nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 rustPlatform,
5 fetchzip,
6 openssl,
7 pkg-config,
8 installShellFiles,
9 bash,
10 # rbw-fzf
11 withFzf ? false,
12 fzf,
13 perl,
14 # rbw-rofi
15 withRofi ? false,
16 rofi,
17 xclip,
18 # pass-import
19 withPass ? false,
20 pass,
21}:
22rustPlatform.buildRustPackage rec {
23 pname = "rbw";
24 version = "1.15.0";
25
26 src = fetchzip {
27 url = "https://git.tozt.net/rbw/snapshot/rbw-${version}.tar.gz";
28 hash = "sha256-N/s1flB+s2HwEeLsf7YlJG+5TJgP8Wu7PHNPWmVfpIo=";
29 };
30
31 cargoHash = "sha256-N4IxnAXDvD+vp3LUB9CKYM+1C5i1Flihk+Pfb2c5IWY=";
32
33 nativeBuildInputs = [
34 installShellFiles
35 ]
36 ++ lib.optionals stdenv.hostPlatform.isLinux [ pkg-config ];
37
38 buildInputs = [ bash ]; # for git-credential-rbw
39
40 preConfigure = lib.optionalString stdenv.hostPlatform.isLinux ''
41 export OPENSSL_INCLUDE_DIR="${openssl.dev}/include"
42 export OPENSSL_LIB_DIR="${lib.getLib openssl}/lib"
43 '';
44
45 postInstall = ''
46 install -Dm755 -t $out/bin bin/git-credential-rbw
47 ''
48 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
49 installShellCompletion --cmd rbw \
50 --bash <($out/bin/rbw gen-completions bash) \
51 --fish <($out/bin/rbw gen-completions fish) \
52 --nushell <($out/bin/rbw gen-completions nushell) \
53 --zsh <($out/bin/rbw gen-completions zsh)
54 ''
55 + lib.optionalString withFzf ''
56 install -Dm755 -t $out/bin bin/rbw-fzf
57 substituteInPlace $out/bin/rbw-fzf \
58 --replace fzf ${fzf}/bin/fzf \
59 --replace perl ${perl}/bin/perl
60 ''
61 + lib.optionalString withRofi ''
62 install -Dm755 -t $out/bin bin/rbw-rofi
63 substituteInPlace $out/bin/rbw-rofi \
64 --replace rofi ${rofi}/bin/rofi \
65 --replace xclip ${xclip}/bin/xclip
66 ''
67 + lib.optionalString withPass ''
68 install -Dm755 -t $out/bin bin/pass-import
69 substituteInPlace $out/bin/pass-import \
70 --replace pass ${pass}/bin/pass
71 '';
72
73 meta = {
74 description = "Unofficial command line client for Bitwarden";
75 homepage = "https://crates.io/crates/rbw";
76 changelog = "https://git.tozt.net/rbw/plain/CHANGELOG.md?id=${version}";
77 license = lib.licenses.mit;
78 maintainers = with lib.maintainers; [
79 albakham
80 jasonxue1
81 ];
82 mainProgram = "rbw";
83 };
84}