nix-helpers: e1873c6cdf8857bb81c49e3eb2401dd5cb05fd8a

     1: #!/usr/bin/env bash
     2: set -e
     3: 
     4: # Runs the given command in a temporary directory, adds that directory
     5: # to the Nix store then deletes the temp directory. If a second argument
     6: # is given, it's used as the directory name (which Nix prefixes with a
     7: # content hash).
     8: 
     9: NAME="nixed-dir"
    10: [[ -z "$2" ]] || NAME="$2"
    11: 
    12: if [[ "$SKIP_NIX" -eq 1 ]]
    13: then
    14:     INNER="$NAME"
    15: else
    16:     SCRATCH=$(mktemp -d)
    17:     # shellcheck disable=SC2064
    18:     trap "rm -rf $SCRATCH" EXIT
    19:     INNER="$SCRATCH/$NAME"
    20: fi
    21: 
    22: mkdir -p "$INNER"
    23: pushd "$INNER" > /dev/null
    24: out="$PWD" "$1"
    25: popd           > /dev/null
    26: 
    27: if [[ "$SKIP_NIX" -eq 1 ]]
    28: then
    29:     readlink -f "$INNER"
    30: else
    31:     nix-store --add "$INNER"
    32: fi

Generated by git2html.