diff --git a/nixosModules/services/fava/service.nix b/nixosModules/services/fava/service.nix index 12ea6c2..f43930f 100644 --- a/nixosModules/services/fava/service.nix +++ b/nixosModules/services/fava/service.nix @@ -3,9 +3,12 @@ { options.fava = { enable = lib.mkEnableOption "Enables fava double entry accounting"; - ledgerFile = lib.mkOption { default = "/var/lib/fava/ledger.beancount"; }; + ledgerFiles = lib.mkOption { + default = ["/var/lib/fava/ledger.beancount"]; + }; port = lib.mkOption { default = "5000"; }; host = lib.mkOption { default = "localhost"; }; + favaHome = lib.mkOption { default = "/var/lib/fava"; }; }; config = lib.mkIf config.fava.enable { @@ -15,7 +18,13 @@ wants = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { - ExecStart = "${pkgs.fava}/bin/fava --port ${config.fava.port} --host ${config.fava.host} ${config.fava.ledgerFile}"; + ExecStart = with config.fava; let + command = lib.concatStringsSep " " ([ + "${pkgs.fava}/bin/fava" + "--port ${port}" + "--host ${host}" + ] ++ ["--"] ++ ledgerFiles); + in command; Type = "simple"; User = "fava"; Group = "fava"; @@ -26,12 +35,12 @@ PrivateDevices = true; ProtectHome = true; ProtectSystem = "full"; - ReadWriteDirectories = "/var/lib/fava"; + ReadWriteDirectories = config.fava.favaHome; }; }; users.users.fava = { - home = "/var/lib/fava"; + home = config.fava.favaHome; createHome = true; isSystemUser = true; group = "fava";