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.
'';
};
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;
};
}