spark-wallet: simplify start script
Also: - quote paths - use long form args
This commit is contained in:
parent
0f32f3c99e
commit
127b186c3c
@ -6,19 +6,21 @@ let
|
|||||||
cfg = config.services.spark-wallet;
|
cfg = config.services.spark-wallet;
|
||||||
inherit (config) nix-bitcoin-services;
|
inherit (config) nix-bitcoin-services;
|
||||||
onion-chef-service = (if cfg.onion-service then [ "onion-chef.service" ] else []);
|
onion-chef-service = (if cfg.onion-service then [ "onion-chef.service" ] else []);
|
||||||
run-spark-wallet = pkgs.writeScript "run-spark-wallet" ''
|
|
||||||
CMD="${pkgs.nix-bitcoin.spark-wallet}/bin/spark-wallet --ln-path ${cfg.ln-path} --host ${cfg.host} -Q -k -c ${config.nix-bitcoin.secretsDir}/spark-wallet-login ${cfg.extraArgs}"
|
# Use wasabi rate provider because the default (bitstamp) doesn't accept
|
||||||
${optionalString cfg.onion-service
|
# connections through Tor
|
||||||
''
|
torRateProvider = "--rate-provider wasabi --proxy socks5h://${config.services.tor.client.socksListenAddress}";
|
||||||
echo Getting onion hostname
|
startScript = ''
|
||||||
CMD="$CMD --public-url http://$(cat /var/lib/onion-chef/spark-wallet/spark-wallet)"
|
${optionalString cfg.onion-service ''
|
||||||
''
|
publicURL="--public-url http://$(cat /var/lib/onion-chef/spark-wallet/spark-wallet)"
|
||||||
}
|
''}
|
||||||
# Use rate provide wasabi because default (bitstamp) doesn't accept
|
exec ${pkgs.nix-bitcoin.spark-wallet}/bin/spark-wallet \
|
||||||
# connections through Tor and add proxy for rate lookup.
|
--ln-path '${cfg.ln-path}' \
|
||||||
CMD="$CMD --rate-provider wasabi --proxy socks5h://${config.services.tor.client.socksListenAddress}"
|
--host ${cfg.host} \
|
||||||
echo Running $CMD
|
--config '${config.nix-bitcoin.secretsDir}/spark-wallet-login' \
|
||||||
$CMD
|
${torRateProvider} \
|
||||||
|
$publicURL \
|
||||||
|
--pairing-qr --print-key ${cfg.extraArgs}
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
options.services.spark-wallet = {
|
options.services.spark-wallet = {
|
||||||
@ -84,8 +86,8 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
requires = [ "clightning.service" ] ++ onion-chef-service;
|
requires = [ "clightning.service" ] ++ onion-chef-service;
|
||||||
after = [ "clightning.service" ] ++ onion-chef-service;
|
after = [ "clightning.service" ] ++ onion-chef-service;
|
||||||
|
script = startScript;
|
||||||
serviceConfig = nix-bitcoin-services.defaultHardening // {
|
serviceConfig = nix-bitcoin-services.defaultHardening // {
|
||||||
ExecStart = "${pkgs.bash}/bin/bash ${run-spark-wallet}";
|
|
||||||
User = "spark-wallet";
|
User = "spark-wallet";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
|
Loading…
Reference in New Issue
Block a user