From 99185164fba6850c65c0d7f122cf7568005b8af4 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 26 Oct 2022 05:03:28 -0700 Subject: [PATCH] add a `flake.nix` for nix development use it for interactive development: ``` $ nix develop $ make ``` or for non-interactive builds: ``` $ nix build $ ./result/bin/browserpass listen ``` --- flake.lock | 42 +++++++++++++++++++++++++++++++++ flake.nix | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7b85fc2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1666610816, + "narHash": "sha256-q4F2VNe5bpxXOvp16DyLwE1SgNZMbNO29ZQJPIomedg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6107f97012a0c134c5848125b5aa1b149b76d2c9", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3045e5d --- /dev/null +++ b/flake.nix @@ -0,0 +1,68 @@ +{ + 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 + 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 ]; + }; + } + ); +} + +