refactor(actualbudget): split service and guest config

This commit is contained in:
2026-08-11 08:27:04 -04:00
parent eacf2d4b25
commit 67a91d11e9
3 changed files with 102 additions and 21 deletions

View File

@@ -1,23 +1,43 @@
args@{ my, ... }:
# Actual Budget in a NixOS guest, with durable state bind-mounted from the host.
my.guest {
name = "actualbudget";
interior = {
users.users.actual = {
isSystemUser = true;
uid = 20001;
group = "storage";
};
services.actual = {
enable = true;
openFirewall = true;
user = "actual";
group = "storage";
settings = {
port = 5006;
dataDir = "/data";
{
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 = {
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.";
};
};
} args
config = 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;
};
}