From e6729e269fc5ab99c3a645c9034d0cbfea183556 Mon Sep 17 00:00:00 2001 From: Michael Raitza Date: Wed, 17 Feb 2021 14:06:04 +0100 Subject: [PATCH] Copy source tree to non-nix-builder build directory and cd to the right spot --- builder.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builder.nix b/builder.nix index 5d654ad..7e65ffb 100644 --- a/builder.nix +++ b/builder.nix @@ -23,12 +23,16 @@ let then imported.value else { src = filterSource - (path: type: type != "directory" || (baseNameOf path != ".git" && (all (x: path != x) filter))) + (path: type: baseNameOf path != ".git" && baseNameOf path != ".envrc" && (all (x: path != x) filter)) (/. + root); - builder = '' + builder = let + relPath = dirOf (removePrefix (root + "/") builder); + in '' #!/bin/sh set -e pout=$(mktemp -u -p $PWD) + cp -r --reflink=auto --no-preserve=mode "$src/" src + cd src/${relPath} ${/. + builder} $d1 $d2 $out >$pout if [ -e $out -a -s $pout ]; then printf "Error: %s wrote to stdout and created \$3\n" "$d1" >&2