tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixbot module: init
Robin Gloster
9 years ago
c6b050fd
e904bb48
+150
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
web-apps
nixbot.nix
+1
nixos/modules/module-list.nix
···
481
481
./services/ttys/gpm.nix
482
482
./services/ttys/kmscon.nix
483
483
./services/web-apps/mattermost.nix
484
484
+
./services/web-apps/nixbot.nix
484
485
./services/web-apps/pump.io.nix
485
486
./services/web-apps/tt-rss.nix
486
487
./services/web-apps/selfoss.nix
+149
nixos/modules/services/web-apps/nixbot.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
cfg = config.services.nixbot;
7
7
+
pyramidIni = ''
8
8
+
###
9
9
+
# app configuration
10
10
+
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/environment.html
11
11
+
###
12
12
+
13
13
+
[app:main]
14
14
+
use = egg:nixbot
15
15
+
16
16
+
nixbot.github_token = ${cfg.githubToken}
17
17
+
nixbot.bot_name = ${cfg.botName}
18
18
+
nixbot.repo = ${cfg.repo}
19
19
+
nixbot.pr_repo = ${cfg.prRepo}
20
20
+
nixbot.hydra_jobsets_repo = ${cfg.hydraJobsetsRepo}
21
21
+
nixbot.github_secret = justnotsorandom
22
22
+
nixbot.public_url = ${cfg.publicUrl}
23
23
+
nixbot.repo_dir = ${cfg.repoDir}
24
24
+
25
25
+
pyramid.reload_templates = false
26
26
+
pyramid.debug_authorization = false
27
27
+
pyramid.debug_notfound = false
28
28
+
pyramid.debug_routematch = false
29
29
+
pyramid.default_locale_name = en
30
30
+
31
31
+
# By default, the toolbar only appears for clients from IP addresses
32
32
+
# '127.0.0.1' and '::1'.
33
33
+
# debugtoolbar.hosts = 127.0.0.1 ::1
34
34
+
35
35
+
###
36
36
+
# wsgi server configuration
37
37
+
###
38
38
+
39
39
+
[server:main]
40
40
+
use = egg:waitress#main
41
41
+
host = 0.0.0.0
42
42
+
port = 6543
43
43
+
44
44
+
###
45
45
+
# logging configuration
46
46
+
# http://docs.pylonsproject.org/projects/pyramid/en/1.7-branch/narr/logging.html
47
47
+
###
48
48
+
49
49
+
[loggers]
50
50
+
keys = root, nixbot
51
51
+
52
52
+
[handlers]
53
53
+
keys = console
54
54
+
55
55
+
[formatters]
56
56
+
keys = generic
57
57
+
58
58
+
[logger_root]
59
59
+
level = INFO
60
60
+
handlers = console
61
61
+
62
62
+
[logger_nixbot]
63
63
+
level = INFO
64
64
+
handlers =
65
65
+
qualname = nixbot
66
66
+
67
67
+
[handler_console]
68
68
+
class = StreamHandler
69
69
+
args = (sys.stderr,)
70
70
+
level = NOTSET
71
71
+
formatter = generic
72
72
+
73
73
+
[formatter_generic]
74
74
+
format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s
75
75
+
'';
76
76
+
in {
77
77
+
options = {
78
78
+
services.nixbot = {
79
79
+
enable = mkEnableOption "nixbot";
80
80
+
81
81
+
botName = mkOption {
82
82
+
type = types.str;
83
83
+
description = "The bot's github user account name.";
84
84
+
default = "nixbot";
85
85
+
};
86
86
+
87
87
+
githubToken = mkOption {
88
88
+
type = types.str;
89
89
+
description = "The bot's github user account token.";
90
90
+
example = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
91
91
+
};
92
92
+
93
93
+
repo = mkOption {
94
94
+
type = types.str;
95
95
+
description = "The github repository to check for PRs.";
96
96
+
example = "nixos/nixpkgs";
97
97
+
};
98
98
+
99
99
+
prRepo = mkOption {
100
100
+
type = types.str;
101
101
+
description = "The github repository to push the testing branches to.";
102
102
+
example = "nixos/nixpkgs-pr";
103
103
+
};
104
104
+
105
105
+
hydraJobsetsRepo = mkOption {
106
106
+
type = types.str;
107
107
+
description = "The github repository to push the hydra jobset definitions to.";
108
108
+
example = "nixos/hydra-jobsets";
109
109
+
};
110
110
+
111
111
+
publicUrl = mkOption {
112
112
+
type = types.str;
113
113
+
description = "The public URL the bot is reachable at (Github hook endpoint).";
114
114
+
example = "https://nixbot.nixos.org";
115
115
+
};
116
116
+
117
117
+
repoDir = mkOption {
118
118
+
type = types.path;
119
119
+
description = "The directory the repositories are stored in.";
120
120
+
default = "/var/lib/nixbot";
121
121
+
};
122
122
+
};
123
123
+
};
124
124
+
125
125
+
config = mkIf cfg.enable {
126
126
+
users.extraUsers.nixbot = {
127
127
+
createHome = true;
128
128
+
home = cfg.repoDir;
129
129
+
};
130
130
+
131
131
+
systemd.services.nixbot = let
132
132
+
env = pkgs.python3.buildEnv.override {
133
133
+
extraLibs = [ pkgs.nixbot ];
134
134
+
};
135
135
+
in {
136
136
+
after = [ "network.target" ];
137
137
+
wantedBy = [ "multi-user.target" ];
138
138
+
script = ''
139
139
+
${env}/bin/pserve ${pkgs.writeText "production.ini" pyramidIni}
140
140
+
'';
141
141
+
142
142
+
serviceConfig = {
143
143
+
User = "nixbot";
144
144
+
Group = "nogroup";
145
145
+
PermissionsStartOnly = true;
146
146
+
};
147
147
+
};
148
148
+
};
149
149
+
}