From 83b968abcfe68a45c20e16b05efb4511255c0162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Fri, 12 Jul 2024 23:44:28 +0200 Subject: [PATCH] nixos_rebuild: allow adding build host --- roles/nixos_rebuild/templates/script.j2 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/nixos_rebuild/templates/script.j2 b/roles/nixos_rebuild/templates/script.j2 index 9715b18..2cb8bd4 100644 --- a/roles/nixos_rebuild/templates/script.j2 +++ b/roles/nixos_rebuild/templates/script.j2 @@ -9,10 +9,14 @@ fi export ANSIBLE_JSON={{ loc_json | quote }} if [ -v NIXOS_ANYWHERE ]; then - if [ -v NIXOS_METHOD ]; then - echo "ERR: Method not supported for NIXOS_ANYWHERE!" >&2 + if [ -v NIXOS_METHOD ] || [ -v NIXOS_BUILD_HOST ]; then + echo "ERR: NIXOS_METHOD and/or NIXOS_BUILD_HOST not supported for NIXOS_ANYWHERE!" >&2 fi {{ nix_wrapper | quote }} nix run github:nix-community/nixos-anywhere -- --option pure-eval "false" --flake {{ flake_url | quote }} {{ target_host | quote }} else - {{ nix_wrapper | quote }} nix run nixpkgs#nixos-rebuild -- --flake {{ flake_url | quote }} "${NIXOS_METHOD:-switch}" --use-substitutes --impure --target-host {{ target_host | quote }} --show-trace + EXTRA_ARGS=() + if [ -v NIXOS_BUILD_HOST ]; then + EXTRA_ARGS+=("--build-host" "$NIXOS_BUILD_HOST") + fi + {{ nix_wrapper | quote }} nix run nixpkgs#nixos-rebuild -- --flake {{ flake_url | quote }} "${NIXOS_METHOD:-switch}" --use-substitutes --impure --target-host {{ target_host | quote }} --show-trace "${EXTRA_ARGS[@]}" fi