Skip to content

OUT_PATHS empty on post-build-hook when set in NIX_CONFIG #5694

@nrdxp

Description

@nrdxp

Describe the bug

I have a simple script to upload artifacts to cache after a build:

set -x

echo $OUT_PATHS

[[ $DIRENV_IN_ENVRC = 1 ]] && exit
[[ $NO_CACHE_UPLOAD = 1 ]] && exit
[[ -z $OUT_PATHS ]] && exit

export IFS=' '

echo "Signing paths" $OUT_PATHS
nix store sign --key-file secrets/nix-secret-key-file $OUT_PATHS
echo "Uploading paths" $OUT_PATHS
exec nix copy --to 'redacted' $OUT_PATHS

I placed the first echo statement at the top for debugging. The script always fails to upload anything because OUT_PATHS is always empty.

Steps To Reproduce

  1. Take the script above
  2. set it as a post build hook
  3. run nix build -L nixpkgs#hello, add a --rebuild flag if the package has already been built (since hook only runs after a local build)
  4. notice how the echo statement echos nothing

Expected behavior

man nix.conf says OUT_PATHS should contain a space separated list of built paths.

nix-env --version output

I tried this on the latest nix unstable as well as stable nix 2.4

Additional context

I am setting the post-build-hook in a flake devShell via the NIX_CONFIG variable. This is done because the cache in question is local to this particular flake and it's environment. Not sure if that may somehow be part of the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions