-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomebox.nix
54 lines (45 loc) · 1.33 KB
/
homebox.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, ... }:
{
sops.secrets = rec {
HOMEBOX_ENV = {
owner = config.users.users.homebox.name;
inherit (config.users.users.homebox) group;
};
"POSTGRES/HOMEBOX_PASSWORD" = {
inherit (HOMEBOX_ENV) owner group;
};
};
services = rec {
homebox = {
enable = true;
settings = {
HBOX_MODE = "production";
HBOX_WEB_HOST = "0.0.0.0";
HBOX_WEB_PORT = "7745";
HBOX_DATABASE_TYPE = "postgres";
HBOX_DATABASE_HOST = "nixio";
HBOX_DATABASE_PORT = "5432";
HBOX_DATABASE_USERNAME = "homebox";
HBOX_DATABASE_DATABASE = "homebox";
};
};
caddy.virtualHosts."photos".extraConfig = ''
reverse_proxy http://${homebox.settings.HBOX_WEB_HOST}:${toString homebox.settings.HBOX_WEB_PORT}
'';
postgresql = {
ensureDatabases = [ homebox.settings.HBOX_DATABASE_DATABASE ];
ensureUsers = [
{
name = homebox.settings.HBOX_DATABASE_USERNAME;
ensureDBOwnership = true;
}
];
};
};
systemd.services = {
postgresql.postStart =
lib.mine.mkPostgresRolePass config.services.homebox.settings.HBOX_DATABASE_DATABASE
config.sops.secrets."POSTGRES/HOMEBOX_PASSWORD".path;
homebox.serviceConfig.EnvironmentFile = config.sops.secrets.HOMEBOX_ENV.path;
};
}