nix-dotfiles/nixosModules/services/fava/service.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2025-08-26 08:55:51 -07:00
{ config, pkgs, lib, ... }:
{
options.fava = {
enable = lib.mkEnableOption "Enables fava double entry accounting";
ledgerFile = lib.mkOption { default = "/var/lib/fava/ledger.beancount"; };
port = lib.mkOption { default = "5000"; };
host = lib.mkOption { default = "localhost"; };
};
config = lib.mkIf config.fava.enable {
systemd.services.fava = {
description = "Fava";
after = [ "network-online.target" ];
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}";
Type = "simple";
User = "fava";
Group = "fava";
Restart = "on-failure";
RestartSec = "5s";
NoNewPrivileges = true;
PrivateTmp = true;
PrivateDevices = true;
ProtectHome = true;
ProtectSystem = "full";
ReadWriteDirectories = "/var/lib/fava";
};
};
users.users.fava = {
home = "/var/lib/fava";
createHome = true;
isSystemUser = true;
group = "fava";
};
users.groups.fava = {};
system.extraPkgs = [
pkgs.beancount
];
};
}