rtl: add option extraCurrency

This commit is contained in:
Erik Arvstedt 2021-11-26 15:13:37 +01:00
parent 62a2602e78
commit 10a744a598
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
2 changed files with 18 additions and 1 deletions

View File

@ -49,6 +49,17 @@ let
default = false; default = false;
description = "Enable the Night UI Theme."; description = "Enable the Night UI Theme.";
}; };
extraCurrency = mkOption {
type = with types; nullOr str;
default = null;
example = "USD";
description = ''
Currency code (ISO 4217) of the extra currency used for displaying balances.
When set, this option enables online currency rate fetching.
Warning: Rate fetching requires outgoing clearnet connections, so option
`tor.enforce` is automatically disabled.
'';
};
user = mkOption { user = mkOption {
type = types.str; type = types.str;
default = "rtl"; default = "rtl";
@ -118,7 +129,10 @@ let
''"channelBackupPath": "${cfg.dataDir}/backup/lnd",'' ''"channelBackupPath": "${cfg.dataDir}/backup/lnd",''
} }
"logLevel": "INFO", "logLevel": "INFO",
"fiatConversion": false, "fiatConversion": ${if cfg.extraCurrency == null then "false" else "true"},
${optionalString (cfg.extraCurrency != null)
''"currencyUnit": "${cfg.extraCurrency}",''
}
${optionalString (isLnd && cfg.loop) ${optionalString (isLnd && cfg.loop)
''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",'' ''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",''
} }
@ -190,6 +204,8 @@ in {
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
]; ];
services.rtl.tor.enforce = mkIf (cfg.extraCurrency != null) false;
systemd.services.rtl = rec { systemd.services.rtl = rec {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
requires = optional cfg.nodes.clightning "cl-rest.service" ++ requires = optional cfg.nodes.clightning "cl-rest.service" ++

View File

@ -67,6 +67,7 @@ let
nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce '' nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce ''
echo a > rtl-password echo a > rtl-password
''); '');
services.rtl.extraCurrency = mkDefault "CHF";
tests.spark-wallet = cfg.spark-wallet.enable; tests.spark-wallet = cfg.spark-wallet.enable;