blob: 6299ad984980e5f5bdedd19443a8e2f1a997045b (
plain)
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
|
flake: { config, lib, pkgs, ... }:
let
cfg = config.services.witryna;
in
{
options.services.witryna = {
enable = lib.mkEnableOption "witryna deployment service";
package = lib.mkOption {
type = lib.types.package;
default = flake.packages.${pkgs.stdenv.hostPlatform.system}.witryna;
description = "The witryna package to use.";
};
configFile = lib.mkOption {
type = lib.types.path;
description = "Path to witryna.toml configuration file.";
};
};
config = lib.mkIf cfg.enable {
users.users.witryna = {
isSystemUser = true;
group = "witryna";
home = "/var/lib/witryna";
};
users.groups.witryna = {};
systemd.tmpfiles.rules = [
"d /var/lib/witryna 0755 witryna witryna -"
"d /var/lib/witryna/clones 0755 witryna witryna -"
"d /var/lib/witryna/builds 0755 witryna witryna -"
"d /var/lib/witryna/cache 0755 witryna witryna -"
"d /var/log/witryna 0755 witryna witryna -"
];
systemd.services.witryna = {
description = "Witryna - Git-based static site deployment orchestrator";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = "witryna";
Group = "witryna";
ExecStart = "${cfg.package}/bin/witryna serve --config ${cfg.configFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
Restart = "on-failure";
RestartSec = 5;
# Security hardening (mirrors debian/witryna.service)
NoNewPrivileges = true;
PrivateTmp = true;
ProtectSystem = "strict";
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectControlGroups = true;
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
ReadWritePaths = [ "/var/lib/witryna" "/var/log/witryna" "/run/user" ];
LimitNOFILE = 65536;
LimitNPROC = 4096;
};
};
};
}
|