diff options
Diffstat (limited to 'overlays')
-rw-r--r-- | overlays/sshpass-secret.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/overlays/sshpass-secret.nix b/overlays/sshpass-secret.nix new file mode 100644 index 00000000..cfd19afe --- /dev/null +++ b/overlays/sshpass-secret.nix | |||
@@ -0,0 +1,26 @@ | |||
1 | final: prev: { | ||
2 | sshpassSecret = prev.writeScriptBin "sshpass-secret" '' | ||
3 | #!${final.zsh}/bin/zsh -e | ||
4 | |||
5 | typeset -a cmd | ||
6 | cmd=() | ||
7 | |||
8 | while | ||
9 | if [[ "$#" -le 0 ]]; then | ||
10 | echo "Insufficient arguments" >&2 | ||
11 | exit 2 | ||
12 | fi | ||
13 | arg="''${1}" | ||
14 | shift | ||
15 | do | ||
16 | [[ "''${arg}" == '--' ]] && break | ||
17 | user=''${arg%@*} | ||
18 | host=''${arg#*@} | ||
19 | exec {fdnum}< <(${final.gnome.libsecret}/bin/secret-tool lookup service sshpass host "''${host}" user "''${user}") | ||
20 | cmd+=(${final.sshpass}/bin/sshpass -d ''${fdnum} -P "''${user}@''${host}'s password:") | ||
21 | done | ||
22 | |||
23 | cmd+=($@) | ||
24 | exec -a ''${cmd[1]} -- $cmd | ||
25 | ''; | ||
26 | } | ||