Skip to content

Commit

Permalink
Allow buildInputs to be regular files
Browse files Browse the repository at this point in the history
If a build input is a regular file, use it as a setup hook. This makes
setup hooks more efficient to create: you don't need a derivation that
copies them to $out/nix-support/setup-hook, instead you can use the
file as is.
  • Loading branch information
edolstra committed Aug 9, 2014
1 parent 0a8605d commit b23dbb1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkgs/stdenv/generic/setup.sh
Expand Up @@ -198,6 +198,10 @@ findInputs() {

eval $var="'${!var} $pkg '"

if [ -f $pkg ]; then
source $pkg
fi

if [ -f $pkg/nix-support/setup-hook ]; then
source $pkg/nix-support/setup-hook
fi
Expand Down

7 comments on commit b23dbb1

@jcumming
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes problems for derivations that take regular files that are not setup hooks, and crash when sourced by bash.

@vcunat
Copy link
Member

@vcunat vcunat commented on b23dbb1 Jan 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, true, but why else should one have a single file in buildInputs? It's typically used to add stuff to various search paths.

@jcumming
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using it to pass a build config file.

@vcunat
Copy link
Member

@vcunat vcunat commented on b23dbb1 Jan 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, but how do you access it within the build? I don't see how buildInputs serves for that.

@jcumming
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I had originally thought it needed to be in the buildInputs to be available during the build, but I guess that's not the case, is it?

@edolstra
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, any environment variable will do.

@vcunat
Copy link
Member

@vcunat vcunat commented on b23dbb1 Jan 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or one can often directly supply it e.g. within makeFlags or similar vars/commands.

Please sign in to comment.