summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/brain/default.nix
blob: d7e36a5277ac28bac0349e84b38d565520298e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ pkgs }:

let
  pass = pkgs.pass.withExtensions (ext: [
    ext.pass-otp
  ]);
in

pkgs.write "brain" {
  "/bin/brain".link = pkgs.writeDash "brain" ''
    PASSWORD_STORE_DIR=$HOME/brain \
    exec ${pass}/bin/pass "$@"
  '';
  "/bin/brainmenu".link = pkgs.writeDash "brainmenu" ''
    PASSWORD_STORE_DIR=$HOME/brain \
    exec ${pass}/bin/passmenu "$@"
  '';
  "/share/bash-completion/completions/brain".link =
    pkgs.runCommand "brain-completions" {
    } /* sh */ ''
      sed -r '
        s/\<_pass?(_|\>)/_brain\1/g
        s/\<__password_store/_brain/g
        s/\<pass\>/brain/
        s/\$HOME\/\.password-store/$HOME\/brain/
      ' < ${pass}/share/bash-completion/completions/pass > $out
    '';
}