tangled
alpha
login
or
join now
pyrox.dev
/
nix
My Nix Configuration
1
fork
atom
overview
issues
pulls
pipelines
[marvin.services] planka: use native instead of docker
pyrox.dev
2 months ago
d19571cc
0f2e217f
+97
-32
1 changed file
expand all
collapse all
unified
split
hosts
marvin
services
planka.nix
+97
-32
hosts/marvin/services/planka.nix
···
1
1
{
2
2
+
lib,
2
3
config,
3
4
self,
5
5
+
self',
6
6
+
pkgs,
4
7
...
5
8
}:
6
9
let
7
7
-
dataDir = "/var/lib/planka";
8
10
d = self.lib.data.services.planka;
11
11
+
12
12
+
commonServiceConfig = {
13
13
+
EnvironmentFile = config.age.secrets.planka-env.path;
14
14
+
StateDirectory = "planka";
15
15
+
WorkingDirectory = "/var/lib/planka";
16
16
+
User = "planka";
17
17
+
Group = "planka";
18
18
+
19
19
+
# Hardening
20
20
+
LockPersonality = true;
21
21
+
NoNewPrivileges = true;
22
22
+
PrivateDevices = true;
23
23
+
PrivateMounts = true;
24
24
+
PrivateTmp = true;
25
25
+
PrivateUsers = true;
26
26
+
ProtectClock = true;
27
27
+
ProtectControlGroups = true;
28
28
+
ProtectHome = true;
29
29
+
ProtectHostname = true;
30
30
+
ProtectKernelLogs = true;
31
31
+
ProtectKernelModules = true;
32
32
+
ProtectKernelTunables = true;
33
33
+
ProtectProc = "invisible";
34
34
+
RemoveIPC = true;
35
35
+
RestrictRealtime = true;
36
36
+
RestrictSUIDSGID = true;
37
37
+
UMask = "0660";
38
38
+
RestrictAddressFamilies = [
39
39
+
"AF_UNIX"
40
40
+
"AF_INET"
41
41
+
"AF_INET6"
42
42
+
];
43
43
+
};
9
44
in
10
45
{
11
11
-
virtualisation.oci-containers.containers = {
12
12
-
planka-server = {
13
13
-
image = "ghcr.io/plankanban/planka:2.0.0-rc.4";
14
14
-
ports = [ "${toString d.port}:1337" ];
15
15
-
environment = {
16
16
-
BASE_URL = "https://${d.extUrl}";
17
17
-
DATABASE_URL = "postgresql://planka@planka-db/planka";
18
18
-
# Default Admin
19
19
-
DEFAULT_ADMIN_EMAIL = "pyrox@pyrox.dev";
20
20
-
DEFAULT_ADMIN_USERNAME = "pyrox";
21
21
-
TRUST_PROXY = "true";
22
22
-
DEFAULT_LANGUAGE = "en-US";
46
46
+
systemd = {
47
47
+
tmpfiles.settings = {
48
48
+
"10-planka"."/var/lib/planka".d = {
49
49
+
group = "planka";
50
50
+
user = "planka";
51
51
+
mode = "0755";
23
52
};
24
24
-
environmentFiles = [ config.age.secrets.planka-env.path ];
25
25
-
volumes = [
26
26
-
"${dataDir}/user-avatars:/app/public/user-avatars"
27
27
-
"${dataDir}/project-background-images:/app/public/project-background-images"
28
28
-
"${dataDir}/attachments:/app/private/attachments"
29
29
-
"${dataDir}/favicons:/app/public/favicons"
30
30
-
"${dataDir}/background-images:/app/public/background-images"
31
31
-
];
32
32
-
extraOptions = [ "--network=planka" ];
33
53
};
34
34
-
planka-db = {
35
35
-
image = "postgres:16-alpine";
36
36
-
volumes = [ "${dataDir}/db:/var/lib/postgresql/data" ];
37
37
-
environment = {
38
38
-
POSTGRES_USER = "planka";
39
39
-
POSTGRES_DB = "planka";
40
40
-
POSTGRES_HOST_AUTH_METHOD = "trust";
54
54
+
services = {
55
55
+
planka-init-db = {
56
56
+
wantedBy = [ "multi-user.target" ];
57
57
+
after = [ "postgres.target" ];
58
58
+
description = "Planka Kanban Database Init Script";
59
59
+
path = [
60
60
+
pkgs.nodejs
61
61
+
];
62
62
+
script = ''
63
63
+
if [ ! -f /var/lib/planka/db-init-ran ]; then
64
64
+
node run ${self'.packages.planka}/lib/node_modules/planka/db/init.js && \
65
65
+
touch /var/lib/planka/db-init-ran
66
66
+
fi
67
67
+
'';
68
68
+
serviceConfig = commonServiceConfig // {
69
69
+
Type = "oneshot";
70
70
+
SyslogIdentifier = "planka-init-db";
71
71
+
};
41
72
};
42
42
-
extraOptions = [ "--network=planka" ];
73
73
+
planka-server = {
74
74
+
after = [ "planka-init-db.service" ];
75
75
+
wantedBy = [ "multi-user.target" ];
76
76
+
description = "Planka Kanban Server";
77
77
+
documentation = [ "https://docs.planka.cloud" ];
78
78
+
environment = {
79
79
+
DATABASE_URL = "postgresql://%2Frun%2Fpostgresql/planka";
80
80
+
DEFAULT_ADMIN_EMAIL = "pyrox@pyrox.dev";
81
81
+
DEFAULT_ADMIN_USERNAME = "pyrox";
82
82
+
TRUST_PROXY = "true";
83
83
+
DEFAULT_LANGUAGE = "en-US";
84
84
+
BASE_URL = "https://${d.extUrl}";
85
85
+
NODE_ENV = "production";
86
86
+
};
87
87
+
serviceConfig = commonServiceConfig // {
88
88
+
Type = "simple";
89
89
+
ExecStart = "${lib.getExe self'.packages.planka} --port ${toString d.port}";
90
90
+
SyslogIdentifier = "planka";
91
91
+
};
92
92
+
};
43
93
};
44
94
};
95
95
+
users.users.planka = {
96
96
+
isSystemUser = true;
97
97
+
group = "planka";
98
98
+
};
99
99
+
users.groups.planka = { };
100
100
+
services.postgresql = {
101
101
+
ensureUsers = [
102
102
+
{
103
103
+
name = "planka";
104
104
+
ensureDBOwnership = true;
105
105
+
ensureClauses.login = true;
106
106
+
}
107
107
+
];
108
108
+
ensureDatabases = [ "planka" ];
109
109
+
};
45
110
age.secrets.planka-env = {
46
111
file = ./secrets/planka-env.age;
47
47
-
owner = "thehedgehog";
48
48
-
group = "misc";
112
112
+
owner = "planka";
113
113
+
group = "planka";
49
114
};
50
115
services.anubis.instances.planka = {
51
116
settings = {