-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodule.nix
More file actions
81 lines (79 loc) · 1.93 KB
/
module.nix
File metadata and controls
81 lines (79 loc) · 1.93 KB
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
71
72
73
74
75
76
77
78
79
80
81
{
config,
lib,
pkgs,
...
}:
with lib; let
options = {
services.boostbox = {
enable = mkEnableOption "BoostBox, a simple API for hosting Podcasting 2.0 boost metadata";
package = mkOption {
type = types.package;
};
user = mkOption {
type = types.str;
default = "boostbox";
description = "User account under which the BoostBox service runs.";
};
group = mkOption {
type = types.str;
default = "boostbox";
description = "Group under which the BoostBox service runs.";
};
port = mkOption {
type = types.port;
default = 8080;
description = "HTTP API and docs port.";
};
extraEnvironment = lib.mkOption {
description = ''
Environment variables to pass to BoostBox.
'';
type = types.attrsOf lib.types.str;
default = {};
example = literalExpression ''
{
BB_STORAGE = "FS";
}
'';
};
};
};
cfg = config.services.boostbox;
env = mkMerge [
{
HOME = "/var/lib/boostbox";
ENV = "PROD";
BB_FS_ROOT_PATH = "/var/lib/boostbox";
BB_PORT = "${builtins.toString cfg.port}";
}
cfg.extraEnvironment
];
in {
inherit options;
config = mkIf cfg.enable {
users.groups.${cfg.group} = {};
users.users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
};
systemd.services.boostbox = {
description = "BoostBox";
wantedBy = ["multi-user.target"];
after = ["network.target"];
environment = env;
serviceConfig = {
ExecStart = "${getExe cfg.package}";
User = cfg.user;
Group = cfg.group;
Restart = "on-failure";
RestartSec = 10;
StateDirectory = "boostbox";
WorkingDirectory = "/var/lib/boostbox";
LockPersonality = true;
NoNewPrivileges = true;
};
};
};
}