at 23.11-beta 165 lines 4.9 kB view raw
1{ stdenv, lib, pkgs, fetchurl, buildEnv 2, coreutils, findutils, gnugrep, gnused, getopt, git, tree, gnupg, openssl 3, which, openssh, procps, qrencode, makeWrapper, pass 4 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 9 10# For backwards-compatibility 11, tombPluginSupport ? false 12}: 13 14assert x11Support -> xclip != null; 15assert waylandSupport -> wl-clipboard != null; 16 17assert dmenuSupport -> x11Support || waylandSupport; 18assert dmenuSupport && x11Support 19 -> dmenu != null && xdotool != null; 20assert dmenuSupport && waylandSupport 21 -> dmenu-wayland != null && ydotool != null; 22 23 24let 25 passExtensions = import ./extensions { inherit pkgs; }; 26 27 env = extensions: 28 let 29 selected = [ pass ] ++ extensions passExtensions 30 ++ lib.optional tombPluginSupport passExtensions.tomb; 31 in buildEnv { 32 name = "pass-env"; 33 paths = selected; 34 nativeBuildInputs = [ makeWrapper ]; 35 buildInputs = lib.concatMap (x: x.buildInputs) selected; 36 37 postBuild = '' 38 files=$(find $out/bin/ -type f -exec readlink -f {} \;) 39 if [ -L $out/bin ]; then 40 rm $out/bin 41 mkdir $out/bin 42 fi 43 44 for i in $files; do 45 if ! [ "$(readlink -f "$out/bin/$(basename $i)")" = "$i" ]; then 46 ln -sf $i $out/bin/$(basename $i) 47 fi 48 done 49 50 wrapProgram $out/bin/pass \ 51 --set SYSTEM_EXTENSION_DIR "$out/lib/password-store/extensions" 52 ''; 53 meta.mainProgram = "pass"; 54 }; 55in 56 57stdenv.mkDerivation rec { 58 version = "1.7.4"; 59 pname = "password-store"; 60 61 src = fetchurl { 62 url = "https://git.zx2c4.com/password-store/snapshot/${pname}-${version}.tar.xz"; 63 sha256 = "1h4k6w7g8pr169p5w9n6mkdhxl3pw51zphx7www6pvgjb7vgmafg"; 64 }; 65 66 patches = [ 67 ./set-correct-program-name-for-sleep.patch 68 ./extension-dir.patch 69 ] ++ lib.optional stdenv.isDarwin ./no-darwin-getopt.patch; 70 71 nativeBuildInputs = [ makeWrapper ]; 72 73 installFlags = [ "PREFIX=$(out)" "WITH_ALLCOMP=yes" ]; 74 75 postInstall = lib.optionalString dmenuSupport '' 76 cp "contrib/dmenu/passmenu" "$out/bin/" 77 ''; 78 79 wrapperPath = with lib; makeBinPath ([ 80 coreutils 81 findutils 82 getopt 83 git 84 gnugrep 85 gnupg 86 gnused 87 tree 88 which 89 openssh 90 procps 91 qrencode 92 ] ++ optional stdenv.isDarwin openssl 93 ++ optional x11Support xclip 94 ++ optional waylandSupport wl-clipboard 95 ++ optionals (waylandSupport && dmenuSupport) [ ydotool dmenu-wayland ] 96 ++ optionals (x11Support && dmenuSupport) [ xdotool dmenu ] 97 ); 98 99 postFixup = '' 100 # Fix program name in --help 101 substituteInPlace $out/bin/pass \ 102 --replace 'PROGRAM="''${0##*/}"' "PROGRAM=pass" 103 104 # Ensure all dependencies are in PATH 105 wrapProgram $out/bin/pass \ 106 --prefix PATH : "${wrapperPath}" 107 '' + lib.optionalString dmenuSupport '' 108 # We just wrap passmenu with the same PATH as pass. It doesn't 109 # need all the tools in there but it doesn't hurt either. 110 wrapProgram $out/bin/passmenu \ 111 --prefix PATH : "$out/bin:${wrapperPath}" 112 ''; 113 114 # Turn "check" into "installcheck", since we want to test our pass, 115 # not the one before the fixup. 116 postPatch = '' 117 patchShebangs tests 118 119 substituteInPlace src/password-store.sh \ 120 --replace "@out@" "$out" 121 122 # the turning 123 sed -i -e 's@^PASS=.*''$@PASS=$out/bin/pass@' \ 124 -e 's@^GPGS=.*''$@GPG=${gnupg}/bin/gpg2@' \ 125 -e '/which gpg/ d' \ 126 tests/setup.sh 127 '' + lib.optionalString stdenv.isDarwin '' 128 # 'pass edit' uses hdid, which is not available from the sandbox. 129 rm -f tests/t0200-edit-tests.sh 130 rm -f tests/t0010-generate-tests.sh 131 rm -f tests/t0020-show-tests.sh 132 rm -f tests/t0050-mv-tests.sh 133 rm -f tests/t0100-insert-tests.sh 134 rm -f tests/t0300-reencryption.sh 135 rm -f tests/t0400-grep.sh 136 ''; 137 138 doCheck = false; 139 140 doInstallCheck = true; 141 nativeInstallCheckInputs = [ git ]; 142 installCheckTarget = "test"; 143 144 passthru = { 145 extensions = passExtensions; 146 withExtensions = env; 147 }; 148 149 meta = with lib; { 150 description = "Stores, retrieves, generates, and synchronizes passwords securely"; 151 homepage = "https://www.passwordstore.org/"; 152 license = licenses.gpl2Plus; 153 mainProgram = "pass"; 154 maintainers = with maintainers; [ lovek323 fpletz tadfisher globin ma27 ]; 155 platforms = platforms.unix; 156 157 longDescription = '' 158 pass is a very simple password store that keeps passwords inside gpg2 159 encrypted files inside a simple directory tree residing at 160 ~/.password-store. The pass utility provides a series of commands for 161 manipulating the password store, allowing the user to add, remove, edit, 162 synchronize, generate, and manipulate passwords. 163 ''; 164 }; 165}