nix-helpers: 657ddb952ca6cde8b20bb7719c72525406e0dfeb
1: { bash, hasBinary, mkBin, withDeps, withNix }:
2:
3: with builtins;
4: with rec {
5: nixy = withNix { };
6:
7: pkg = mkBin {
8: name = "pipeToNix";
9: paths = nixy.buildInputs;
10: vars = removeAttrs nixy [ "buildInputs" ];
11: script = ''
12: #!${bash}/bin/bash
13: set -e
14:
15: # Dumps stdin to a temporary file, adds that file to the Nix store then
16: # deletes the temp file. If an argument is given, it's used as the file
17: # name (which Nix will prefix with a content hash).
18:
19: NAME="piped"
20: [[ -z "$1" ]] || NAME="$1"
21:
22: SCRATCH=$(mktemp -d)
23: trap "rm -rf $SCRATCH" EXIT
24:
25: F="$SCRATCH/$NAME"
26: cat > "$F"
27:
28: nix-store --add "$F"
29: '';
30: };
31: };
32: withDeps [ (hasBinary pkg "pipeToNix") ] pkg
Generated by git2html.