1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 makeWrapper,
6 unstableGitUpdater,
7 coreutils,
8 util-linux,
9 gnugrep,
10 libnotify,
11 pwgen,
12 findutils,
13 gawk,
14 gnused,
15 # wayland-only deps
16 rofi-wayland,
17 pass-wayland,
18 wl-clipboard,
19 wtype,
20 # x11-only deps
21 rofi,
22 pass,
23 xclip,
24 xdotool,
25 # backend selector
26 backend ? "x11",
27}:
28
29assert lib.assertOneOf "backend" backend [
30 "x11"
31 "wayland"
32];
33
34stdenv.mkDerivation {
35 pname = "rofi-pass";
36 version = "2.0.2-unstable-2024-06-16";
37
38 src = fetchFromGitHub {
39 owner = "carnager";
40 repo = "rofi-pass";
41 rev = "37c4c862deb133a85b7d72989acfdbd2ef16b8ad";
42 hash = "sha256-1lPNj47vTPLBK7mVm+PngV8C/ZsjJ2EN4ffXGU2TlQo=";
43 };
44
45 nativeBuildInputs = [ makeWrapper ];
46
47 dontBuild = true;
48
49 installPhase = ''
50 mkdir -p $out/bin
51 cp -a rofi-pass $out/bin/rofi-pass
52
53 mkdir -p $out/share/doc/rofi-pass/
54 cp -a config.example $out/share/doc/rofi-pass/config.example
55 '';
56
57 wrapperPath = lib.makeBinPath (
58 [
59 coreutils
60 findutils
61 gawk
62 gnugrep
63 gnused
64 libnotify
65 pwgen
66 util-linux
67 ]
68 ++ lib.optionals (backend == "x11") [
69 rofi
70 (pass.withExtensions (ext: [ ext.pass-otp ]))
71 xclip
72 xdotool
73 ]
74 ++ lib.optionals (backend == "wayland") [
75 rofi-wayland
76 (pass-wayland.withExtensions (ext: [ ext.pass-otp ]))
77 wl-clipboard
78 wtype
79 ]
80 );
81
82 fixupPhase = ''
83 patchShebangs $out/bin
84
85 wrapProgram $out/bin/rofi-pass \
86 --prefix PATH : "$wrapperPath" \
87 --set-default ROFI_PASS_BACKEND ${if backend == "wayland" then "wtype" else "xdotool"} \
88 --set-default ROFI_PASS_CLIPBOARD_BACKEND ${
89 if backend == "wayland" then "wl-clipboard" else "xclip"
90 }
91 '';
92
93 passthru.updateScript = unstableGitUpdater { };
94
95 meta = {
96 description = "Script to make rofi work with password-store";
97 mainProgram = "rofi-pass";
98 homepage = "https://github.com/carnager/rofi-pass";
99 license = lib.licenses.gpl3;
100 platforms = with lib.platforms; linux;
101 maintainers = [ ];
102 };
103}