mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/services.gocd-agent: remove with lib;
This commit is contained in:
parent
d575253885
commit
67553951b1
1 changed files with 33 additions and 36 deletions
|
@ -1,34 +1,31 @@
|
|||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.gocd-agent;
|
||||
opt = options.services.gocd-agent;
|
||||
in {
|
||||
options = {
|
||||
services.gocd-agent = {
|
||||
enable = mkEnableOption "gocd-agent";
|
||||
enable = lib.mkEnableOption "gocd-agent";
|
||||
|
||||
user = mkOption {
|
||||
user = lib.mkOption {
|
||||
default = "gocd-agent";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
User the Go.CD agent should execute under.
|
||||
'';
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
group = lib.mkOption {
|
||||
default = "gocd-agent";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
If the default user "gocd-agent" is configured then this is the primary
|
||||
group of that user.
|
||||
'';
|
||||
};
|
||||
|
||||
extraGroups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
extraGroups = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "wheel" "docker" ];
|
||||
description = ''
|
||||
|
@ -36,18 +33,18 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
packages = lib.mkOption {
|
||||
default = [ pkgs.stdenv pkgs.jre pkgs.git config.programs.ssh.package pkgs.nix ];
|
||||
defaultText = literalExpression "[ pkgs.stdenv pkgs.jre pkgs.git config.programs.ssh.package pkgs.nix ]";
|
||||
type = types.listOf types.package;
|
||||
defaultText = lib.literalExpression "[ pkgs.stdenv pkgs.jre pkgs.git config.programs.ssh.package pkgs.nix ]";
|
||||
type = lib.types.listOf lib.types.package;
|
||||
description = ''
|
||||
Packages to add to PATH for the Go.CD agent process.
|
||||
'';
|
||||
};
|
||||
|
||||
agentConfig = mkOption {
|
||||
agentConfig = lib.mkOption {
|
||||
default = "";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
example = ''
|
||||
agent.auto.register.resources=ant,java
|
||||
agent.auto.register.environments=QA,Performance
|
||||
|
@ -58,40 +55,40 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
goServer = mkOption {
|
||||
goServer = lib.mkOption {
|
||||
default = "https://127.0.0.1:8154/go";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
URL of the GoCD Server to attach the Go.CD Agent to.
|
||||
'';
|
||||
};
|
||||
|
||||
workDir = mkOption {
|
||||
workDir = lib.mkOption {
|
||||
default = "/var/lib/go-agent";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Specifies the working directory in which the Go.CD agent java archive resides.
|
||||
'';
|
||||
};
|
||||
|
||||
initialJavaHeapSize = mkOption {
|
||||
initialJavaHeapSize = lib.mkOption {
|
||||
default = "128m";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Specifies the initial java heap memory size for the Go.CD agent java process.
|
||||
'';
|
||||
};
|
||||
|
||||
maxJavaHeapMemory = mkOption {
|
||||
maxJavaHeapMemory = lib.mkOption {
|
||||
default = "256m";
|
||||
type = types.str;
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Specifies the java maximum heap memory size for the Go.CD agent java process.
|
||||
'';
|
||||
};
|
||||
|
||||
startupOptions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
startupOptions = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [
|
||||
"-Xms${cfg.initialJavaHeapSize}"
|
||||
"-Xmx${cfg.maxJavaHeapMemory}"
|
||||
|
@ -99,7 +96,7 @@ in {
|
|||
"-Dcruise.console.publish.interval=10"
|
||||
"-Djava.security.egd=file:/dev/./urandom"
|
||||
];
|
||||
defaultText = literalExpression ''
|
||||
defaultText = lib.literalExpression ''
|
||||
[
|
||||
"-Xms''${config.${opt.initialJavaHeapSize}}"
|
||||
"-Xmx''${config.${opt.maxJavaHeapMemory}}"
|
||||
|
@ -114,9 +111,9 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
extraOptions = lib.mkOption {
|
||||
default = [ ];
|
||||
type = types.listOf types.str;
|
||||
type = lib.types.listOf lib.types.str;
|
||||
example = [
|
||||
"-X debug"
|
||||
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"
|
||||
|
@ -133,9 +130,9 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
environment = mkOption {
|
||||
environment = lib.mkOption {
|
||||
default = { };
|
||||
type = with types; attrsOf str;
|
||||
type = with lib.types; attrsOf str;
|
||||
description = ''
|
||||
Additional environment variables to be passed to the Go.CD agent process.
|
||||
As a base environment, Go.CD agent receives NIX_PATH from
|
||||
|
@ -146,12 +143,12 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.groups = optionalAttrs (cfg.group == "gocd-agent") {
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups = lib.optionalAttrs (cfg.group == "gocd-agent") {
|
||||
gocd-agent.gid = config.ids.gids.gocd-agent;
|
||||
};
|
||||
|
||||
users.users = optionalAttrs (cfg.user == "gocd-agent") {
|
||||
users.users = lib.optionalAttrs (cfg.user == "gocd-agent") {
|
||||
gocd-agent = {
|
||||
description = "gocd-agent user";
|
||||
createHome = true;
|
||||
|
@ -178,7 +175,7 @@ in {
|
|||
{
|
||||
NIX_REMOTE = "daemon";
|
||||
AGENT_WORK_DIR = cfg.workDir;
|
||||
AGENT_STARTUP_ARGS = ''${concatStringsSep " " cfg.startupOptions}'';
|
||||
AGENT_STARTUP_ARGS = ''${lib.concatStringsSep " " cfg.startupOptions}'';
|
||||
LOG_DIR = cfg.workDir;
|
||||
LOG_FILE = "${cfg.workDir}/go-agent-start.log";
|
||||
} //
|
||||
|
@ -201,8 +198,8 @@ in {
|
|||
ln -s "${pkgs.writeText "autoregister.properties" cfg.agentConfig}" config/autoregister.properties
|
||||
|
||||
${pkgs.git}/bin/git config --global --add http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
|
||||
${pkgs.jre}/bin/java ${concatStringsSep " " cfg.startupOptions} \
|
||||
${concatStringsSep " " cfg.extraOptions} \
|
||||
${pkgs.jre}/bin/java ${lib.concatStringsSep " " cfg.startupOptions} \
|
||||
${lib.concatStringsSep " " cfg.extraOptions} \
|
||||
-jar ${pkgs.gocd-agent}/go-agent/agent-bootstrapper.jar \
|
||||
-serverUrl ${cfg.goServer}
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue