103 lines
2.4 KiB
Nix
103 lines
2.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
my,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.guests.actualbudget;
|
|
dataDir = "/data";
|
|
in
|
|
{
|
|
imports = [
|
|
(my.guest {
|
|
name = "actualbudget";
|
|
interior = {
|
|
modules.services.actualbudget = {
|
|
enable = true;
|
|
inherit dataDir;
|
|
};
|
|
};
|
|
})
|
|
];
|
|
|
|
options.guests.actualbudget = {
|
|
reverseProxy = {
|
|
enable = lib.mkEnableOption "the public reverse-proxy route for the Actual Budget guest";
|
|
|
|
host = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Primary hostname served by the Actual Budget route.";
|
|
};
|
|
|
|
aliases = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
description = "Additional hostnames served by the Actual Budget route.";
|
|
};
|
|
|
|
path = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/";
|
|
description = "URL path prefix proxied to Actual Budget.";
|
|
};
|
|
|
|
backend = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Full HTTP backend URL for the Actual Budget service.";
|
|
};
|
|
|
|
tls = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Whether to serve Actual Budget with ACME-backed TLS.";
|
|
};
|
|
|
|
websockets = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Whether to enable websocket proxying for Actual Budget.";
|
|
};
|
|
};
|
|
|
|
dataPath = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
example = "/srv/actualbudget";
|
|
description = "Host path bind-mounted as Actual Budget's data directory.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
(lib.mkIf (cfg.enable && cfg.reverseProxy.enable) {
|
|
modules.reverse-proxy.routes.actualbudget = {
|
|
inherit (cfg.reverseProxy)
|
|
host
|
|
aliases
|
|
path
|
|
backend
|
|
tls
|
|
websockets
|
|
;
|
|
};
|
|
})
|
|
(lib.mkIf cfg.enable {
|
|
assertions = [
|
|
{
|
|
assertion = cfg.dataPath != null;
|
|
message = "guests.actualbudget.dataPath must point at the host directory that stores Actual Budget data.";
|
|
}
|
|
];
|
|
|
|
guests.actualbudget = {
|
|
mounts.${dataDir}.hostPath = cfg.dataPath;
|
|
limits = {
|
|
memory = lib.mkDefault "2G";
|
|
cpu = lib.mkDefault "200%";
|
|
tasksMax = lib.mkDefault 512;
|
|
};
|
|
};
|
|
})
|
|
];
|
|
}
|