From ccef870b74cc17c0986c5a09f66ae51ce97f1c34 Mon Sep 17 00:00:00 2001 From: nixbitcoin Date: Tue, 16 Feb 2021 16:51:15 +0000 Subject: [PATCH] spark-wallet: add user & group options --- modules/spark-wallet.nix | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/spark-wallet.nix b/modules/spark-wallet.nix index 419cb3c..8ffdc21 100644 --- a/modules/spark-wallet.nix +++ b/modules/spark-wallet.nix @@ -48,17 +48,27 @@ in { encodes an URL for accessing the web interface. ''; }; + user = mkOption { + type = types.str; + default = "spark-wallet"; + description = "The user as which to run spark-wallet."; + }; + group = mkOption { + type = types.str; + default = cfg.user; + description = "The group as which to run spark-wallet."; + }; inherit (nbLib) enforceTor; }; config = mkIf cfg.enable { services.clightning.enable = true; - users.users.spark-wallet = { - group = "spark-wallet"; - extraGroups = [ "clightning" ]; + users.users.${cfg.user} = { + group = cfg.group; + extraGroups = [ config.services.clightning.group ]; }; - users.groups.spark-wallet = {}; + users.groups.${cfg.group} = {}; systemd.services.spark-wallet = { wantedBy = [ "multi-user.target" ]; @@ -66,7 +76,7 @@ in { after = [ "clightning.service" ]; script = startScript; serviceConfig = nbLib.defaultHardening // { - User = "spark-wallet"; + User = cfg.user; Restart = "on-failure"; RestartSec = "10s"; } // (if cfg.enforceTor @@ -74,6 +84,6 @@ in { else nbLib.allowAnyIP) // nbLib.nodejs; }; - nix-bitcoin.secrets.spark-wallet-login.user = "spark-wallet"; + nix-bitcoin.secrets.spark-wallet-login.user = cfg.user; }; }