From c32a244bd70d6e72df500895b8df442667c66e82 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 26 May 2015 16:36:08 +0200 Subject: [PATCH] reproduce.tt: Add --print-flags option Useful when scripting stuff (e.g. if you want to do a nix-instantiate instead of a nix-build). --- src/root/reproduce.tt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/root/reproduce.tt b/src/root/reproduce.tt index 36383bff..161ea2ab 100644 --- a/src/root/reproduce.tt +++ b/src/root/reproduce.tt @@ -16,6 +16,7 @@ info() { # Process the command line. fetchOnly= +printFlags= while [ $# -gt 0 ]; do arg="$1" shift @@ -47,6 +48,10 @@ Flags: --fetch Fetch the inputs and then exit. + --print-flags + Fetch the inputs, then print the argument to nix-build on stdout + and exit. + Any additional flags are passed to nix-build. See the nix-build(1) manpage for details. EOF @@ -60,6 +65,8 @@ EOF shift elif [ "$arg" = --fetch ]; then fetchOnly=1 + elif [ "$arg" = --print-flags ]; then + printFlags=1 else extraArgs+=("$arg") fi @@ -188,7 +195,19 @@ args+=(--option extra-binary-caches '[% c.uri_for('/') %]') # when evaluating jobs that rely on builtins.currentSystem. args+=(--option system x86_64-linux) +args+=("$nixExprInputDir/[% build.nixexprpath %]" -A '[% build.job.name %]') + +if [ -n "$printFlags" ]; then + first=1 + for i in "${args[@]}"; do + if [ -z "$first" ]; then printf " "; fi + first= + printf "%q" "$i" + done + exit 0 +fi + info "running nix-build..." echo "using these flags: ${args[@]}" >&2 -exec nix-build "$nixExprInputDir/[% build.nixexprpath %]" -A '[% build.job.name %]' "${args[@]}" "${extraArgs[@]}" +exec nix-build "${args[@]}" "${extraArgs[@]}"