From f7bfa8f38cba7da1fb54bcf9e778b4dafeea967e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 8 Dec 2021 11:58:54 +0100 Subject: gkleen@sif: sshpass-secret --- accounts/gkleen@sif/default.nix | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 64e1e6c0..4f4897f5 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -59,6 +59,30 @@ let wrapProgram $out/bin/zulip \ --add-flags '--force-device-scale-factor=1.6' ''; + sshpassSecret = pkgs.writeScriptBin "sshpass-secret" '' + #!${pkgs.zsh}/bin/zsh -e + + typeset -a cmd + cmd=() + + while + if [[ "$#" -le 0 ]]; then + echo "Insufficient arguments" >&2 + exit 2 + fi + arg="''${1}" + shift + do + [[ "''${arg}" == '--' ]] && break + user=''${arg%@*} + host=''${arg#*@} + exec {fdnum}< <(${pkgs.gnome.libsecret}/bin/secret-tool lookup service sshpass host "''${host}" user "''${user}") + cmd+=(${pkgs.sshpass}/bin/sshpass -d ''${fdnum} -P "''${user}@''${host}'s password:") + done + + cmd+=($@) + exec -a ''${cmd[1]} -- $cmd + ''; in { imports = with flake.nixosModules.userProfiles.${userName}; [ mpv yt-dlp @@ -279,7 +303,7 @@ in { skype virt-manager rclone cached-nix-shell xournal discord xmonad worktime fira-code-symbols emacsclientDesktopItem libreoffice xournalpp wrappedChrome nixos-shell virt-viewer - freerdp + freerdp gnome-icon-theme paper-icon-theme sshpassSecret ]; file = { -- cgit v1.2.3