nixos/services.cachix-agent: remove with lib;

This commit is contained in:
Felix Buehler 2024-12-29 21:50:39 +01:00
parent fb31348d4d
commit 81f97e6d28

View file

@ -4,9 +4,6 @@
lib, lib,
... ...
}: }:
with lib;
let let
cfg = config.services.cachix-agent; cfg = config.services.cachix-agent;
in in
@ -14,37 +11,37 @@ in
meta.maintainers = [ lib.maintainers.domenkozar ]; meta.maintainers = [ lib.maintainers.domenkozar ];
options.services.cachix-agent = { options.services.cachix-agent = {
enable = mkEnableOption "Cachix Deploy Agent: https://docs.cachix.org/deploy/"; enable = lib.mkEnableOption "Cachix Deploy Agent: https://docs.cachix.org/deploy/";
name = mkOption { name = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Agent name, usually same as the hostname"; description = "Agent name, usually same as the hostname";
default = config.networking.hostName; default = config.networking.hostName;
defaultText = "config.networking.hostName"; defaultText = "config.networking.hostName";
}; };
verbose = mkOption { verbose = lib.mkOption {
type = types.bool; type = lib.types.bool;
description = "Enable verbose output"; description = "Enable verbose output";
default = false; default = false;
}; };
profile = mkOption { profile = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "Profile name, defaults to 'system' (NixOS)."; description = "Profile name, defaults to 'system' (NixOS).";
}; };
host = mkOption { host = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "Cachix uri to use."; description = "Cachix uri to use.";
}; };
package = mkPackageOption pkgs "cachix" { }; package = lib.mkPackageOption pkgs "cachix" { };
credentialsFile = mkOption { credentialsFile = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/etc/cachix-agent.token"; default = "/etc/cachix-agent.token";
description = '' description = ''
Required file that needs to contain CACHIX_AGENT_TOKEN=... Required file that needs to contain CACHIX_AGENT_TOKEN=...
@ -52,7 +49,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.services.cachix-agent = { systemd.services.cachix-agent = {
description = "Cachix Deploy Agent"; description = "Cachix Deploy Agent";
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
@ -76,7 +73,7 @@ in
${cfg.package}/bin/cachix ${lib.optionalString cfg.verbose "--verbose"} ${ ${cfg.package}/bin/cachix ${lib.optionalString cfg.verbose "--verbose"} ${
lib.optionalString (cfg.host != null) "--host ${cfg.host}" lib.optionalString (cfg.host != null) "--host ${cfg.host}"
} \ } \
deploy agent ${cfg.name} ${optionalString (cfg.profile != null) cfg.profile} deploy agent ${cfg.name} ${lib.optionalString (cfg.profile != null) cfg.profile}
''; '';
}; };
}; };