-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimmich.nix
70 lines (62 loc) · 1.38 KB
/
immich.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{ config, lib, ... }:
{
users = {
users.immich.uid = 998;
groups.immich.gid = 998;
};
sops.secrets =
let
immichOwned = {
owner = config.users.users.immich.name;
inherit (config.users.users.immich) group;
};
in
{
"POSTGRES/IMMICH_PASSWORD" = immichOwned;
"IMMICH/ENV" = immichOwned;
};
services = {
immich = {
enable = true;
host = "0.0.0.0";
secretsFile = config.sops.secrets."IMMICH/ENV".path;
environment = {
IMMICH_TRUSTED_PROXIES = "100.64.0.0/10,192.168.1.0/24,192.168.2.0/24";
};
machine-learning = {
enable = true;
environment = { };
};
database = {
enable = true;
createDB = true;
host = "nixio";
};
redis = {
enable = true;
};
};
caddy.virtualHosts."photos".extraConfig =
let
cfg = config.services.immich;
in
''
reverse_proxy http://${cfg.host}:${toString cfg.port}
'';
};
systemd.services = {
postgresql = {
enable = lib.mkForce false;
postStart = ''
${lib.mine.mkPostgresRolePass config.services.immich.database.name
config.sops.secrets."POSTGRES/IMMICH_PASSWORD".path
}
'';
};
};
networking = {
firewall = {
allowedTCPPorts = [ config.services.immich.port ];
};
};
}