mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 15:09:46 +01:00
36a53d9f26
This process was automated by [my fork of `nix-doc-munge`]. All conversions were automatically checked to produce the same DocBook result when converted back, modulo minor typographical/formatting differences on the acceptable-to-desirable spectrum. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ {} + $ ./format [my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
84 lines
2.1 KiB
Nix
84 lines
2.1 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.cachix-agent;
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
options.services.cachix-agent = {
|
|
enable = mkEnableOption
|
|
(lib.mdDoc "Cachix Deploy Agent: <https://docs.cachix.org/deploy/>");
|
|
|
|
name = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc "The unique agent name.";
|
|
};
|
|
|
|
verbose = mkEnableOption (lib.mdDoc "verbose output");
|
|
|
|
profile = mkOption {
|
|
type = types.str;
|
|
default = "home-manager";
|
|
description = lib.mdDoc ''
|
|
The Nix profile name.
|
|
'';
|
|
};
|
|
|
|
host = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = lib.mdDoc "Cachix URI to use.";
|
|
};
|
|
|
|
package = mkPackageOptionMD pkgs "cachix" { };
|
|
|
|
credentialsFile = mkOption {
|
|
type = types.path;
|
|
default = "${config.xdg.configHome}/cachix-agent.token";
|
|
defaultText =
|
|
literalExpression ''"''${config.xdg.configHome}/cachix-agent.token"'';
|
|
description = lib.mdDoc ''
|
|
Required file that needs to contain
|
|
`CACHIX_AGENT_TOKEN=...`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.cachix-agent" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
systemd.user.services.cachix-agent = {
|
|
Unit.Description = "Cachix Deploy Agent";
|
|
|
|
Service = {
|
|
Environment = [
|
|
"PATH=${
|
|
if config.nix.enable && config.nix.package != null then
|
|
config.nix.package
|
|
else
|
|
pkgs.nix
|
|
}/bin"
|
|
];
|
|
EnvironmentFile = cfg.credentialsFile;
|
|
|
|
# We don't want to kill children processes as those are deployments.
|
|
KillMode = "process";
|
|
Restart = "on-failure";
|
|
ExecStart = escapeShellArgs ([ "${cfg.package}/bin/cachix" ]
|
|
++ optional cfg.verbose "--verbose"
|
|
++ optional (cfg.host != null) "--host ${cfg.host}"
|
|
++ [ "deploy" "agent" cfg.name ]
|
|
++ optional (cfg.profile != null) cfg.profile);
|
|
};
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
};
|
|
};
|
|
}
|