fork/home-manager
git clone https://git.julia.blue/fork/home-manager
0f4e5b49
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . keychain ; 8 9flags = cfg . extraFlags ++ optional ( cfg . agents != [ ]) 10"--agents ${ concatStringsSep "," cfg . agents } " 11++ optional ( cfg . inheritType != null ) "--inherit ${ cfg . inheritType } " ; 12 13shellCommand = 14" ${ cfg . package } /bin/keychain --eval ${ concatStringsSep " " flags } ${ 15concatStringsSep " " cfg . keys 16} " ; 17 18in { 19meta . maintainers = [ ]; 20 21options . programs . keychain = { 22enable = mkEnableOption "keychain" ; 23 24package = mkOption { 25type = types . package ; 26default = pkgs . keychain ; 27defaultText = literalExpression "pkgs.keychain" ; 28description = '' 29Keychain package to install. 30'' ; 31}; 32 33keys = mkOption { 34type = types . listOf types . str ; 35default = [ "id_rsa" ]; 36description = '' 37Keys to add to keychain. 38'' ; 39}; 40 41agents = mkOption { 42type = types . listOf types . str ; 43default = [ ]; 44description = '' 45Agents to add. 46'' ; 47}; 48 49inheritType = mkOption { 50type = 51types . nullOr ( types . enum [ "local" "any" "local-once" "any-once" ]); 52default = null ; 53description = '' 54Inherit type to attempt from agent variables from the environment. 55'' ; 56}; 57 58extraFlags = mkOption { 59type = types . listOf types . str ; 60default = [ "--quiet" ]; 61description = '' 62Extra flags to pass to keychain. 63'' ; 64}; 65 66enableBashIntegration = mkOption { 67default = true ; 68type = types . bool ; 69description = '' 70Whether to enable Bash integration. 71'' ; 72}; 73 74enableFishIntegration = mkOption { 75default = true ; 76type = types . bool ; 77description = '' 78Whether to enable Fish integration. 79'' ; 80}; 81 82enableZshIntegration = mkOption { 83default = true ; 84type = types . bool ; 85description = '' 86Whether to enable Zsh integration. 87'' ; 88}; 89 90enableNushellIntegration = mkOption { 91default = true ; 92type = types . bool ; 93description = '' 94Whether to enable Nushell integration. 95'' ; 96}; 97 98enableXsessionIntegration = mkOption { 99default = true ; 100type = types . bool ; 101visible = pkgs . stdenv . hostPlatform . isLinux ; 102description = '' 103Whether to run keychain from your {file}`~/.xsession`. 104'' ; 105}; 106}; 107 108config = mkIf cfg . enable { 109home . packages = [ cfg . package ]; 110programs . bash . initExtra = mkIf cfg . enableBashIntegration '' 111eval "$(SHELL=bash ${ shellCommand } )" 112'' ; 113programs . fish . interactiveShellInit = mkIf cfg . enableFishIntegration '' 114SHELL=fish eval ( ${ shellCommand } ) 115'' ; 116programs . zsh . initExtra = mkIf cfg . enableZshIntegration '' 117eval "$(SHELL=zsh ${ shellCommand } )" 118'' ; 119programs . nushell . extraConfig = mkIf cfg . enableNushellIntegration '' 120let keychain_shell_command = (SHELL=bash ${ shellCommand } | parse -r '(\w+)=(.*); export \1' | transpose -ird) 121if not ($keychain_shell_command|is-empty) { 122$keychain_shell_command | load-env 123} 124'' ; 125xsession . initExtra = mkIf cfg . enableXsessionIntegration '' 126eval "$(SHELL=bash ${ shellCommand } )" 127'' ; 128}; 129}