summaryrefslogtreecommitdiff
path: root/shells/sub_bash.nix
blob: 656b3858ab421741e6d8aac218df21e234b3d8c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# run with
# nix-shell shell.nix --run 'touch in ; tail -f in | bash & echo $! > pid'
# and then send commands with
# echo 'compute_me "1 + 3"' >> in
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = [ pkgs.bc ];
  shellHook = ''
    compute_me() {
      echo "$1" | bc;
    }
    export -f compute_me

    echo "I’m ready"
    '';
}