Fix passing $OUT_PATHS to the post-build hook

Fixes #6446.
This commit is contained in:
Eelco Dolstra 2022-04-28 13:36:01 +02:00
parent 35393dc2c6
commit 4a9623b129
3 changed files with 9 additions and 6 deletions

View file

@ -786,8 +786,7 @@ void runPostBuildHook(
Store & store, Store & store,
Logger & logger, Logger & logger,
const StorePath & drvPath, const StorePath & drvPath,
StorePathSet outputPaths const StorePathSet & outputPaths)
)
{ {
auto hook = settings.postBuildHook; auto hook = settings.postBuildHook;
if (hook == "") if (hook == "")
@ -906,7 +905,7 @@ void DerivationGoal::buildDone()
auto builtOutputs = registerOutputs(); auto builtOutputs = registerOutputs();
StorePathSet outputPaths; StorePathSet outputPaths;
for (auto & [_, output] : buildResult.builtOutputs) for (auto & [_, output] : builtOutputs)
outputPaths.insert(output.outPath); outputPaths.insert(output.outPath);
runPostBuildHook( runPostBuildHook(
worker.store, worker.store,

View file

@ -9,12 +9,12 @@ echo 'require-sigs = false' >> $NIX_CONF_DIR/nix.conf
restartDaemon restartDaemon
# Build the dependencies and push them to the remote store # Build the dependencies and push them to the remote store.
nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh nix-build -o $TEST_ROOT/result dependencies.nix --post-build-hook $PWD/push-to-store.sh
clearStore clearStore
# Ensure that we the remote store contains both the runtime and buildtime # Ensure that the remote store contains both the runtime and build-time
# closure of what we've just built # closure of what we've just built.
nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix
nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix input1_drv nix copy --from "$REMOTE_STORE" --no-require-sigs -f dependencies.nix input1_drv

View file

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
set -x set -x
set -e
[ -n "$OUT_PATHS" ]
[ -n "$DRV_PATH" ]
echo Pushing "$OUT_PATHS" to "$REMOTE_STORE" echo Pushing "$OUT_PATHS" to "$REMOTE_STORE"
printf "%s" "$DRV_PATH" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs printf "%s" "$DRV_PATH" | xargs nix copy --to "$REMOTE_STORE" --no-require-sigs