nix-build: add --cores parameter

This commit is contained in:
Ingolf Wanger 2019-03-22 22:57:14 +01:00
parent c54ce47d5d
commit 223d5c0579

View File

@ -9,6 +9,7 @@ configuration=${NIXOS_CONFIG:-$libexec_dir/configuration.nix}
format=
format_dir=$libexec_dir/formats
target_system=
cores=
run=
## Functions
@ -28,6 +29,7 @@ Options:
* --run: runs the configuration in a VM
only works for the "vm" and "vm-no-gui" formats
* --system: specify the target system (eg: x86_64-linux)
* --cores : to control the maximum amount of parallelism. (see nix-build documentation)
USAGE
}
@ -50,6 +52,10 @@ while [[ $# -gt 0 ]]; do
configuration=$2
shift
;;
--cores)
cores=$2
shift
;;
-f | --format)
format=$format_dir/$2.nix
shift
@ -98,6 +104,10 @@ if [[ -n $target_system ]]; then
args+=(--argstr system "$target_system")
fi
if [[ -n $cores ]]; then
args+=(--cores "$cores")
fi
formatAttr=$(nix-instantiate "${args[@]}" --eval --json -A config.formatAttr | jq -r .)
out=$(nix-build "${args[@]}" --no-out-link -A "config.system.build.$formatAttr")