Skip to content

Commit

Permalink
Fix nix scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
NCrashed committed Jul 5, 2022
1 parent 71304f0 commit 46f7ba9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
20 changes: 18 additions & 2 deletions nix/hexstody-btc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ in {
Which hostname is binded to the node.
'';
};
domain = mkOption {
type = types.str;
description = ''
Which domain is binded to the node.
'';
};
operatorKeys = mkOption {
type = types.listOf types.str;
description = ''
Public keys of operators
'';
};

btcNode = mkOption {
type = types.str;
Expand Down Expand Up @@ -98,14 +110,18 @@ in {
description = "Hexstody BTC adapter";
after = ["network.target" cfg.passwordFileService cfg.secretKeyService];
wants = ["network.target" cfg.passwordFileService cfg.secretKeyService];
script = ''
script = let
mkKeyFile = content: pkgs.writeText "operator-pubkey.pem" content;
in ''
export HEXSTODY_BTC_NODE_PASSWORD=$(cat ${cfg.passwordFile} | xargs echo -n)
export HEXSTODY_BTC_SECRET_KEY=$(cat ${cfg.secretKey} | xargs echo -n)
${cfg.package}/bin/hexstody-btc serve \
--address ${cfg.host} \
--node-url ${cfg.btcNode} \
--node-user ${cfg.rpcUser} \
--port ${builtins.toString cfg.port}
--port ${builtins.toString cfg.port} \
--hot-domain ${cfg.domain} \
--operator-public-keys ${pkgs.lib.concatStringsSep " " (builtins.map mkKeyFile cfg.operatorKeys)}
'';
serviceConfig = {
Restart = "always";
Expand Down
18 changes: 17 additions & 1 deletion nix/hexstody-hot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ in {
Which hostname is binded to the node.
'';
};
domain = mkOption {
type = types.str;
description = ''
Which domain is binded to the node.
'';
};
operatorKeys = mkOption {
type = types.listOf types.str;
description = ''
Public keys of operators
'';
};

btcModule = mkOption {
type = types.str;
Expand Down Expand Up @@ -113,7 +125,9 @@ in {
description = "Hexstody hot wallet";
after = ["network.target" cfg.passwordFileService cfg.secretKeyService];
wants = ["network.target" cfg.passwordFileService cfg.secretKeyService];
script = ''
script = let
mkKeyFile = content: pkgs.writeText "operator-pubkey.pem" content;
in ''
export DB_PASSWORD=$(cat ${cfg.passwordFile} | xargs echo -n)
export DATABASE_URL="postgresql://${cfg.databaseUser}:$DB_PASSWORD@${cfg.databaseHost}/${cfg.databaseName}"
export HEXSTODY_OPERATOR_API_SECRET_KEY=$(cat ${cfg.secretKey} | xargs echo -n)
Expand All @@ -125,6 +139,8 @@ in {
--public-api-static-path ${cfg.package}/share/public/static \
--operator-api-template-path ${cfg.package}/share/operator/templates \
--public-api-template-path ${cfg.package}/share/public/templates \
--hot-domain ${cfg.domain} \
--operator-public-keys ${pkgs.lib.concatStringsSep " " (builtins.map mkKeyFile cfg.operatorKeys)} \
serve
'';
serviceConfig = {
Expand Down

0 comments on commit 46f7ba9

Please sign in to comment.