nixos/users/malte/pass.nix
Malte Tammena 9bada411db Move [marie|malte] -> /users/[marie|malte]
To prepare for an addiotional /users/modules
which can be shared between users.
2022-01-13 12:08:39 +01:00

51 lines
1.4 KiB
Nix

{ pkgs, ... }:
let
sed = "${pkgs.gnused}/bin/sed";
pass = "${pkgs.pass}/bin/pass";
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
notify-send = "${pkgs.libnotify}/bin/notify-send";
bemenu = ''
${pkgs.bemenu}/bin/bemenu -inl80 \
--fn 'FiraCode Nerd Font 11' \
--tb=#282828 \
--tf=#ebdbb2 \
--fb=#282828 \
--ff=#ebdbb2 \
--nb=#282828 \
--nf=#ebdbb2 \
--hb=#ebdbb2 \
--hf=#282828 \
-p 'Password:'
'';
passmenu-bemenu = pkgs.writeScriptBin "passmenu-bemenu" ''
#!${pkgs.stdenv.shell}
PREFIX=~/.local/share/password-store/
SUFFIX=.gpg
set -o pipefail
selection=$( ${pkgs.fd}/bin/fd '.gpg' "$PREFIX" \
| ${sed} "s|$PREFIX||" \
| ${sed} "s|$SUFFIX||" \
| ${bemenu} )
if [[ $? -ne 0 ]]; then
exit 1
fi
PASSWORD_STORE_DIR="$PREFIX" ${pass} show "$selection" | ${wl-copy} -o || exit 2
${notify-send} -u low -a Pass "$selection" "Copied to clipboard"
'';
in {
programs.password-store = {
enable = true;
settings = { PASSWORD_STORE_KEY = "BCE9E4BF632E7CED"; };
};
home.packages = [ passmenu-bemenu pkgs.firaCodeNerd ];
}