ssh_auth_sock: init module
`$SSH_AUTH_SOCK` must not be set unconditionally through 'home.sessionVariables' since its value needs to be preserved if it stems from a forwarded SSH agent. Hence, this commit establishes a centralized, internal 'ssh_auth_sock.initialization' option for setting `$SSH_AUTH_SOCK`. It checks whether its value has to be preserved and injects the initialization code into the proper 'programs.(bash|fish|nushell|zsh).*' options.
This commit is contained in:
committed by
Austin Horstman
parent
03bdcf84f0
commit
a61b22e323
@@ -0,0 +1,75 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.ssh_auth_sock;
|
||||
|
||||
mkShellInitOption =
|
||||
shell:
|
||||
lib.mkOption {
|
||||
description = "Code that initializes {env}`SSH_AUTH_SOCK` in ${shell}.";
|
||||
type = lib.types.str;
|
||||
};
|
||||
|
||||
initSubmodule =
|
||||
{ config, ... }:
|
||||
{
|
||||
options.bash = mkShellInitOption "bash";
|
||||
options.fish = mkShellInitOption "fish";
|
||||
options.nushell = mkShellInitOption "nushell";
|
||||
};
|
||||
|
||||
# Preserve $SSH_AUTH_SOCK only if it stems from a forwarded agent which
|
||||
# is the case if both $SSH_AUTH_SOCK and $SSH_CONNECTION are set.
|
||||
bashIntegration = ''
|
||||
if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then
|
||||
${cfg.initialization.bash}
|
||||
fi
|
||||
'';
|
||||
fishIntegration = ''
|
||||
if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"
|
||||
${cfg.initialization.fish}
|
||||
end
|
||||
'';
|
||||
nushellIntegration =
|
||||
let
|
||||
unsetOrEmpty = var: ''("${var}" not-in $env) or ($env.${var} | is-empty)'';
|
||||
in
|
||||
''
|
||||
if ${unsetOrEmpty "SSH_AUTH_SOCK"} or ${unsetOrEmpty "SSH_CONNECTION"} {
|
||||
${cfg.initialization.nushell}
|
||||
}
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.bmrips ];
|
||||
|
||||
options.ssh_auth_sock.initialization = lib.mkOption {
|
||||
description = ''
|
||||
Shell-specific code to initialize {env}`SSH_AUTH_SOCK`.
|
||||
|
||||
RATIONALE: {env}`SSH_AUTH_SOCK` must not be set unconditionally through
|
||||
{option}`home.sessionVariables` since its value needs to be preserved if
|
||||
it stems from a forwarded agent. Hence, this option establishes a
|
||||
centralized interface for setting {env}`SSH_AUTH_SOCK`. It checks whether
|
||||
its value has to be preserved and injects the initialization code into the
|
||||
proper {option}`programs.(bash|fish|nushell|zsh).*` options.
|
||||
'';
|
||||
example = {
|
||||
bash = "export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock";
|
||||
fish = "set -x SSH_AUTH_SOCK $HOME/.ssh/agent.sock";
|
||||
nushell = "$env.SSH_AUTH_SOCK = $HOME/.ssh/agent.sock";
|
||||
};
|
||||
default = null;
|
||||
internal = true;
|
||||
type = with lib.types; nullOr (submodule initSubmodule);
|
||||
};
|
||||
|
||||
config = lib.mkIf (cfg.initialization != null) {
|
||||
# $SSH_AUTH_SOCK has to be set early since other tools rely on it
|
||||
programs.bash.profileExtra = lib.mkOrder 900 bashIntegration;
|
||||
programs.fish.shellInit = lib.mkOrder 900 fishIntegration;
|
||||
programs.nushell.extraConfig = lib.mkOrder 900 nushellIntegration;
|
||||
programs.zsh.envExtra = lib.mkOrder 900 bashIntegration;
|
||||
};
|
||||
}
|
||||
@@ -48,6 +48,7 @@ let
|
||||
./misc/qt/kvantum.nix
|
||||
./misc/shell.nix
|
||||
./misc/specialisation.nix
|
||||
./misc/ssh_auth_sock.nix
|
||||
./misc/submodule-support.nix
|
||||
./misc/tmpfiles.nix
|
||||
./misc/uninstall.nix
|
||||
|
||||
@@ -48,7 +48,6 @@ let
|
||||
''
|
||||
+ optionalString cfg.enableSshSupport ''
|
||||
${gpgSshSupportStr} | ignore
|
||||
$env.SSH_AUTH_SOCK = ($env.SSH_AUTH_SOCK? | default (${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket))
|
||||
'';
|
||||
|
||||
# mimic `gpgconf` output for use in the service definitions.
|
||||
@@ -367,12 +366,31 @@ in
|
||||
++ [ cfg.extraConfig ]
|
||||
);
|
||||
|
||||
home.sessionVariablesExtra = optionalString cfg.enableSshSupport ''
|
||||
unset SSH_AGENT_PID
|
||||
if [ -z "$SSH_CONNECTION" -o -z "$SSH_AUTH_SOCK" ] && [ "''${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
|
||||
export SSH_AUTH_SOCK="$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"
|
||||
fi
|
||||
'';
|
||||
ssh_auth_sock.initialization = lib.mkIf cfg.enableSshSupport {
|
||||
bash = ''
|
||||
unset SSH_AGENT_PID
|
||||
if [ "''${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
|
||||
export SSH_AUTH_SOCK="$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"
|
||||
fi
|
||||
'';
|
||||
fish = ''
|
||||
set -e SSH_AGENT_PID
|
||||
|
||||
begin
|
||||
set -l gnupg_val 0
|
||||
if set -q gnupg_SSH_AUTH_SOCK_by
|
||||
set gnupg_val $gnupg_SSH_AUTH_SOCK_by
|
||||
end
|
||||
|
||||
if test $gnupg_val -ne %self
|
||||
set -x SSH_AUTH_SOCK (${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)
|
||||
end
|
||||
end
|
||||
'';
|
||||
nushell = ''
|
||||
$env.SSH_AUTH_SOCK = $"(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"
|
||||
'';
|
||||
};
|
||||
|
||||
programs = {
|
||||
bash.initExtra = mkIf cfg.enableBashIntegration gpgBashInitStr;
|
||||
|
||||
@@ -10,6 +10,16 @@ in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.delafthi ];
|
||||
|
||||
imports =
|
||||
map
|
||||
(shell: lib.mkRemovedOptionModule [ "services" "proton-pass-agent" "enable${shell}Integration" ] "")
|
||||
[
|
||||
"Bash"
|
||||
"Zsh"
|
||||
"Fish"
|
||||
"Nushell"
|
||||
];
|
||||
|
||||
options.services.proton-pass-agent = {
|
||||
enable = lib.mkEnableOption "Proton Pass as a SSH agent";
|
||||
|
||||
@@ -43,14 +53,6 @@ in
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
|
||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
||||
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
|
||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||
|
||||
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||
};
|
||||
|
||||
config =
|
||||
@@ -72,42 +74,16 @@ in
|
||||
lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs =
|
||||
let
|
||||
# Preserve $SSH_AUTH_SOCK only if it stems from a forwarded agent which
|
||||
# is the case if both $SSH_AUTH_SOCK and $SSH_CONNECTION are set.
|
||||
bashIntegration = ''
|
||||
if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then
|
||||
export SSH_AUTH_SOCK=${socketPath}
|
||||
fi
|
||||
'';
|
||||
fishIntegration = ''
|
||||
if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"
|
||||
set -x SSH_AUTH_SOCK ${socketPath}
|
||||
end
|
||||
'';
|
||||
nushellIntegration =
|
||||
let
|
||||
unsetOrEmpty = var: ''("${var}" not-in $env) or ($env.${var} | is-empty)'';
|
||||
socketPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
''$"(${lib.getExe pkgs.getconf} DARWIN_USER_TEMP_DIR)/${cfg.socket}"''
|
||||
else
|
||||
''$"($env.XDG_RUNTIME_DIR)/${cfg.socket}"'';
|
||||
in
|
||||
''
|
||||
if ${unsetOrEmpty "SSH_AUTH_SOCK"} or ${unsetOrEmpty "SSH_CONNECTION"} {
|
||||
$env.SSH_AUTH_SOCK = ${socketPath}
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
# $SSH_AUTH_SOCK has to be set early since other tools rely on it
|
||||
bash.profileExtra = lib.mkIf cfg.enableBashIntegration (lib.mkOrder 900 bashIntegration);
|
||||
fish.shellInit = lib.mkIf cfg.enableFishIntegration (lib.mkOrder 900 fishIntegration);
|
||||
nushell.extraConfig = lib.mkIf cfg.enableNushellIntegration (lib.mkOrder 900 nushellIntegration);
|
||||
zsh.envExtra = lib.mkIf cfg.enableZshIntegration (lib.mkOrder 900 bashIntegration);
|
||||
};
|
||||
ssh_auth_sock.initialization = {
|
||||
bash = ''export SSH_AUTH_SOCK="${socketPath}"'';
|
||||
fish = ''set -x SSH_AUTH_SOCK "${socketPath}"'';
|
||||
nushell = "$env.SSH_AUTH_SOCK = ${
|
||||
if pkgs.stdenv.isDarwin then
|
||||
''$"(${lib.getExe pkgs.getconf} DARWIN_USER_TEMP_DIR)/${cfg.socket}"''
|
||||
else
|
||||
''$"($env.XDG_RUNTIME_DIR)/${cfg.socket}"''
|
||||
}";
|
||||
};
|
||||
|
||||
systemd.user.services.proton-pass-agent = {
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
|
||||
@@ -13,6 +13,15 @@ in
|
||||
lib.hm.maintainers.lheckemann
|
||||
];
|
||||
|
||||
imports =
|
||||
map (shell: lib.mkRemovedOptionModule [ "services" "ssh-agent" "enable${shell}Integration" ] "")
|
||||
[
|
||||
"Bash"
|
||||
"Zsh"
|
||||
"Fish"
|
||||
"Nushell"
|
||||
];
|
||||
|
||||
options.services.ssh-agent = {
|
||||
enable = lib.mkEnableOption "OpenSSH private key agent";
|
||||
|
||||
@@ -47,59 +56,27 @@ in
|
||||
See {manpage}`ssh-agent(1)`.
|
||||
'';
|
||||
};
|
||||
|
||||
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
|
||||
|
||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||
|
||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||
|
||||
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
programs =
|
||||
ssh_auth_sock.initialization =
|
||||
let
|
||||
socketPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"$(${lib.getExe pkgs.getconf} DARWIN_USER_TEMP_DIR)/${cfg.socket}"
|
||||
else
|
||||
"$XDG_RUNTIME_DIR/${cfg.socket}";
|
||||
|
||||
# Preserve $SSH_AUTH_SOCK only if it stems from a forwarded agent which
|
||||
# is the case if both $SSH_AUTH_SOCK and $SSH_CONNECTION are set.
|
||||
bashIntegration = ''
|
||||
if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then
|
||||
export SSH_AUTH_SOCK=${socketPath}
|
||||
fi
|
||||
'';
|
||||
fishIntegration = ''
|
||||
if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"
|
||||
set -x SSH_AUTH_SOCK ${socketPath}
|
||||
end
|
||||
'';
|
||||
nushellIntegration =
|
||||
let
|
||||
unsetOrEmpty = var: ''("${var}" not-in $env) or ($env.${var} | is-empty)'';
|
||||
socketPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
''$"(${lib.getExe pkgs.getconf} DARWIN_USER_TEMP_DIR)/${cfg.socket}"''
|
||||
else
|
||||
''$"($env.XDG_RUNTIME_DIR)/${cfg.socket}"'';
|
||||
in
|
||||
''
|
||||
if ${unsetOrEmpty "SSH_AUTH_SOCK"} or ${unsetOrEmpty "SSH_CONNECTION"} {
|
||||
$env.SSH_AUTH_SOCK = ${socketPath}
|
||||
}
|
||||
'';
|
||||
in
|
||||
{
|
||||
# $SSH_AUTH_SOCK has to be set early since other tools rely on it
|
||||
bash.profileExtra = lib.mkIf cfg.enableBashIntegration (lib.mkOrder 900 bashIntegration);
|
||||
fish.shellInit = lib.mkIf cfg.enableFishIntegration (lib.mkOrder 900 fishIntegration);
|
||||
nushell.extraConfig = lib.mkIf cfg.enableNushellIntegration (lib.mkOrder 900 nushellIntegration);
|
||||
zsh.envExtra = lib.mkIf cfg.enableZshIntegration (lib.mkOrder 900 bashIntegration);
|
||||
bash = ''export SSH_AUTH_SOCK="${socketPath}"'';
|
||||
fish = ''set -x SSH_AUTH_SOCK "${socketPath}"'';
|
||||
nushell = "$env.SSH_AUTH_SOCK = ${
|
||||
if pkgs.stdenv.isDarwin then
|
||||
''$"(${lib.getExe pkgs.getconf} DARWIN_USER_TEMP_DIR)/${cfg.socket}"''
|
||||
else
|
||||
''$"($env.XDG_RUNTIME_DIR)/${cfg.socket}"''
|
||||
}";
|
||||
};
|
||||
|
||||
systemd.user.services.ssh-agent = {
|
||||
|
||||
@@ -59,11 +59,14 @@ in
|
||||
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.sessionVariables = {
|
||||
# Override ssh-agent's $SSH_AUTH_SOCK definition since ssh-tpm-agent is a
|
||||
# proxy to it.
|
||||
SSH_AUTH_SOCK = lib.mkOverride 90 "$XDG_RUNTIME_DIR/ssh-tpm-agent.sock";
|
||||
SSH_TPM_AUTH_SOCK = "$XDG_RUNTIME_DIR/ssh-tpm-agent.sock";
|
||||
home.sessionVariables.SSH_TPM_AUTH_SOCK = "$XDG_RUNTIME_DIR/ssh-tpm-agent.sock";
|
||||
|
||||
# Override ssh-agent's $SSH_AUTH_SOCK definition since ssh-tpm-agent is a
|
||||
# proxy to it.
|
||||
ssh_auth_sock.initialization = lib.mkOverride 90 {
|
||||
bash = ''export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'';
|
||||
fish = ''set -x SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'';
|
||||
nushell = ''$env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-tpm-agent.sock"'';
|
||||
};
|
||||
|
||||
systemd.user = {
|
||||
|
||||
@@ -22,11 +22,24 @@ in
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.sessionVariables.SSH_AUTH_SOCK =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"/tmp/yubikey-agent.sock"
|
||||
else
|
||||
"\${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock";
|
||||
ssh_auth_sock.initialization =
|
||||
let
|
||||
socketPath =
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"/tmp/yubikey-agent.sock"
|
||||
else
|
||||
"\${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock";
|
||||
in
|
||||
{
|
||||
bash = ''export SSH_AUTH_SOCK="${socketPath}"'';
|
||||
fish = ''set -x SSH_AUTH_SOCK "${socketPath}"'';
|
||||
nushell = "$env.SSH_AUTH_SOCK = ${
|
||||
if pkgs.stdenv.isDarwin then
|
||||
"/tmp/yubikey-agent.sock"
|
||||
else
|
||||
''$"($env.XDG_RUNTIME_DIR | default $"/run/user/(id -u)")/yubikey-agent/yubikey-agent.sock"''
|
||||
}";
|
||||
};
|
||||
|
||||
systemd.user.services.yubikey-agent = {
|
||||
Unit = {
|
||||
|
||||
@@ -187,6 +187,7 @@ import nmtSrc {
|
||||
./modules/misc/nix
|
||||
./modules/misc/nix-remote-build
|
||||
./modules/misc/specialisation
|
||||
./modules/misc/ssh_auth_sock/default.nix
|
||||
./modules/misc/xdg
|
||||
./modules/xresources
|
||||
# keep-sorted end
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
ssh_auth_sock-initialization = ./initialization.nix;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
|
||||
ssh_auth_sock.initialization = {
|
||||
bash = "echo bash/zsh";
|
||||
fish = "echo fish";
|
||||
nushell = "echo nushell";
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'if ("SSH_AUTH_SOCK" not-in $env) or ($env.SSH_AUTH_SOCK | is-empty) or ("SSH_CONNECTION" not-in $env) or ($env.SSH_CONNECTION | is-empty) {'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
|
||||
'';
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
gpg-agent-default-homedir = ./default-homedir.nix;
|
||||
gpg-agent-override-homedir = ./override-homedir.nix;
|
||||
gpg-agent-pinentry-program = ./pinentry-program.nix;
|
||||
gpg-agent-ssh-support = ./ssh-support.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
|
||||
services.gpg-agent = {
|
||||
enable = true;
|
||||
enableSshSupport = true;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="$(@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK (@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"(@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="$(@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)"'
|
||||
|
||||
assertFileContains \
|
||||
home-files/.bashrc \
|
||||
'@gnupg@/bin/gpg-connect-agent --quiet updatestartuptty /bye'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'@gnupg@/bin/gpg-connect-agent --quiet updatestartuptty /bye'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'@gnupg@/bin/gpg-connect-agent --quiet updatestartuptty /bye'
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'@gnupg@/bin/gpg-connect-agent --quiet updatestartuptty /bye'
|
||||
'';
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.proton-pass-agent = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
bash_profile=home-files/.profile
|
||||
|
||||
assertFileContains $bash_profile \
|
||||
'if [ -z "$SSH_AUTH_SOCK" -o -z "$SSH_CONNECTION" ]; then'
|
||||
assertFileContains $bash_profile \
|
||||
'export SSH_AUTH_SOCK=${
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"$XDG_RUNTIME_DIR"
|
||||
}/proton-pass-agent'
|
||||
'';
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
{
|
||||
proton-pass-agent-basic-service = ./basic-service.nix;
|
||||
proton-pass-agent-full-service = ./full-service.nix;
|
||||
proton-pass-agent-bash-integration = ./bash-integration.nix;
|
||||
proton-pass-agent-fish-integration = ./fish-integration.nix;
|
||||
proton-pass-agent-nushell-integration = ./nushell-integration.nix;
|
||||
proton-pass-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.proton-pass-agent = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
};
|
||||
|
||||
programs.fish.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
fish_config=home-files/.config/fish/config.fish
|
||||
|
||||
assertFileContains $fish_config \
|
||||
'if test -z "$SSH_AUTH_SOCK"; or test -z "$SSH_CONNECTION'
|
||||
assertFileContains $fish_config \
|
||||
'set -x SSH_AUTH_SOCK ${
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"$XDG_RUNTIME_DIR"
|
||||
}/proton-pass-agent'
|
||||
'';
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.proton-pass-agent = {
|
||||
enable = true;
|
||||
enableNushellIntegration = true;
|
||||
};
|
||||
|
||||
programs.nushell.enable = true;
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
unsetOrEmpty = var: ''("${var}" not-in $env) or ($env.${var} | is-empty)'';
|
||||
in
|
||||
''
|
||||
nu_config=home-files/.config/nushell/config.nu
|
||||
|
||||
assertFileContains $nu_config \
|
||||
'if ${unsetOrEmpty "SSH_AUTH_SOCK"} or ${unsetOrEmpty "SSH_CONNECTION"} {'
|
||||
assertFileContains $nu_config \
|
||||
'$env.SSH_AUTH_SOCK = $"${
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"($env.XDG_RUNTIME_DIR)"
|
||||
}/proton-pass-agent"'
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.proton-pass-agent.enable = true;
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
bashDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"$XDG_RUNTIME_DIR";
|
||||
fishDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"$XDG_RUNTIME_DIR";
|
||||
nushellDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)"
|
||||
else
|
||||
"($env.XDG_RUNTIME_DIR)";
|
||||
in
|
||||
''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="${bashDir}/proton-pass-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "${fishDir}/proton-pass-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"${nushellDir}/proton-pass-agent"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="${bashDir}/proton-pass-agent"'
|
||||
'';
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
services.ssh-agent = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
};
|
||||
|
||||
programs.bash.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK=$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent'
|
||||
'';
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
ssh-agent-darwin-basic-service = ./basic-service.nix;
|
||||
ssh-agent-darwin-timeout-service = ./timeout-service.nix;
|
||||
ssh-agent-darwin-pkcs11-service = ./pkcs11-service.nix;
|
||||
ssh-agent-darwin-bash-integration = ./bash-integration.nix;
|
||||
ssh-agent-darwin-nushell-integration = ./nushell-integration.nix;
|
||||
ssh-agent-basic-service = ./basic-service.nix;
|
||||
ssh-agent-pkcs11-service = ./pkcs11-service.nix;
|
||||
ssh-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
ssh-agent-timeout-service = ./timeout-service.nix;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
services.ssh-agent = {
|
||||
enable = true;
|
||||
enableNushellIntegration = true;
|
||||
};
|
||||
|
||||
programs.nushell.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.ssh-agent.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="$(@system_cmds@/bin/getconf DARWIN_USER_TEMP_DIR)/ssh-agent"'
|
||||
'';
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
ssh-agent-basic-service = ./basic-service.nix;
|
||||
ssh-agent-timeout-service = ./timeout-service.nix;
|
||||
ssh-agent-pkcs11-service = ./pkcs11-service.nix;
|
||||
ssh-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
ssh-agent-timeout-service = ./timeout-service.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.ssh-agent.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"'
|
||||
'';
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
|
||||
ssh-tpm-agent-standalone = ./standalone.nix;
|
||||
ssh-tpm-agent-as-ssh-agent-proxy = ./as-ssh-agent-proxy.nix;
|
||||
ssh-tpm-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
ssh-tpm-agent-standalone = ./standalone.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.ssh-tpm-agent.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-tpm-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-tpm-agent.sock"'
|
||||
'';
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
yubikey-agent = ./service.nix;
|
||||
yubikey-agent-service = ./service.nix;
|
||||
yubikey-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.yubikey-agent.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="/tmp/yubikey-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "/tmp/yubikey-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = /tmp/yubikey-agent.sock'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="/tmp/yubikey-agent.sock"'
|
||||
'';
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
yubikey-agent = ./service.nix;
|
||||
yubikey-agent-service = ./service.nix;
|
||||
yubikey-agent-ssh_auth_sock = ./ssh_auth_sock.nix;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
programs.bash.enable = true;
|
||||
programs.fish.enable = true;
|
||||
programs.nushell.enable = true;
|
||||
programs.zsh.enable = true;
|
||||
services.yubikey-agent.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains \
|
||||
home-files/.profile \
|
||||
'export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'set -x SSH_AUTH_SOCK "''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.config/nushell/config.nu \
|
||||
'$env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR | default $"/run/user/(id -u)")/yubikey-agent/yubikey-agent.sock"'
|
||||
assertFileContains \
|
||||
home-files/.zshenv \
|
||||
'export SSH_AUTH_SOCK="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-agent/yubikey-agent.sock"'
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user