You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nice workaround! After playing around with it, I ended up using a different approach.
The main advantage with this one is that you can still use nix build with all its normal arguments. The main hack is that you configure an output by means of configuring an input. Here's an example flake.nix:
So the file ./defaults/config.nix will be hashed and mentioned in flake.lock. Now, key excerpts from a wrapper build.sh:
show_help() {
cat <<EOF
Usage: $0 [--compiler COMPILER] [ --prod ] \\
[ --error-insert | --no-error-insert ] [ -- [ BUILD_ARGUMENTS ] ]
$0 --help
...
Options:
--compiler COMPILER Specify the compiler version to use.
--prod Make a production build. Default is debug
build.
--error-insert, --no-error-insert Activate error insert functionality.
Default is on for debug and off for prod
builds.
-h, --help Show this help message and exit.
BUILD_ARGUMENTS Arbitrary arguments to pass along to
'nix build'.
EOF
}
...
tmpConfigfile=$(mktemp)
{
echo "{"
echo " compiler = $COMPILER;"
echo " prodBuild = $PROD_BUILD;"
echo " errorInsert = $ERROR_INSERT;"
echo "}"
} > "$tmpConfigfile"
configfile="$(nix store add "$tmpConfigfile" -n config.nix)"
rm "$tmpConfigfile"
nix build $FLAKE --override-input configFile path:$configfile "$@"
So the parameters are passed in by means of an overridden, non-flake input. The flake then passes these on to whatever function takes them, and uses the (already configured) as a normal, "non-configurable" output.
The text was updated successfully, but these errors were encountered:
Nice workaround! After playing around with it, I ended up using a different approach.
The main advantage with this one is that you can still use
nix build
with all its normal arguments. The main hack is that you configure an output by means of configuring an input. Here's an exampleflake.nix
:So the file
./defaults/config.nix
will be hashed and mentioned inflake.lock
. Now, key excerpts from a wrapperbuild.sh
:So the parameters are passed in by means of an overridden, non-flake input. The flake then passes these on to whatever function takes them, and uses the (already configured) as a normal, "non-configurable" output.
The text was updated successfully, but these errors were encountered: