nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 gnupg,
7 makeWrapper,
8 autoPatchelfHook,
9 testers,
10 browserpass,
11}:
12
13buildGoModule rec {
14 pname = "browserpass";
15 version = "3.1.0";
16
17 src = fetchFromGitHub {
18 owner = "browserpass";
19 repo = "browserpass-native";
20 tag = version;
21 sha256 = "sha256-UZzOPRRiCUIG7uSSp9AEPMDN/+4cgyK47RhrI8oUx8U=";
22 };
23
24 nativeBuildInputs = [
25 makeWrapper
26 ]
27 ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
28
29 vendorHash = "sha256-CjuH4ANP2bJDeA+o+1j+obbtk5/NVLet/OFS3Rms4r0=";
30
31 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
32
33 postPatch = ''
34 # Because this Makefile will be installed to be used by the user, patch
35 # variables to be valid by default
36 substituteInPlace Makefile \
37 --replace "PREFIX ?= /usr" ""
38 sed -i -e 's/SED =.*/SED = sed/' Makefile
39 sed -i -e 's/INSTALL =.*/INSTALL = install/' Makefile
40 '';
41
42 DESTDIR = placeholder "out";
43
44 postConfigure = ''
45 make configure
46 '';
47
48 buildPhase = ''
49 make browserpass
50 '';
51
52 checkTarget = "test";
53
54 installPhase = ''
55 make install
56
57 wrapProgram $out/bin/browserpass \
58 --suffix PATH : ${lib.makeBinPath [ gnupg ]}
59
60 # This path is used by our firefox wrapper for finding native messaging hosts
61 mkdir -p $out/lib/mozilla/native-messaging-hosts
62 # Copy ff manifests rather than linking to allow link-farming to work recursively in dependants
63 cp $out/lib/browserpass/hosts/firefox/*.json $out/lib/mozilla/native-messaging-hosts/
64 '';
65
66 passthru.tests.version = testers.testVersion {
67 package = browserpass;
68 command = "browserpass --version";
69 };
70
71 meta = {
72 description = "Browserpass native client app";
73 mainProgram = "browserpass";
74 homepage = "https://github.com/browserpass/browserpass-native";
75 license = lib.licenses.isc;
76 maintainers = with lib.maintainers; [ rvolosatovs ];
77 };
78}