nixos/hledger-web: set capabilites as boolean

This commit is contained in:
Justin Humm 2021-03-12 22:09:51 +01:00 committed by erictapen
parent 569940b9fd
commit 347a9168ae
2 changed files with 28 additions and 6 deletions

View file

@ -26,12 +26,28 @@ in {
''; '';
}; };
capabilities = mkOption { capabilities = {
type = types.commas; view = mkOption {
default = "view"; type = types.bool;
description = '' default = true;
Enable the view, add, and/or manage capabilities. E.g. view,add description = ''
''; Enable the view capability.
'';
};
add = mkOption {
type = types.bool;
default = false;
description = ''
Enable the add capability.
'';
};
manage = mkOption {
type = types.bool;
default = false;
description = ''
Enable the manage capability.
'';
};
}; };
stateDir = mkOption { stateDir = mkOption {
@ -86,6 +102,11 @@ in {
users.groups.hledger = {}; users.groups.hledger = {};
systemd.services.hledger-web = let systemd.services.hledger-web = let
capabilityString = with cfg.capabilities; concatStringsSep "," (
(optional view "view")
++ (optional add "add")
++ (optional manage "manage")
);
serverArgs = with cfg; escapeShellArgs ([ serverArgs = with cfg; escapeShellArgs ([
"--serve" "--serve"
"--host=${host}" "--host=${host}"

View file

@ -19,6 +19,7 @@ rec {
host = "127.0.0.1"; host = "127.0.0.1";
port = 5000; port = 5000;
enable = true; enable = true;
capabilities.manage = true;
}; };
networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ]; networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ];
systemd.services.hledger-web.preStart = '' systemd.services.hledger-web.preStart = ''