Skip to content

Instantly share code, notes, and snippets.

@phryneas
Last active March 25, 2018 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phryneas/68d3817a55baf439d8bf2b9b6dd6fb9e to your computer and use it in GitHub Desktop.
Save phryneas/68d3817a55baf439d8bf2b9b6dd6fb9e to your computer and use it in GitHub Desktop.
passB-nixos

PassB on NixOS

Prerequisites

Preparations

run ./generate.shell

install with an overlay

  • symlink the passb-overlay.nix into the folder ~/.config/nixpkgs/overlays
  • this overrides your firefox-package, so just call nix-env -iA nixpkgs.firefox

without overlay, from your ~/.config/nixpkgs/config.nix

# ~/.config/nixpkgs/config.nix
{
  packageOverrides = pkgs: with pkgs; {
    all = pkgs.buildEnv {
      # ... your other packages
      (firefox.override {  extraNativeMessagingHosts = [ (import ./passB/default.nix { inherit pkgs; }).firefox-hostApp ]; })
    }
  };
}
composition.nix
node-env.nix
node-packages.nix
{
pkgs ? import <nixpkgs> { inherit system; },
system ? builtins.currentSystem,
nodejs ? pkgs.nodejs-8_x,
pass ? pkgs.pass,
}:
let
nodePackages = import ./composition.nix {
inherit system pkgs nodejs;
};
inherit (pkgs.stdenv.lib) makeBinPath;
inherit (pkgs) findutils;
in {
firefox-hostApp = nodePackages."passB_nodeHostApp-git://github.com/passb/nodeHostApp.git".override ( oldAttrs: {
name = "passb-firefox-hostApp";
postInstall = ''
JSONDIR=$out/lib/mozilla/native-messaging-hosts
mkdir -p "$JSONDIR"
cp ./passb.json "$JSONDIR/passb.json"
substituteInPlace "$JSONDIR/passb.json" --replace PLACEHOLDER $out/bin/passb_host.sh
mkdir -p $out/bin
cat <<EOF > $out/bin/passb_host.sh
#!/usr/bin/env bash
export PATH=${makeBinPath [ pass nodejs findutils ]}
node $out/lib/node_modules/passb-hostapp/index.js
EOF
chmod +x $out/bin/passb_host.sh
'';
});
}
#!/run/current-system/sw/bin/env nix-shell
#!nix-shell -i bash --pure -p nodePackages.node2nix git nix
node2nix -8 -i packages.json --composition composition.nix
composition.nix:
./generate.shell
setup: composition.nix
self: super:
#let
# inherit (super.lib) optionalAttrs;
#in
#optionalAttrs (super.firefox ? override)
rec {
passB = (import ./default.nix { pkgs = self; });
firefox = super.firefox.override { extraNativeMessagingHosts = [ passB.firefox-hostApp ]; };
}
[
{"passB_nodeHostApp": "git://github.com/passb/nodeHostApp.git"}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment