Skip to content

Commit

Permalink
nixos/hledger-web: set capabilites as boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
erictapen committed Mar 26, 2021
1 parent 73c4f3b commit 55c7cb3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
33 changes: 27 additions & 6 deletions nixos/modules/services/web-apps/hledger-web.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,28 @@ in {
'';
};

capabilities = mkOption {
type = types.commas;
default = "view";
description = ''
Enable the view, add, and/or manage capabilities. E.g. view,add
'';
capabilities = {
view = mkOption {
type = types.bool;
default = true;
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 {
Expand Down Expand Up @@ -86,6 +102,11 @@ in {
users.groups.hledger = {};

systemd.services.hledger-web = let
capabilityString = with cfg.capabilities; concatStringsSep "," (
(optional view "view")
++ (optional add "add")
++ (optional manage "manage")
);
serverArgs = with cfg; escapeShellArgs ([
"--serve"
"--host=${host}"
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/hledger-web.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rec {
host = "127.0.0.1";
port = 5000;
enable = true;
capabilities.manage = true;
};
networking.firewall.allowedTCPPorts = [ config.services.hledger-web.port ];
systemd.services.hledger-web.preStart = ''
Expand Down

0 comments on commit 55c7cb3

Please sign in to comment.