nixos module for actual

This commit is contained in:
xenofem 2024-05-09 18:46:45 -04:00
parent c6a9f51675
commit f42cc7b10e

View file

@ -122,5 +122,48 @@
"${pname}" = package; "${pname}" = package;
default = package; default = package;
}; };
nixosModules.default = { lib, config, ... }:
with lib;
let
cfg = config.services.actual-server;
dataDir = "/var/lib/actual";
cfgFile = writeText "actual.json" (builtins.toJSON {
inherit dataDir;
inherit (cfg) hostname port;
serverFiles = "${dataDir}/server-files";
userFiles = "${dataDir}/user-files";
});
in {
options.services.actual = {
enable = mkEnableOption "Actual budget server";
hostname = mkOption { type = types.str; default = "127.0.0.1"; };
port = mkOption { type = types.port; default = 5006; };
};
config = mkIf cfg.enable {
users.users.actual = {
name = "actual";
group = "actual";
isSystemUser = true;
};
users.groups.actual = {};
systemd.services.actual-server = {
description = "Actual budget server";
documentation = [ "https://actualbudget.org/docs/" ];
wantedBy = [ "multi-user.target" ];
after = [ "networking.target" ];
serviceConfig = {
ExecStart = "${package}/bin/actual";
Restart = "always";
User = "actual";
Group = "actual";
PrivateTmp = true;
StateDirectory = "actual";
};
environment.ACTUAL_CONFIG_PATH = "${cfgFile}";
};
};
};
}; };
} }