git.iko.soy/typeable/nixpkgs
on master help sign in
jenkins service: add declarative plugin support
commit41ea71a3475174daba0708dae2b365c2dd6f5d30 authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> dateSat 20 May 2017, 22:44 (10 years ago) parent8c0b08d
1 file changed+34−3
nixos/modules/services/continuous-integration/jenkins/default.nix+34−3
nixos/modules/services/continuous-integration/jenkins/default.nix+34−3
@@ -101,6 +101,22 @@ in {
101101 '';
102102 };
103103
104+ plugins = mkOption {
105+ default = null;
106+ #type = types.nullOr (types.attrsOf types.package);
107+ description = ''
108+ A set of plugins to activate. Note that this will completely
109+ remove and replace any previously installed plugins. If you
110+ have manually-installed plugins that you want to keep while
111+ using this module, set this option to
112+ <literal>null</literal>. You can generate this set with a
113+ tool such as <literal>jenkinsPlugins2nix</literal>.
114+ '';
115+ example = literalExample ''
116+ import path/to/jenkinsPlugins2nix-generated-plugins.nix { inherit (pkgs) fetchurl stdenv; }
117+ '';
118+ };
119+
104120 extraOptions = mkOption {
105121 type = types.listOf types.str;
106122 default = [ ];
@@ -149,9 +165,24 @@ in {
149165 path = cfg.packages;
150166
151167 # Force .war (re)extraction, or else we might run stale Jenkins.
152− preStart = ''
153− rm -rf ${cfg.home}/war
154− '';
168+
169+ preStart =
170+ let replacePlugins =
171+ if isNull cfg.plugins
172+ then ""
173+ else
174+ let pluginCmds = lib.attrsets.mapAttrsToList
175+ (n: v: "cp ${v} ${cfg.home}/plugins/${n}.hpi")
176+ cfg.plugins;
177+ in ''
178+ rm -r ${cfg.home}/plugins
179+ mkdir -p ${cfg.home}/plugins
180+ ${lib.strings.concatStringsSep "\n" pluginCmds}
181+ '';
182+ in ''
183+ rm -rf ${cfg.home}/war
184+ ${replacePlugins}
185+ '';
155186
156187 script = ''
157188 ${pkgs.jdk}/bin/java -jar ${pkgs.jenkins}/webapps/jenkins.war --httpListenAddress=${cfg.listenAddress} \