|
1 |
| -# This file was generated by https://github.com/kamilchm/go2nix v1.2.1 |
2 |
| -{ stdenv, buildGoPackage, fetchFromGitHub, gnupg }: |
3 |
| - |
4 |
| -buildGoPackage rec { |
5 |
| - name = "browserpass-${version}"; |
6 |
| - version = "2.0.22"; |
7 |
| - |
8 |
| - goPackagePath = "github.com/dannyvankooten/browserpass"; |
9 |
| - |
10 |
| - goDeps = ./deps.nix; |
| 1 | +{ lib, callPackage, buildGoPackage, fetchFromGitHub, makeWrapper, gnupg }: |
| 2 | +let |
| 3 | + # For backwards compatibility with v2 of the browser extension, we embed v2 |
| 4 | + # of the native host in v3. Because the extension will auto-update when it |
| 5 | + # is released, this code can be removed from that point on. |
| 6 | + # Don't forget to remove v2 references down below and the v2 files in this |
| 7 | + # folder |
| 8 | + v2 = callPackage ./2.nix {}; |
| 9 | +in buildGoPackage rec { |
| 10 | + pname = "browserpass"; |
| 11 | + version = "3.0.1"; |
11 | 12 |
|
12 | 13 | src = fetchFromGitHub {
|
13 |
| - repo = "browserpass"; |
14 |
| - owner = "dannyvankooten"; |
| 14 | + owner = "browserpass"; |
| 15 | + repo = "browserpass-native"; |
15 | 16 | rev = version;
|
16 |
| - sha256 = "05cacrx08k99c5zra7ksdik9xxn3vih3x6in7536zs5gm55mkbfx"; |
| 17 | + sha256 = "1i3xxysiiapz9y2v0gp13inx7j0d7n0khpmcsy9k95pzn53526dx"; |
17 | 18 | };
|
18 | 19 |
|
| 20 | + nativeBuildInputs = [ makeWrapper ]; |
| 21 | + |
| 22 | + goPackagePath = "github.com/browserpass/browserpass-native"; |
| 23 | + goDeps = ./deps.nix; |
| 24 | + |
19 | 25 | postPatch = ''
|
20 |
| - substituteInPlace browserpass.go \ |
21 |
| - --replace /usr/local/bin/gpg ${gnupg}/bin/gpg |
| 26 | + # Because this Makefile will be installed to be used by the user, patch |
| 27 | + # variables to be valid by default |
| 28 | + substituteInPlace Makefile \ |
| 29 | + --replace "PREFIX ?= /usr" "" |
22 | 30 | '';
|
23 | 31 |
|
24 |
| - postInstall = '' |
25 |
| - host_file="$bin/bin/browserpass" |
26 |
| - mkdir -p "$bin/etc" |
| 32 | + DESTDIR = placeholder "bin"; |
| 33 | + |
| 34 | + postConfigure = '' |
| 35 | + cd "go/src/$goPackagePath" |
| 36 | + make configure |
| 37 | + ''; |
| 38 | + |
| 39 | + buildPhase = '' |
| 40 | + make |
| 41 | + ''; |
| 42 | + |
| 43 | + installPhase = '' |
| 44 | + make install |
| 45 | +
|
| 46 | + wrapProgram $bin/bin/browserpass \ |
| 47 | + --suffix PATH : ${lib.makeBinPath [ gnupg ]} |
27 | 48 |
|
28 |
| - sed -e "s!%%replace%%!$host_file!" go/src/${goPackagePath}/chrome/host.json > chrome-host.json |
29 |
| - sed -e "s!%%replace%%!$host_file!" go/src/${goPackagePath}/firefox/host.json > firefox-host.json |
| 49 | + # This path is used by our firefox wrapper for finding native messaging hosts |
| 50 | + mkdir -p $bin/lib/mozilla/native-messaging-hosts |
| 51 | + ln -s $bin/lib/browserpass/hosts/firefox/*.json $bin/lib/mozilla/native-messaging-hosts |
30 | 52 |
|
31 |
| - install chrome-host.json $bin/etc/ |
32 |
| - install -D firefox-host.json $bin/lib/mozilla/native-messaging-hosts/com.dannyvankooten.browserpass.json |
33 |
| - install go/src/${goPackagePath}/chrome/policy.json $bin/etc/chrome-policy.json |
| 53 | + # These can be removed too, see comment up top |
| 54 | + ln -s ${lib.getBin v2}/etc $bin/etc |
| 55 | + ln -s ${lib.getBin v2}/lib/mozilla/native-messaging-hosts/* $bin/lib/mozilla/native-messaging-hosts |
34 | 56 | '';
|
35 | 57 |
|
36 |
| - meta = with stdenv.lib; { |
37 |
| - description = "A Chrome & Firefox extension for zx2c4's pass"; |
38 |
| - homepage = https://github.com/dannyvankooten/browserpass; |
39 |
| - license = licenses.mit; |
40 |
| - platforms = with platforms; linux ++ darwin ++ openbsd; |
41 |
| - maintainers = with maintainers; [ rvolosatovs ]; |
| 58 | + meta = with lib; { |
| 59 | + description = "Browserpass native client app"; |
| 60 | + homepage = https://github.com/browserpass/browserpass-native; |
| 61 | + license = licenses.isc; |
| 62 | + platforms = platforms.all; |
| 63 | + maintainers = with maintainers; [ rvolosatovs infinisil ]; |
42 | 64 | };
|
43 | 65 | }
|
0 commit comments