browserpass: Remove v2 and switch to buildGoModule (#60282)

gstqt5
Silvan Mosberger 2019-04-28 20:05:24 +02:00 committed by Wael Nasreddine
parent 162546f0a1
commit da4f6a2a09
5 changed files with 7 additions and 205 deletions

View File

@ -26,16 +26,6 @@ with lib;
# brave
"opt/brave/native-messaging-hosts/${appId}".source = source "hosts/chromium";
"opt/brave/policies/managed/${appId}".source = source "policies/chromium";
}
# As with the v2 backwards compatibility in the pkgs.browserpass
# declaration, this part can be removed once the browser extension
# auto-updates to v3 (planned 2019-04-13, see
# https://github.com/browserpass/browserpass-native/issues/31)
// {
"chromium/native-messaging-hosts/com.dannyvankooten.browserpass.json".source = "${pkgs.browserpass}/etc/chrome-host.json";
"chromium/policies/managed/com.dannyvankooten.browserpass.json".source = "${pkgs.browserpass}/etc/chrome-policy.json";
"opt/chrome/native-messaging-hosts/com.dannyvankooten.browserpass.json".source = "${pkgs.browserpass}/etc/chrome-host.json";
"opt/chrome/policies/managed/com.dannyvankooten.browserpass.json".source = "${pkgs.browserpass}/etc/chrome-policy.json";
};
nixpkgs.config.firefox.enableBrowserpass = true;
};

View File

@ -1,43 +0,0 @@
# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
{ stdenv, buildGoPackage, fetchFromGitHub, gnupg }:
buildGoPackage rec {
name = "browserpass-${version}";
version = "2.0.22";
goPackagePath = "github.com/dannyvankooten/browserpass";
goDeps = ./2deps.nix;
src = fetchFromGitHub {
repo = "browserpass";
owner = "dannyvankooten";
rev = version;
sha256 = "05cacrx08k99c5zra7ksdik9xxn3vih3x6in7536zs5gm55mkbfx";
};
postPatch = ''
substituteInPlace browserpass.go \
--replace /usr/local/bin/gpg ${gnupg}/bin/gpg
'';
postInstall = ''
host_file="$bin/bin/browserpass"
mkdir -p "$bin/etc"
sed -e "s!%%replace%%!$host_file!" go/src/${goPackagePath}/chrome/host.json > chrome-host.json
sed -e "s!%%replace%%!$host_file!" go/src/${goPackagePath}/firefox/host.json > firefox-host.json
install chrome-host.json $bin/etc/
install -D firefox-host.json $bin/lib/mozilla/native-messaging-hosts/com.dannyvankooten.browserpass.json
install go/src/${goPackagePath}/chrome/policy.json $bin/etc/chrome-policy.json
'';
meta = with stdenv.lib; {
description = "A Chrome & Firefox extension for zx2c4's pass";
homepage = https://github.com/dannyvankooten/browserpass;
license = licenses.mit;
platforms = with platforms; linux ++ darwin ++ openbsd;
maintainers = with maintainers; [ rvolosatovs ];
};
}

View File

@ -1,39 +0,0 @@
# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
[
{
goPackagePath = "github.com/gokyle/twofactor";
fetch = {
type = "git";
url = "https://github.com/gokyle/twofactor";
rev = "eaad1884d40f9cabff98a57a524c17afd00c9fe7";
sha256 = "07kvga6f2b56kpy52a3xk16garvlqz950s350dax97x7cayba95g";
};
}
{
goPackagePath = "github.com/mattn/go-zglob";
fetch = {
type = "git";
url = "https://github.com/mattn/go-zglob";
rev = "4959821b481786922ac53e7ef25c61ae19fb7c36";
sha256 = "0rwkdw143kphpmingsrw1zp030zf3p08f64h347jpdm4lz8z5449";
};
}
{
goPackagePath = "github.com/sahilm/fuzzy";
fetch = {
type = "git";
url = "https://github.com/sahilm/fuzzy";
rev = "a154b19bb758dcdd6ede58dc11ea53c2950527b2";
sha256 = "0jkw6474d5ik2fq2zznqxj4y3p42z47r7mbg856ln5wyara2sg0l";
};
}
{
goPackagePath = "rsc.io/qr";
fetch = {
type = "git";
url = "https://github.com/rsc/qr";
rev = "48b2ede4844e13f1a2b7ce4d2529c9af7e359fc5";
sha256 = "1npxy32glnkvsp0871972jzjzgkwaqmbv6jsj9wgqsa1s2jr004p";
};
}
]

View File

@ -1,12 +1,5 @@
{ lib, callPackage, buildGoPackage, fetchFromGitHub, makeWrapper, gnupg }:
let
# For backwards compatibility with v2 of the browser extension, we embed v2
# of the native host in v3. Because the extension will auto-update when it
# is released, this code can be removed from that point on.
# Don't forget to remove v2 references down below and the v2 files in this
# folder
v2 = callPackage ./2.nix {};
in buildGoPackage rec {
{ lib, callPackage, buildGoModule, fetchFromGitHub, makeWrapper, gnupg }:
buildGoModule rec {
pname = "browserpass";
version = "3.0.6";
@ -19,8 +12,7 @@ in buildGoPackage rec {
nativeBuildInputs = [ makeWrapper ];
goPackagePath = "github.com/browserpass/browserpass-native";
goDeps = ./deps.nix;
modSha256 = "13yw7idgw8l48yvm4jjha0kbx6q22m2zp13y006mikavynqsr5kj";
postPatch = ''
# Because this Makefile will be installed to be used by the user, patch
@ -31,10 +23,9 @@ in buildGoPackage rec {
sed -i -e 's/INSTALL :=.*/INSTALL := install/' Makefile
'';
DESTDIR = placeholder "bin";
DESTDIR = placeholder "out";
postConfigure = ''
cd "go/src/$goPackagePath"
make configure
'';
@ -45,16 +36,12 @@ in buildGoPackage rec {
installPhase = ''
make install
wrapProgram $bin/bin/browserpass \
wrapProgram $out/bin/browserpass \
--suffix PATH : ${lib.makeBinPath [ gnupg ]}
# This path is used by our firefox wrapper for finding native messaging hosts
mkdir -p $bin/lib/mozilla/native-messaging-hosts
ln -s $bin/lib/browserpass/hosts/firefox/*.json $bin/lib/mozilla/native-messaging-hosts
# These can be removed too, see comment up top
ln -s ${lib.getBin v2}/etc $bin/etc
ln -s ${lib.getBin v2}/lib/mozilla/native-messaging-hosts/* $bin/lib/mozilla/native-messaging-hosts
mkdir -p $out/lib/mozilla/native-messaging-hosts
ln -s $out/lib/browserpass/hosts/firefox/*.json $out/lib/mozilla/native-messaging-hosts
'';
meta = with lib; {

View File

@ -1,93 +0,0 @@
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
[
{
goPackagePath = "github.com/davecgh/go-spew";
fetch = {
type = "git";
url = "https://github.com/davecgh/go-spew";
rev = "v1.1.1";
sha256 = "0hka6hmyvp701adzag2g26cxdj47g21x6jz4sc6jjz1mn59d474y";
};
}
{
goPackagePath = "github.com/konsorten/go-windows-terminal-sequences";
fetch = {
type = "git";
url = "https://github.com/konsorten/go-windows-terminal-sequences";
rev = "v1.0.2";
sha256 = "09mn209ika7ciy87xf2x31dq5fnqw39jidgaljvmqxwk7ff1hnx7";
};
}
{
goPackagePath = "github.com/mattn/go-zglob";
fetch = {
type = "git";
url = "https://github.com/mattn/go-zglob";
rev = "v0.0.1";
sha256 = "1sncdyq5fbd42al4amyy91h7vlzm3wm6c9vl8za2pjgfgsd581fz";
};
}
{
goPackagePath = "github.com/pmezard/go-difflib";
fetch = {
type = "git";
url = "https://github.com/pmezard/go-difflib";
rev = "v1.0.0";
sha256 = "0c1cn55m4rypmscgf0rrb88pn58j3ysvc2d0432dp3c6fqg6cnzw";
};
}
{
goPackagePath = "github.com/rifflock/lfshook";
fetch = {
type = "git";
url = "https://github.com/rifflock/lfshook";
rev = "b9218ef580f5";
sha256 = "0wxqjcjfg8c0klmdgmbw3ckagby3wg9rkga9ihd4fsf05x5scxrc";
};
}
{
goPackagePath = "github.com/sirupsen/logrus";
fetch = {
type = "git";
url = "https://github.com/sirupsen/logrus";
rev = "v1.4.0";
sha256 = "1y1qjcg19z7q9sy32rhc148kdql2aw7xkcm9d6r1blrl0mdgpx0w";
};
}
{
goPackagePath = "github.com/stretchr/objx";
fetch = {
type = "git";
url = "https://github.com/stretchr/objx";
rev = "v0.1.1";
sha256 = "0iph0qmpyqg4kwv8jsx6a56a7hhqq8swrazv40ycxk9rzr0s8yls";
};
}
{
goPackagePath = "github.com/stretchr/testify";
fetch = {
type = "git";
url = "https://github.com/stretchr/testify";
rev = "v1.3.0";
sha256 = "0wjchp2c8xbgcbbq32w3kvblk6q6yn533g78nxl6iskq6y95lxsy";
};
}
{
goPackagePath = "golang.org/x/crypto";
fetch = {
type = "git";
url = "https://go.googlesource.com/crypto";
rev = "c2843e01d9a2";
sha256 = "01xgxbj5r79nmisdvpq48zfy8pzaaj90bn6ngd4nf33j9ar1dp8r";
};
}
{
goPackagePath = "golang.org/x/sys";
fetch = {
type = "git";
url = "https://go.googlesource.com/sys";
rev = "fead79001313";
sha256 = "12vwl6sv6w7q0dyvynjhbp67242rhh77d6nlsb22ajr8rf17c63i";
};
}
]