browserpass-native/flake.nix

69 lines
1.9 KiB
Nix

{
description = "TODO";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; eachSystem allSystems (system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
nativeBuildInputs = with pkgs; [ makeWrapper ];
in rec {
packages = {
browserpass = pkgs.buildGoModule rec {
# this is mostly excerpted from <nixpkgs/pkgs/tools/security/browserpass/default.nix>
pname = "browserpass";
version = "3.0.10-next-20221026";
src = ./.;
inherit nativeBuildInputs;
vendorSha256 = "gWXcYyIp86b/Pn6vj7qBj/VZS9rTr4weVw0YWmg+36c=";
doCheck = false;
postPatch = ''
# Because this Makefile will be installed to be used by the user, patch
# variables to be valid by default
substituteInPlace Makefile \
--replace "PREFIX ?= /usr" ""
sed -i -e 's/SED =.*/SED = sed/' Makefile
sed -i -e 's/INSTALL =.*/INSTALL = install/' Makefile
'';
DESTDIR = placeholder "out";
postConfigure = ''
make configure
'';
buildPhase = ''
make
'';
installPhase = ''
make install
wrapProgram $out/bin/browserpass \
--suffix PATH : ${lib.makeBinPath [ pkgs.gnupg ]}
# This path is used by our firefox wrapper for finding 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
'';
};
};
defaultPackage = packages.browserpass;
devShells.default = with pkgs; mkShell {
buildInputs = nativeBuildInputs ++ [ go ];
};
}
);
}