1 { config, lib, options, pkgs, ... }:
6 cfg = config.services.gocd-server;
7 opt = options.services.gocd-server;
10 services.gocd-server = {
11 enable = mkEnableOption "gocd-server";
14 default = "gocd-server";
17 User the Go.CD server should execute under.
22 default = "gocd-server";
25 If the default user "gocd-server" is configured then this is the primary group of that user.
29 extraGroups = mkOption {
31 type = types.listOf types.str;
32 example = [ "wheel" "docker" ];
34 List of extra groups that the "gocd-server" user should be a part of.
38 listenAddress = mkOption {
40 example = "localhost";
43 Specifies the bind address on which the Go.CD server HTTP interface listens.
51 Specifies port number on which the Go.CD server HTTP interface listens.
59 Specifies port number on which the Go.CD server HTTPS interface listens.
64 default = "/var/lib/go-server";
67 Specifies the working directory in which the Go.CD server java archive resides.
72 default = [ pkgs.stdenv pkgs.jre pkgs.git config.programs.ssh.package pkgs.nix ];
73 defaultText = literalExpression "[ pkgs.stdenv pkgs.jre pkgs.git config.programs.ssh.package pkgs.nix ]";
74 type = types.listOf types.package;
76 Packages to add to PATH for the Go.CD server's process.
80 initialJavaHeapSize = mkOption {
84 Specifies the initial java heap memory size for the Go.CD server's java process.
88 maxJavaHeapMemory = mkOption {
92 Specifies the java maximum heap memory size for the Go.CD server's java process.
96 startupOptions = mkOption {
97 type = types.listOf types.str;
99 "-Xms${cfg.initialJavaHeapSize}"
100 "-Xmx${cfg.maxJavaHeapMemory}"
101 "-Dcruise.listen.host=${cfg.listenAddress}"
103 "-Djruby.rack.request.size.threshold.bytes=30000000"
105 "-Dcruise.config.dir=${cfg.workDir}/conf"
106 "-Dcruise.config.file=${cfg.workDir}/conf/cruise-config.xml"
107 "-Dcruise.server.port=${toString cfg.port}"
108 "-Dcruise.server.ssl.port=${toString cfg.sslPort}"
109 "--add-opens=java.base/java.lang=ALL-UNNAMED"
110 "--add-opens=java.base/java.util=ALL-UNNAMED"
112 defaultText = literalExpression ''
114 "-Xms''${config.${opt.initialJavaHeapSize}}"
115 "-Xmx''${config.${opt.maxJavaHeapMemory}}"
116 "-Dcruise.listen.host=''${config.${opt.listenAddress}}"
118 "-Djruby.rack.request.size.threshold.bytes=30000000"
120 "-Dcruise.config.dir=''${config.${opt.workDir}}/conf"
121 "-Dcruise.config.file=''${config.${opt.workDir}}/conf/cruise-config.xml"
122 "-Dcruise.server.port=''${toString config.${opt.port}}"
123 "-Dcruise.server.ssl.port=''${toString config.${opt.sslPort}}"
124 "--add-opens=java.base/java.lang=ALL-UNNAMED"
125 "--add-opens=java.base/java.util=ALL-UNNAMED"
130 Specifies startup command line arguments to pass to Go.CD server
135 extraOptions = mkOption {
137 type = types.listOf types.str;
140 "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
142 "-Xloggc:go-server-gc.log"
143 "-XX:+PrintGCTimeStamps"
144 "-XX:+PrintTenuringDistribution"
145 "-XX:+PrintGCDetails"
149 Specifies additional command line arguments to pass to Go.CD server's
150 java process. Example contains debug and gcLog arguments.
154 environment = mkOption {
156 type = with types; attrsOf str;
158 Additional environment variables to be passed to the gocd-server process.
159 As a base environment, gocd-server receives NIX_PATH from
160 {option}`environment.sessionVariables`, NIX_REMOTE is set to
167 config = mkIf cfg.enable {
168 users.groups = optionalAttrs (cfg.group == "gocd-server") {
169 gocd-server.gid = config.ids.gids.gocd-server;
172 users.users = optionalAttrs (cfg.user == "gocd-server") {
174 description = "gocd-server user";
178 extraGroups = cfg.extraGroups;
179 useDefaultShell = true;
180 uid = config.ids.uids.gocd-server;
184 systemd.services.gocd-server = {
185 description = "GoCD Server";
186 after = [ "network.target" ];
187 wantedBy = [ "multi-user.target" ];
191 selectedSessionVars =
192 lib.filterAttrs (n: v: builtins.elem n [ "NIX_PATH" ])
193 config.environment.sessionVariables;
195 selectedSessionVars //
196 { NIX_REMOTE = "daemon";
203 ${pkgs.git}/bin/git config --global --add http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
204 ${pkgs.jre}/bin/java -server ${concatStringsSep " " cfg.startupOptions} \
205 ${concatStringsSep " " cfg.extraOptions} \
206 -jar ${pkgs.gocd-server}/go-server/lib/go.jar
212 WorkingDirectory = cfg.workDir;