1{ config, lib, pkgs, ... }:
2with lib;
3let
4 cfg = config.services.jenkinsSlave;
5 masterCfg = config.services.jenkins;
6in {
7 options = {
8 services.jenkinsSlave = {
9 # todo:
10 # * assure the profile of the jenkins user has a JRE and any specified packages. This would
11 # enable ssh slaves.
12 # * Optionally configure the node as a jenkins ad-hoc slave. This would imply configuration
13 # properties for the master node.
14 enable = mkOption {
15 type = types.bool;
16 default = false;
17 description = ''
18 If true the system will be configured to work as a jenkins slave.
19 If the system is also configured to work as a jenkins master then this has no effect.
20 In progress: Currently only assures the jenkins user is configured.
21 '';
22 };
23
24 user = mkOption {
25 default = "jenkins";
26 type = types.str;
27 description = ''
28 User the jenkins slave agent should execute under.
29 '';
30 };
31
32 group = mkOption {
33 default = "jenkins";
34 type = types.str;
35 description = ''
36 If the default slave agent user "jenkins" is configured then this is
37 the primary group of that user.
38 '';
39 };
40
41 home = mkOption {
42 default = "/var/lib/jenkins";
43 type = types.path;
44 description = ''
45 The path to use as JENKINS_HOME. If the default user "jenkins" is configured then
46 this is the home of the "jenkins" user.
47 '';
48 };
49 };
50 };
51
52 config = mkIf (cfg.enable && !masterCfg.enable) {
53 users.extraGroups = optional (cfg.group == "jenkins") {
54 name = "jenkins";
55 gid = config.ids.gids.jenkins;
56 };
57
58 users.extraUsers = optional (cfg.user == "jenkins") {
59 name = "jenkins";
60 description = "jenkins user";
61 createHome = true;
62 home = cfg.home;
63 group = cfg.group;
64 useDefaultShell = true;
65 uid = config.ids.uids.jenkins;
66 };
67 };
68}