Skip to content

Commit

Permalink
Add nix-build-inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Trinkle committed Mar 18, 2018
1 parent 0e77539 commit 73fcd5a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions nix-build-inplace
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail

if [ "$1" = --help -o "$1" = -h ] ; then
2>&1 echo "Usage: $0 [ARGS...]"
2>&1 echo "ARGS will be passed to nix-shell"
exit 1
fi

nix-shell --pure "$@" --command "$(cat <<'EOF'
mkdir -p tmp
export NIX_BUILD_TOP="$PWD/tmp"
export TMPDIR="$NIX_BUILD_TOP"
export TEMPDIR="$NIX_BUILD_TOP"
export TMP="$NIX_BUILD_TOP"
export TEMP="$NIX_BUILD_TOP"
export HOME=/homeless-shelter
mkdir -p outputs
for x in $outputs ; do
mkdir -p "outputs/$x"
# Replace the expected output paths with our mutable output paths
# everywhere they appear in the environment
eval "$(set | sed "s@${!x//@/\@}@$PWD/outputs/$x@g")"
done
# We want to overwrite old sources with new ones, but we don't want to
eval "$(typeset -f unpackPhase | head -n -1 ; cat <<'ENDFUNC'
if [ "$sourceRoot" != src ] ; then
cp -aT "$sourceRoot" src
rm -rf "$sourceRoot"
sourceRoot=src
fi
}
ENDFUNC
)"
cd tmp
genericBuild
EOF
)"

ln -sfT outputs/out result

0 comments on commit 73fcd5a

Please sign in to comment.