diff options
Diffstat (limited to 'nixpkgs/nixos/modules/services/system/cachix-agent/default.nix')
-rw-r--r-- | nixpkgs/nixos/modules/services/system/cachix-agent/default.nix | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/nixpkgs/nixos/modules/services/system/cachix-agent/default.nix b/nixpkgs/nixos/modules/services/system/cachix-agent/default.nix index 496e0b90355b..b730118d46d8 100644 --- a/nixpkgs/nixos/modules/services/system/cachix-agent/default.nix +++ b/nixpkgs/nixos/modules/services/system/cachix-agent/default.nix @@ -12,28 +12,34 @@ in { name = mkOption { type = types.str; - description = "Agent name, usually same as the hostname"; + description = lib.mdDoc "Agent name, usually same as the hostname"; default = config.networking.hostName; defaultText = "config.networking.hostName"; }; + verbose = mkOption { + type = types.bool; + description = lib.mdDoc "Enable verbose output"; + default = false; + }; + profile = mkOption { type = types.nullOr types.str; default = null; - description = "Profile name, defaults to 'system' (NixOS)."; + description = lib.mdDoc "Profile name, defaults to 'system' (NixOS)."; }; package = mkOption { type = types.package; default = pkgs.cachix; defaultText = literalExpression "pkgs.cachix"; - description = "Cachix Client package to use."; + description = lib.mdDoc "Cachix Client package to use."; }; credentialsFile = mkOption { type = types.path; default = "/etc/cachix-agent.token"; - description = '' + description = lib.mdDoc '' Required file that needs to contain CACHIX_AGENT_TOKEN=... ''; }; @@ -45,12 +51,19 @@ in { after = ["network-online.target"]; path = [ config.nix.package ]; wantedBy = [ "multi-user.target" ]; - # don't restart while changing - reloadIfChanged = true; + + # Cachix requires $USER to be set + environment.USER = "root"; + + # don't stop the service if the unit disappears + unitConfig.X-StopOnRemoval = false; + serviceConfig = { + # we don't want to kill children processes as those are deployments + KillMode = "process"; Restart = "on-failure"; EnvironmentFile = cfg.credentialsFile; - ExecStart = "${cfg.package}/bin/cachix deploy agent ${cfg.name} ${if cfg.profile != null then profile else ""}"; + ExecStart = "${cfg.package}/bin/cachix ${lib.optionalString cfg.verbose "--verbose"} deploy agent ${cfg.name} ${if cfg.profile != null then profile else ""}"; }; }; }; |