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
127 lines
3.1 KiB
Nix
127 lines
3.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.keychain;
|
|
|
|
flags = cfg.extraFlags ++ optional (cfg.agents != [ ])
|
|
"--agents ${concatStringsSep "," cfg.agents}"
|
|
++ optional (cfg.inheritType != null) "--inherit ${cfg.inheritType}";
|
|
|
|
shellCommand =
|
|
"${cfg.package}/bin/keychain --eval ${concatStringsSep " " flags} ${
|
|
concatStringsSep " " cfg.keys
|
|
}";
|
|
|
|
in {
|
|
meta.maintainers = [ ];
|
|
|
|
options.programs.keychain = {
|
|
enable = mkEnableOption (lib.mdDoc "keychain");
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.keychain;
|
|
defaultText = literalExpression "pkgs.keychain";
|
|
description = lib.mdDoc ''
|
|
Keychain package to install.
|
|
'';
|
|
};
|
|
|
|
keys = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ "id_rsa" ];
|
|
description = lib.mdDoc ''
|
|
Keys to add to keychain.
|
|
'';
|
|
};
|
|
|
|
agents = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
description = lib.mdDoc ''
|
|
Agents to add.
|
|
'';
|
|
};
|
|
|
|
inheritType = mkOption {
|
|
type =
|
|
types.nullOr (types.enum [ "local" "any" "local-once" "any-once" ]);
|
|
default = null;
|
|
description = lib.mdDoc ''
|
|
Inherit type to attempt from agent variables from the environment.
|
|
'';
|
|
};
|
|
|
|
extraFlags = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ "--quiet" ];
|
|
description = lib.mdDoc ''
|
|
Extra flags to pass to keychain.
|
|
'';
|
|
};
|
|
|
|
enableBashIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Whether to enable Bash integration.
|
|
'';
|
|
};
|
|
|
|
enableFishIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Whether to enable Fish integration.
|
|
'';
|
|
};
|
|
|
|
enableZshIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Whether to enable Zsh integration.
|
|
'';
|
|
};
|
|
|
|
enableNushellIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Whether to enable Nushell integration.
|
|
'';
|
|
};
|
|
|
|
enableXsessionIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
visible = pkgs.stdenv.hostPlatform.isLinux;
|
|
description = lib.mdDoc ''
|
|
Whether to run keychain from your {file}`~/.xsession`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ cfg.package ];
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
eval "$(SHELL=bash ${shellCommand})"
|
|
'';
|
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
|
SHELL=fish eval (${shellCommand})
|
|
'';
|
|
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
|
eval "$(SHELL=zsh ${shellCommand})"
|
|
'';
|
|
programs.nushell.extraConfig = mkIf cfg.enableNushellIntegration ''
|
|
${shellCommand} | parse -r '(\w+)=(.*); export \1' | transpose -ird | load-env
|
|
'';
|
|
xsession.initExtra = mkIf cfg.enableXsessionIntegration ''
|
|
eval "$(SHELL=bash ${shellCommand})"
|
|
'';
|
|
};
|
|
}
|