1 { stdenv, lib, pkgs, fetchurl, buildEnv
2 , coreutils, findutils, gnugrep, gnused, getopt, git, tree, gnupg, openssl
3 , which, openssh, procps, qrencode, makeWrapper, pass, symlinkJoin
5 , xclip ? null, xdotool ? null, dmenu ? null
6 , x11Support ? !stdenv.isDarwin , dmenuSupport ? (x11Support || waylandSupport)
7 , waylandSupport ? false, wl-clipboard ? null
8 , ydotool ? null, dmenu-wayland ? null
10 # For backwards-compatibility
11 , tombPluginSupport ? false
16 assert x11Support -> xclip != null;
17 assert waylandSupport -> wl-clipboard != null;
19 assert dmenuSupport -> x11Support || waylandSupport;
20 assert dmenuSupport && x11Support
21 -> dmenu != null && xdotool != null;
22 assert dmenuSupport && waylandSupport
23 -> dmenu-wayland != null && ydotool != null;
27 passExtensions = import ./extensions { inherit pkgs; };
31 selected = [ pass ] ++ extensions passExtensions
32 ++ lib.optional tombPluginSupport passExtensions.tomb;
34 # lib.getExe looks for name, so we keep it the same as mainProgram
37 nativeBuildInputs = [ makeWrapper ];
38 buildInputs = concatMap (x: x.buildInputs) selected;
41 files=$(find $out/bin/ -type f -exec readlink -f {} \;)
42 if [ -L $out/bin ]; then
48 if ! [ "$(readlink -f "$out/bin/$(basename $i)")" = "$i" ]; then
49 ln -sf $i $out/bin/$(basename $i)
53 wrapProgram $out/bin/pass \
54 --set SYSTEM_EXTENSION_DIR "$out/lib/password-store/extensions"
59 stdenv.mkDerivation rec {
61 pname = "password-store";
64 url = "https://git.zx2c4.com/password-store/snapshot/${pname}-${version}.tar.xz";
65 sha256 = "1h4k6w7g8pr169p5w9n6mkdhxl3pw51zphx7www6pvgjb7vgmafg";
69 ./set-correct-program-name-for-sleep.patch
71 ] ++ lib.optional stdenv.isDarwin ./no-darwin-getopt.patch;
73 nativeBuildInputs = [ makeWrapper ];
75 installFlags = [ "PREFIX=$(out)" "WITH_ALLCOMP=yes" ];
78 # Install Emacs Mode. NOTE: We can't install the necessary
79 # dependencies (s.el) here. The user has to do this themselves.
80 mkdir -p "$out/share/emacs/site-lisp"
81 cp "contrib/emacs/password-store.el" "$out/share/emacs/site-lisp/"
82 '' + optionalString dmenuSupport ''
83 cp "contrib/dmenu/passmenu" "$out/bin/"
86 wrapperPath = with lib; makeBinPath ([
99 ] ++ optional stdenv.isDarwin openssl
100 ++ optional x11Support xclip
101 ++ optional waylandSupport wl-clipboard
102 ++ optionals (waylandSupport && dmenuSupport) [ ydotool dmenu-wayland ]
103 ++ optionals (x11Support && dmenuSupport) [ xdotool dmenu ]
107 # Fix program name in --help
108 substituteInPlace $out/bin/pass \
109 --replace 'PROGRAM="''${0##*/}"' "PROGRAM=pass"
111 # Ensure all dependencies are in PATH
112 wrapProgram $out/bin/pass \
113 --prefix PATH : "${wrapperPath}"
114 '' + lib.optionalString dmenuSupport ''
115 # We just wrap passmenu with the same PATH as pass. It doesn't
116 # need all the tools in there but it doesn't hurt either.
117 wrapProgram $out/bin/passmenu \
118 --prefix PATH : "$out/bin:${wrapperPath}"
121 # Turn "check" into "installcheck", since we want to test our pass,
122 # not the one before the fixup.
126 substituteInPlace src/password-store.sh \
127 --replace "@out@" "$out"
130 sed -i -e 's@^PASS=.*''$@PASS=$out/bin/pass@' \
131 -e 's@^GPGS=.*''$@GPG=${gnupg}/bin/gpg2@' \
134 '' + lib.optionalString stdenv.isDarwin ''
135 # 'pass edit' uses hdid, which is not available from the sandbox.
136 rm -f tests/t0200-edit-tests.sh
137 rm -f tests/t0010-generate-tests.sh
138 rm -f tests/t0020-show-tests.sh
139 rm -f tests/t0050-mv-tests.sh
140 rm -f tests/t0100-insert-tests.sh
141 rm -f tests/t0300-reencryption.sh
142 rm -f tests/t0400-grep.sh
147 doInstallCheck = true;
148 installCheckInputs = [ git ];
149 installCheckTarget = "test";
152 extensions = passExtensions;
153 withExtensions = env;
157 description = "Stores, retrieves, generates, and synchronizes passwords securely";
158 homepage = "https://www.passwordstore.org/";
159 license = licenses.gpl2Plus;
160 mainProgram = "pass";
161 maintainers = with maintainers; [ lovek323 fpletz tadfisher globin ma27 ];
162 platforms = platforms.unix;
165 pass is a very simple password store that keeps passwords inside gpg2
166 encrypted files inside a simple directory tree residing at
167 ~/.password-store. The pass utility provides a series of commands for
168 manipulating the password store, allowing the user to add, remove, edit,
169 synchronize, generate, and manipulate passwords.