48 lines
1.2 KiB
Nix
48 lines
1.2 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
namespace,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
name = "actual";
|
|
cfg = config.${namespace}.services.${name};
|
|
|
|
actualConfig = lib.${namespace}.mkModule {
|
|
inherit config name;
|
|
description = "Actual Personal Finance Planner";
|
|
options = { };
|
|
moduleConfig = {
|
|
services.actual = {
|
|
inherit (cfg) openFirewall;
|
|
enable = true;
|
|
settings = {
|
|
inherit (cfg) port;
|
|
trustedProxies = [ config.${namespace}.network.ipv4.address ];
|
|
serverFiles = "${cfg.configDir}/${name}/server-files";
|
|
userFiles = "${cfg.configDir}/${name}/user-files";
|
|
dataDir = "${cfg.configDir}/${name}";
|
|
};
|
|
};
|
|
|
|
systemd.services = lib.mkIf cfg.createUser {
|
|
actual = {
|
|
environment.ACTUAL_CONFIG_PATH = lib.mkForce "/run/actual/config.json";
|
|
serviceConfig = {
|
|
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config /run/actual/config.json";
|
|
WorkingDirectory = lib.mkForce "${cfg.configDir}/${name}";
|
|
StateDirectoryMode = lib.mkForce 700;
|
|
DynamicUser = lib.mkForce false;
|
|
ProtectSystem = lib.mkForce "full";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
imports = [ actualConfig ];
|
|
}
|