Skip to content

Commit

Permalink
Merge pull request #58639 from Infinisil/update/browserpass
Browse files Browse the repository at this point in the history
browserpass: 2.0.22 -> 3.0.1
  • Loading branch information
infinisil committed Apr 1, 2019
2 parents 323cfa9 + e98ee8d commit 86956b9
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 51 deletions.
33 changes: 26 additions & 7 deletions nixos/modules/programs/browserpass.nix
Expand Up @@ -4,15 +4,34 @@ with lib;

{

###### interface
options = {
programs.browserpass.enable = mkEnableOption "the NativeMessaging configuration for Chromium, Chrome, and Vivaldi.";
};
options.programs.browserpass.enable = mkEnableOption "Browserpass native messaging host";

###### implementation
config = mkIf config.programs.browserpass.enable {
environment.systemPackages = [ pkgs.browserpass ];
environment.etc = {
environment.etc = let
appId = "com.github.browserpass.native.json";
source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}";
in {
# chromium
"chromium/native-messaging-hosts/${appId}".source = source "hosts/chromium";
"chromium/policies/managed/${appId}".source = source "policies/chromium";

# chrome
"opt/chrome/native-messaging-hosts/${appId}".source = source "hosts/chromium";
"opt/chrome/policies/managed/${appId}".source = source "policies/chromium";

# vivaldi
"opt/vivaldi/native-messaging-hosts/${appId}".source = source "hosts/chromium";
"opt/vivaldi/policies/managed/${appId}".source = source "policies/chromium";

# 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";
Expand Down
43 changes: 43 additions & 0 deletions pkgs/tools/security/browserpass/2.nix
@@ -0,0 +1,43 @@
# 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 ];
};
}
39 changes: 39 additions & 0 deletions pkgs/tools/security/browserpass/2deps.nix
@@ -0,0 +1,39 @@
# 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";
};
}
]
80 changes: 51 additions & 29 deletions pkgs/tools/security/browserpass/default.nix
@@ -1,43 +1,65 @@
# 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 = ./deps.nix;
{ 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 {
pname = "browserpass";
version = "3.0.1";

src = fetchFromGitHub {
repo = "browserpass";
owner = "dannyvankooten";
owner = "browserpass";
repo = "browserpass-native";
rev = version;
sha256 = "05cacrx08k99c5zra7ksdik9xxn3vih3x6in7536zs5gm55mkbfx";
sha256 = "1i3xxysiiapz9y2v0gp13inx7j0d7n0khpmcsy9k95pzn53526dx";
};

nativeBuildInputs = [ makeWrapper ];

goPackagePath = "github.com/browserpass/browserpass-native";
goDeps = ./deps.nix;

postPatch = ''
substituteInPlace browserpass.go \
--replace /usr/local/bin/gpg ${gnupg}/bin/gpg
# Because this Makefile will be installed to be used by the user, patch
# variables to be valid by default
substituteInPlace Makefile \
--replace "PREFIX ?= /usr" ""
'';

postInstall = ''
host_file="$bin/bin/browserpass"
mkdir -p "$bin/etc"
DESTDIR = placeholder "bin";

postConfigure = ''
cd "go/src/$goPackagePath"
make configure
'';

buildPhase = ''
make
'';

installPhase = ''
make install
wrapProgram $bin/bin/browserpass \
--suffix PATH : ${lib.makeBinPath [ gnupg ]}
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
# 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
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
# 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
'';

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 ];
meta = with lib; {
description = "Browserpass native client app";
homepage = https://github.com/browserpass/browserpass-native;
license = licenses.isc;
platforms = platforms.all;
maintainers = with maintainers; [ rvolosatovs infinisil ];
};
}
84 changes: 69 additions & 15 deletions pkgs/tools/security/browserpass/deps.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 86956b9

Please sign in to comment.