spark-wallet: add user & group options

This commit is contained in:
nixbitcoin 2021-02-16 16:51:15 +00:00
parent 85a1722545
commit ccef870b74
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA

View File

@ -48,17 +48,27 @@ in {
encodes an URL for accessing the web interface. 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; inherit (nbLib) enforceTor;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.clightning.enable = true; services.clightning.enable = true;
users.users.spark-wallet = { users.users.${cfg.user} = {
group = "spark-wallet"; group = cfg.group;
extraGroups = [ "clightning" ]; extraGroups = [ config.services.clightning.group ];
}; };
users.groups.spark-wallet = {}; users.groups.${cfg.group} = {};
systemd.services.spark-wallet = { systemd.services.spark-wallet = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
@ -66,7 +76,7 @@ in {
after = [ "clightning.service" ]; after = [ "clightning.service" ];
script = startScript; script = startScript;
serviceConfig = nbLib.defaultHardening // { serviceConfig = nbLib.defaultHardening // {
User = "spark-wallet"; User = cfg.user;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; RestartSec = "10s";
} // (if cfg.enforceTor } // (if cfg.enforceTor
@ -74,6 +84,6 @@ in {
else nbLib.allowAnyIP) else nbLib.allowAnyIP)
// nbLib.nodejs; // nbLib.nodejs;
}; };
nix-bitcoin.secrets.spark-wallet-login.user = "spark-wallet"; nix-bitcoin.secrets.spark-wallet-login.user = cfg.user;
}; };
} }