nixpkgs-suyu/pkgs/tools/security/rbw/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.1 KiB
Nix
Raw Permalink Normal View History

2020-05-19 18:10:52 +02:00
{ lib
2020-10-01 06:20:00 +02:00
, stdenv
2020-05-19 18:10:52 +02:00
, rustPlatform
2023-03-10 05:20:00 +01:00
, fetchzip
2020-05-19 18:10:52 +02:00
, openssl
2021-01-17 04:51:22 +01:00
, pkg-config
2021-04-25 06:20:00 +02:00
, installShellFiles
, darwin
, bash
2020-05-19 18:10:52 +02:00
2021-10-28 09:13:13 +02:00
# rbw-fzf
, withFzf ? false
, fzf
, perl
# rbw-rofi
, withRofi ? false
, rofi
, xclip
# pass-import
, withPass ? false
, pass
2020-05-19 18:10:52 +02:00
}:
rustPlatform.buildRustPackage rec {
pname = "rbw";
version = "1.9.0";
2020-05-19 18:10:52 +02:00
2023-03-10 05:20:00 +01:00
src = fetchzip {
url = "https://git.tozt.net/rbw/snapshot/rbw-${version}.tar.gz";
sha256 = "sha256-NjMH99rmJYbCxDdc7e0iOFoslSrIuwIBxuHxADp0Ks4=";
2020-05-19 18:10:52 +02:00
};
cargoHash = "sha256-AH35v61FgUQe9BwDgVnXwoVTSQduxeMbXWy4ga3WU3k=";
2020-05-19 18:10:52 +02:00
nativeBuildInputs = [
2021-04-25 06:20:00 +02:00
installShellFiles
2023-02-18 05:20:00 +01:00
] ++ lib.optionals stdenv.isLinux [ pkg-config ];
2020-05-19 18:10:52 +02:00
buildInputs = [ bash ] # for git-credential-rbw
++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk_11_0.frameworks.Security
darwin.apple_sdk_11_0.frameworks.AppKit
];
2020-10-01 06:20:00 +02:00
2023-02-18 05:20:00 +01:00
preConfigure = lib.optionalString stdenv.isLinux ''
2020-05-19 18:10:52 +02:00
export OPENSSL_INCLUDE_DIR="${openssl.dev}/include"
treewide: use lib.getLib for OpenSSL libraries At some point, I'd like to make another attempt at 71f1f4884b5 ("openssl: stop static binaries referencing libs"), which was reverted in 195c7da07df. One problem with my previous attempt is that I moved OpenSSL's libraries to a lib output, but many dependent packages were hardcoding the out output as the location of the libraries. This patch fixes every such case I could find in the tree. It won't have any effect immediately, but will mean these packages will automatically use an OpenSSL lib output if it is reintroduced in future. This patch should cause very few rebuilds, because it shouldn't make any change at all to most packages I'm touching. The few rebuilds that are introduced come from when I've changed a package builder not to use variable names like openssl.out in scripts / substitution patterns, which would be confusing since they don't hardcode the output any more. I started by making the following global replacements: ${pkgs.openssl.out}/lib -> ${lib.getLib pkgs.openssl}/lib ${openssl.out}/lib -> ${lib.getLib openssl}/lib Then I removed the ".out" suffix when part of the argument to lib.makeLibraryPath, since that function uses lib.getLib internally. Then I fixed up cases where openssl was part of the -L flag to the compiler/linker, since that unambigously is referring to libraries. Then I manually investigated and fixed the following packages: - pycurl - citrix-workspace - ppp - wraith - unbound - gambit - acl2 I'm reasonably confindent in my fixes for all of them. For acl2, since the openssl library paths are manually provided above anyway, I don't think openssl is required separately as a build input at all. Removing it doesn't make a difference to the output size, the file list, or the closure. I've tested evaluation with the OfBorg meta checks, to protect against introducing evaluation failures.
2022-03-25 16:33:21 +01:00
export OPENSSL_LIB_DIR="${lib.getLib openssl}/lib"
2020-05-19 18:10:52 +02:00
'';
2021-04-25 06:20:00 +02:00
postInstall = ''
2023-02-18 05:20:00 +01:00
install -Dm755 -t $out/bin bin/git-credential-rbw
installShellCompletion --cmd rbw \
--bash <($out/bin/rbw gen-completions bash) \
--fish <($out/bin/rbw gen-completions fish) \
--zsh <($out/bin/rbw gen-completions zsh)
2021-04-25 06:20:00 +02:00
'' + lib.optionalString withFzf ''
2023-02-18 05:20:00 +01:00
install -Dm755 -t $out/bin bin/rbw-fzf
substituteInPlace $out/bin/rbw-fzf \
--replace fzf ${fzf}/bin/fzf \
--replace perl ${perl}/bin/perl
2020-05-19 18:10:52 +02:00
'' + lib.optionalString withRofi ''
2023-02-18 05:20:00 +01:00
install -Dm755 -t $out/bin bin/rbw-rofi
substituteInPlace $out/bin/rbw-rofi \
--replace rofi ${rofi}/bin/rofi \
--replace xclip ${xclip}/bin/xclip
2020-05-19 18:10:52 +02:00
'' + lib.optionalString withPass ''
2023-02-18 05:20:00 +01:00
install -Dm755 -t $out/bin bin/pass-import
substituteInPlace $out/bin/pass-import \
--replace pass ${pass}/bin/pass
2020-05-19 18:10:52 +02:00
'';
meta = with lib; {
description = "Unofficial command line client for Bitwarden";
homepage = "https://crates.io/crates/rbw";
2020-12-02 05:20:00 +01:00
changelog = "https://git.tozt.net/rbw/plain/CHANGELOG.md?id=${version}";
2020-05-19 18:10:52 +02:00
license = licenses.mit;
2020-10-17 06:20:00 +02:00
maintainers = with maintainers; [ albakham luc65r marsam ];
2020-05-19 18:10:52 +02:00
};
}