Fava, change ledgers to list

This commit is contained in:
Julia Lange 2025-09-15 11:29:52 -07:00
parent 1de1ba027b
commit a2939e5613
Signed by: Julia
SSH key fingerprint: SHA256:50XUMcOFYPUs9/1j7p9SPnwASZ7QnxXm7THF7HkbqzQ

View file

@ -3,9 +3,12 @@
{ {
options.fava = { options.fava = {
enable = lib.mkEnableOption "Enables fava double entry accounting"; 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"; }; port = lib.mkOption { default = "5000"; };
host = lib.mkOption { default = "localhost"; }; host = lib.mkOption { default = "localhost"; };
favaHome = lib.mkOption { default = "/var/lib/fava"; };
}; };
config = lib.mkIf config.fava.enable { config = lib.mkIf config.fava.enable {
@ -15,7 +18,13 @@
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { 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"; Type = "simple";
User = "fava"; User = "fava";
Group = "fava"; Group = "fava";
@ -26,12 +35,12 @@
PrivateDevices = true; PrivateDevices = true;
ProtectHome = true; ProtectHome = true;
ProtectSystem = "full"; ProtectSystem = "full";
ReadWriteDirectories = "/var/lib/fava"; ReadWriteDirectories = config.fava.favaHome;
}; };
}; };
users.users.fava = { users.users.fava = {
home = "/var/lib/fava"; home = config.fava.favaHome;
createHome = true; createHome = true;
isSystemUser = true; isSystemUser = true;
group = "fava"; group = "fava";