mirror of
https://github.com/nix-community/nixos-anywhere.git
synced 2024-10-05 20:27:20 +03:00
16 lines
597 B
Bash
Executable File
16 lines
597 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -efu
|
|
|
|
declare file attribute nix_options
|
|
eval "$(jq -r '@sh "attribute=\(.attribute) file=\(.file) nix_options=\(.nix_options)"')"
|
|
options=$(echo "${nix_options}" | jq -r '.options | to_entries | map("--option \(.key) \(.value)") | join(" ")')
|
|
if [[ -n ${file-} ]] && [[ -e ${file-} ]]; then
|
|
# shellcheck disable=SC2086
|
|
out=$(nix build --no-link --json $options -f "$file" "$attribute")
|
|
printf '%s' "$out" | jq -c '.[].outputs'
|
|
else
|
|
# shellcheck disable=SC2086
|
|
out=$(nix build --no-link --json $options "$attribute")
|
|
printf '%s' "$out" | jq -c '.[].outputs'
|
|
fi
|