mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-26 23:54:01 +00:00
6c5ab28fce
This was done by generating a truly hilarious configuration: rg 'services\.[^.]+\.enable\t' opts-tags | cut -f1 > allonconfig.nix The following were not tested due to other evaluation errors. They should probably be manually audited. services.amule services.castopod services.ceph services.chatgpt-retrieval-plugin services.clamsmtp services.clight services.dante services.dex services.discourse services.dwm-status services.engelsystem services.foundationdb services.frigate services.frp services.grocy services.guacamole-client services.hedgedoc services.home-assistant services.honk services.imaginary services.jitsi-meet services.kerberos_server services.limesurvey services.mastodon services.mediawiki services.mobilizon services.moodle services.mosquitto services.nextcloud services.nullmailer services.patroni services.pfix-srsd services.pgpkeyserver-lite services.postfixadmin services.roundcube services.schleuder services.self-deploy services.slskd services.spacecookie services.statsd services.step-ca services.sympa services.tsmBackup services.vdirsyncer services.vikunja services.yandex-disk services.zabbixWeb
77 lines
2.1 KiB
Nix
77 lines
2.1 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.cachix-agent;
|
|
in {
|
|
meta.maintainers = [ lib.maintainers.domenkozar ];
|
|
|
|
options.services.cachix-agent = {
|
|
enable = mkEnableOption (lib.mdDoc "Cachix Deploy Agent: https://docs.cachix.org/deploy/");
|
|
|
|
name = mkOption {
|
|
type = types.str;
|
|
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 = lib.mdDoc "Profile name, defaults to 'system' (NixOS).";
|
|
};
|
|
|
|
host = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = lib.mdDoc "Cachix uri to use.";
|
|
};
|
|
|
|
package = mkPackageOption pkgs "cachix" { };
|
|
|
|
credentialsFile = mkOption {
|
|
type = types.path;
|
|
default = "/etc/cachix-agent.token";
|
|
description = lib.mdDoc ''
|
|
Required file that needs to contain CACHIX_AGENT_TOKEN=...
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.cachix-agent = {
|
|
description = "Cachix Deploy Agent";
|
|
wants = [ "network-online.target" ];
|
|
after = ["network-online.target"];
|
|
path = [ config.nix.package ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
# 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 = "always";
|
|
RestartSec = 5;
|
|
EnvironmentFile = cfg.credentialsFile;
|
|
ExecStart = ''
|
|
${cfg.package}/bin/cachix ${lib.optionalString cfg.verbose "--verbose"} ${lib.optionalString (cfg.host != null) "--host ${cfg.host}"} \
|
|
deploy agent ${cfg.name} ${optionalString (cfg.profile != null) cfg.profile}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|