This commit is contained in:
mjallen18
2025-12-14 21:50:50 -06:00
parent 0012a019fc
commit 34539045e5
41 changed files with 164 additions and 251 deletions

View File

@@ -7,59 +7,42 @@
}:
with lib;
let
cfg = config.${namespace}.services.actual;
name = "actual";
cfg = config.${namespace}.services.${name};
actualConfig = {
services.actual = {
enable = true;
openFirewall = true;
settings = {
trustedProxies = [ "10.0.1.3" ];
port = cfg.port;
dataDir = cfg.dataDir;
serverFiles = "${cfg.dataDir}/server-files";
userFiles = "${cfg.dataDir}/user-files";
actualConfig = lib.${namespace}.mkModule rec {
inherit name;
description = "Actual Personal Finance Planner";
options = { };
moduleConfig = {
services.actual = {
enable = true;
openFirewall = true;
settings = {
trustedProxies = [ config.${namespace}.network.ipv4.address ];
port = cfg.port;
configDir = cfg.configDir;
serverFiles = "${cfg.configDir}/server-files";
userFiles = "${cfg.configDir}/user-files";
};
};
};
systemd.services = {
actual = {
environment.ACTUAL_CONFIG_PATH = lib.mkForce "${cfg.dataDir}/config.json";
serviceConfig = {
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config ${cfg.dataDir}/config.json";
WorkingDirectory = lib.mkForce cfg.dataDir;
StateDirectoryMode = lib.mkForce 700;
DynamicUser = lib.mkForce false;
ProtectSystem = lib.mkForce "full";
systemd.services = lib.mkIf cfg.createUser {
actual = {
environment.ACTUAL_CONFIG_PATH = lib.mkForce "${cfg.configDir}/config.json";
serviceConfig = {
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config ${cfg.configDir}/config.json";
WorkingDirectory = lib.mkForce cfg.configDir;
StateDirectoryMode = lib.mkForce 700;
DynamicUser = lib.mkForce false;
ProtectSystem = lib.mkForce "full";
};
};
};
};
users.users.actual = {
isSystemUser = true;
group = "actual";
home = cfg.dataDir;
};
users.groups.actual = { };
inherit config;
};
# Create reverse proxy configuration using mkReverseProxy
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
name = "actual";
subdomain = cfg.reverseProxy.subdomain;
url = "http://${cfg.localAddress}:${toString cfg.port}";
middlewares = cfg.reverseProxy.middlewares;
};
fullConfig = {
"${namespace}".services.traefik = lib.mkIf cfg.reverseProxy.enable {
reverseProxies = [ reverseProxyConfig ];
};
}
// actualConfig;
in
{
imports = [ ./options.nix ];
config = mkIf cfg.enable fullConfig;
imports = [ actualConfig ];
}