fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , pkgs , lib , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . cachix-agent ; 8 9in { 10meta . maintainers = [ maintainers . rycee ]; 11 12options . services . cachix-agent = { 13enable = 14mkEnableOption "Cachix Deploy Agent: <https://docs.cachix.org/deploy/>" ; 15 16name = mkOption { 17type = types . str ; 18description = "The unique agent name." ; 19}; 20 21verbose = mkEnableOption "verbose output" ; 22 23profile = mkOption { 24type = types . str ; 25default = "home-manager" ; 26description = '' 27The Nix profile name. 28'' ; 29}; 30 31host = mkOption { 32type = types . nullOr types . str ; 33default = null ; 34description = "Cachix URI to use." ; 35}; 36 37package = mkPackageOption pkgs "cachix" { }; 38 39credentialsFile = mkOption { 40type = types . path ; 41default = " ${ config . xdg . configHome } /cachix-agent.token" ; 42defaultText = 43literalExpression ''"''${config.xdg.configHome}/cachix-agent.token"'' ; 44description = '' 45Required file that needs to contain 46`CACHIX_AGENT_TOKEN=...`. 47'' ; 48}; 49}; 50 51config = mkIf cfg . enable { 52assertions = [ 53( lib . hm . assertions . assertPlatform "services.cachix-agent" pkgs 54lib . platforms . linux ) 55]; 56 57systemd . user . services . cachix-agent = { 58Unit . Description = "Cachix Deploy Agent" ; 59 60Service = { 61Environment = [ 62"PATH= ${ 63if config . nix . enable && config . nix . package != null then 64config . nix . package 65else 66pkgs . nix 67} /bin" 68]; 69EnvironmentFile = cfg . credentialsFile ; 70 71# We don't want to kill children processes as those are deployments. 72KillMode = "process" ; 73Restart = "on-failure" ; 74ExecStart = escapeShellArgs ([ " ${ cfg . package } /bin/cachix" ] 75++ optional cfg . verbose "--verbose" 76++ optional ( cfg . host != null ) "--host ${ cfg . host } " 77++ [ "deploy" "agent" cfg . name ] 78++ optional ( cfg . profile != null ) cfg . profile ); 79}; 80 81Install . WantedBy = [ "default.target" ]; 82}; 83}; 84}