refactor(actualbudget): split service and guest config
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user