mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
allow 'nix build'-specific nix-build-and-cache args
We need --no-link for the complement script. I picked the syntax for this as an analogy with 'cargo rustc --cargo-args -- --rustc-args', but not sure how I feel about it.
This commit is contained in:
parent
1bfcf62d2a
commit
3f89bc4a7c
1 changed files with 25 additions and 3 deletions
|
|
@ -5,11 +5,33 @@ set -euo pipefail
|
||||||
toplevel="$(git rev-parse --show-toplevel)"
|
toplevel="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
# Build and cache the specified arguments
|
# Build and cache the specified arguments
|
||||||
|
#
|
||||||
|
# Usage: nix-build-and-cache just [args...] -- [build-only-args...]
|
||||||
|
#
|
||||||
|
# Arguments after the '--' (build-only-args) will only be passed to the
|
||||||
|
# 'nix build' command, while arguments before '--' will also be passed to any
|
||||||
|
# other nix command using the installable list. This is useful for things like
|
||||||
|
# '--no-link', which are only relevant to 'nix build'.
|
||||||
just() {
|
just() {
|
||||||
|
build_args=()
|
||||||
|
args=()
|
||||||
|
build_only_mode=0
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "$build_only_mode" = 1 ]; then
|
||||||
|
build_args+=( "$arg" )
|
||||||
|
elif [ "$arg" = "--" ]; then
|
||||||
|
# Everything after the -- is passed only to 'nix build'
|
||||||
|
build_only_mode=1
|
||||||
|
else
|
||||||
|
args+=( "$arg" )
|
||||||
|
build_args+=( "$arg" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if command -v nom &> /dev/null; then
|
if command -v nom &> /dev/null; then
|
||||||
nom build "$@"
|
nom build "${build_args[@]}"
|
||||||
else
|
else
|
||||||
nix build "$@"
|
nix build "${build_args[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${ATTIC_TOKEN+x} ]; then
|
if [ -z ${ATTIC_TOKEN+x} ]; then
|
||||||
|
|
@ -24,7 +46,7 @@ just() {
|
||||||
"$ATTIC_TOKEN"
|
"$ATTIC_TOKEN"
|
||||||
|
|
||||||
# Find all output paths of the installables and their build dependencies
|
# Find all output paths of the installables and their build dependencies
|
||||||
readarray -t derivations < <(nix path-info --derivation "$@")
|
readarray -t derivations < <(nix path-info --derivation "${args[@]}")
|
||||||
cache=()
|
cache=()
|
||||||
for derivation in "${derivations[@]}"; do
|
for derivation in "${derivations[@]}"; do
|
||||||
cache+=(
|
cache+=(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue