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 javaPackage = mkPackageOption pkgs "jdk" { }; 51 }; 52 }; 53 54 config = mkIf (cfg.enable && !masterCfg.enable) { 55 users.groups = optionalAttrs (cfg.group == "jenkins") { 56 jenkins.gid = config.ids.gids.jenkins; 57 }; 58 59 users.users = optionalAttrs (cfg.user == "jenkins") { 60 jenkins = { 61 description = "jenkins user"; 62 createHome = true; 63 home = cfg.home; 64 group = cfg.group; 65 useDefaultShell = true; 66 uid = config.ids.uids.jenkins; 67 }; 68 }; 69 70 programs.java = { 71 enable = true; 72 package = cfg.javaPackage; 73 }; 74 }; 75}