Fetch flake once, use store path for later calls
This commit is contained in:
parent
ce4221f4bb
commit
221052d846
8
bij.sh
8
bij.sh
@ -43,6 +43,8 @@ if [[ -z ${FLAKE} ]]; then
|
|||||||
FLAKE="$(pwd)"
|
FLAKE="$(pwd)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
FLAKE_STORE_PATH="$(nix flake archive --json "${FLAKE}" | jq -r .path)"
|
||||||
|
|
||||||
if [[ "${#ARGS[@]}" -lt 1 ]]; then
|
if [[ "${#ARGS[@]}" -lt 1 ]]; then
|
||||||
echo "Command not specified"
|
echo "Command not specified"
|
||||||
exit 1
|
exit 1
|
||||||
@ -62,15 +64,15 @@ HOST="${ARGS[1]}"
|
|||||||
|
|
||||||
if [[ -z ${TARGET} ]]; then
|
if [[ -z ${TARGET} ]]; then
|
||||||
# Use fqdn as target
|
# Use fqdn as target
|
||||||
TARGET="$(nix --extra-experimental-features "nix-command flakes" eval --raw "${FLAKE}#nixosConfigurations.${HOST}" --apply "host: host.config.networking.fqdn")"
|
TARGET="$(nix --extra-experimental-features "nix-command flakes" eval --raw "${FLAKE_STORE_PATH}#nixosConfigurations.${HOST}" --apply "host: host.config.networking.fqdn")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${COMMAND}" in
|
case "${COMMAND}" in
|
||||||
apply)
|
apply)
|
||||||
nixos-rebuild switch --flake "${FLAKE}#${HOST}" --target-host "${TARGET}" --use-substitutes --use-remote-sudo
|
nixos-rebuild switch --flake "${FLAKE_STORE_PATH}#${HOST}" --target-host "${TARGET}" --use-substitutes --use-remote-sudo
|
||||||
;;
|
;;
|
||||||
build)
|
build)
|
||||||
nixos-rebuild build --flake "${FLAKE}#${HOST}"
|
nixos-rebuild build --flake "${FLAKE_STORE_PATH}#${HOST}"
|
||||||
;;
|
;;
|
||||||
exec)
|
exec)
|
||||||
# shellcheck disable=SC2029
|
# shellcheck disable=SC2029
|
||||||
|
Loading…
Reference in New Issue
Block a user