tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
zerobin service : init
Théophane Hufschmitt
9 years ago
201590fd
22e2cfe9
+103
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
networking
zerobin.nix
+1
nixos/modules/module-list.nix
···
401
401
./services/networking/wicd.nix
402
402
./services/networking/wpa_supplicant.nix
403
403
./services/networking/xinetd.nix
404
404
+
./services/networking/zerobin.nix
404
405
./services/networking/zerotierone.nix
405
406
./services/networking/znc.nix
406
407
./services/printing/cupsd.nix
+102
nixos/modules/services/networking/zerobin.nix
···
1
1
+
{ config, pkgs, lib, nodes, ... }:
2
2
+
with lib;
3
3
+
let
4
4
+
cfg = config.services.zerobin;
5
5
+
6
6
+
zerobin_config = pkgs.writeText "zerobin-config.py" ''
7
7
+
PASTE_FILES_ROOT = "${cfg.dataDir}"
8
8
+
${cfg.extraConfig}
9
9
+
'';
10
10
+
11
11
+
in
12
12
+
{
13
13
+
options = {
14
14
+
services.zerobin = {
15
15
+
enable = mkEnableOption "0bin";
16
16
+
17
17
+
dataDir = mkOption {
18
18
+
type = types.str;
19
19
+
default = "/var/lib/zerobin";
20
20
+
description = ''
21
21
+
Path to the 0bin data directory
22
22
+
'';
23
23
+
};
24
24
+
25
25
+
user = mkOption {
26
26
+
type = types.str;
27
27
+
default = "zerobin";
28
28
+
description = ''
29
29
+
The user 0bin should run as
30
30
+
'';
31
31
+
};
32
32
+
33
33
+
group = mkOption {
34
34
+
type = types.str;
35
35
+
default = "zerobin";
36
36
+
description = ''
37
37
+
The group 0bin should run as
38
38
+
'';
39
39
+
};
40
40
+
41
41
+
listenPort = mkOption {
42
42
+
type = types.int;
43
43
+
default = 8000;
44
44
+
example = 1357;
45
45
+
description = ''
46
46
+
The port zerobin should listen on
47
47
+
'';
48
48
+
};
49
49
+
50
50
+
listenAddress = mkOption {
51
51
+
type = types.str;
52
52
+
default = "localhost";
53
53
+
example = "127.0.0.1";
54
54
+
description = ''
55
55
+
The address zerobin should listen to
56
56
+
'';
57
57
+
};
58
58
+
59
59
+
extraConfig = mkOption {
60
60
+
type = types.lines;
61
61
+
default = "";
62
62
+
example = ''
63
63
+
MENU = (
64
64
+
('Home', '/'),
65
65
+
)
66
66
+
COMPRESSED_STATIC_FILE = True
67
67
+
'';
68
68
+
description = ''
69
69
+
Extra configuration to be appended to the 0bin config file
70
70
+
(see https://0bin.readthedocs.org/en/latest/en/options.html)
71
71
+
'';
72
72
+
};
73
73
+
};
74
74
+
};
75
75
+
76
76
+
config = mkIf (cfg.enable) {
77
77
+
users.users."${cfg.user}" =
78
78
+
if cfg.user == "zerobin" then {
79
79
+
isSystemUser = true;
80
80
+
group = cfg.group;
81
81
+
home = cfg.dataDir;
82
82
+
createHome = true;
83
83
+
}
84
84
+
else {};
85
85
+
users.groups."${cfg.group}" = {};
86
86
+
87
87
+
systemd.services.zerobin = {
88
88
+
enable = true;
89
89
+
after = [ "network-interfaces.target" ];
90
90
+
wantedBy = [ "multi-user.target" ];
91
91
+
serviceConfig.ExecStart = "${pkgs.pythonPackages.zerobin}/bin/zerobin ${cfg.listenAddress} ${toString cfg.listenPort} false ${cfg.user} ${cfg.group} ${zerobin_config}";
92
92
+
serviceConfig.PrivateTmp="yes";
93
93
+
serviceConfig.User = cfg.user;
94
94
+
serviceConfig.Group = cfg.group;
95
95
+
preStart = ''
96
96
+
mkdir -p ${cfg.dataDir}
97
97
+
chown ${cfg.user} ${cfg.dataDir}
98
98
+
'';
99
99
+
};
100
100
+
};
101
101
+
}
102
102
+