ITADN

Remote build doesn't work from all-in-one terraform module on MacOS

#590Openonnimonni 创建于 2025-09-29
bug
O
onnimonnicommented
### Prerequisites - [x] I have updated to the latest version using `nix run --refresh github:nix-community/nixos-anywhere` - [x] I have reproduced the issue with the `--debug` flag - [x] I have searched existing issues to make sure this isn't a duplicate ### Bug Description Hey, Initial deployment worked just fine but on the rebuilds opentofu is giving me following errors: ``` │ error: Cannot build '/nix/store/1qi155ilplcyz960l3nsz3x9gmp8pdsq-shutdown-ramfs-contents.json.drv'. │ Reason: required system or feature not available │ Required system: 'aarch64-linux' with features {} │ Current system: 'aarch64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test} ``` Even if I'm using the `build_on_remote = true` for the module. When running the `nixos-rebuild` from my Mac with `aarch64` targets I need to use the `--fast` and `--build-host` flags: ``` nixos-rebuild switch --flake .#my-flake-here --fast --build-host $HOST_IP --target-host $HOST_IP ``` I guess these flags 2 are is missing from the nixos-anywhere all-in-one terraform module? ### Steps to Reproduce 1. Deploy a VPS in Hetzner using MacOS. First nixos-anywhere run works perfectly. 2. Try to run the opentofu apply again after some changes in the flake 3. You should see the issue on the next build ### Debug Logs ```shell $ tofu apply -auto-approve ... module.deploy.module.partitioner-build.data.external.nix-build: Read complete after 3s [id=-] Planning failed. OpenTofu encountered an error while generating this plan. ╷ │ Error: External Program Execution Failed │ │ with module.deploy.module.system-build.data.external.nix-build, │ on .terraform/modules/deploy/terraform/nix-build/main.tf line 7, in data "external" "nix-build": │ 7: program = ["${path.module}/nix-build.sh"] │ │ The data source received an unexpected error while attempting to execute the program. │ │ Program: .terraform/modules/deploy/terraform/nix-build/nix-build.sh │ Error Message: + '[' '{"options":{}}' '!=' '{"options":{}}' ']' │ + options= │ + [[ {"terraformArgs":{"ipv6_block":"XXXX:YYY:ZZZ:WWW::1/64"}} == {} ]] │ + [[ null != null ]] │ ++ echo .#nixosConfigurations.my-server.config.system.build.toplevel │ ++ cut -d '#' -f 2 │ + rest=nixosConfigurations.my-server.config.system.build.toplevel │ + config_path=nixosConfigurations.my-server │ + config_attribute=config.system.build.toplevel │ ++ echo .#nixosConfigurations.my-server.config.system.build.toplevel │ ++ cut -d '#' -f 1 │ + flake_rel=. │ ++ nix flake prefetch . --json │ path '/Users/onnimonni/Projects/my-project/infra' does not contain a 'flake.nix', searching up │ warning: Git tree '/Users/onnimonni/Projects/my-project' has uncommitted changes │ + │ prefetch_result='{"hash":"sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0=","locked":{"dirtyRev":"9ce2f6cae4c296557f640d46a3aad2be53a647fc-dirty","dirtyShortRev":"9ce2f6c-dirty","lastModified":1758196165,"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"original":{"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"storePath":"/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source"}' │ ++ echo │ '{"hash":"sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0=","locked":{"dirtyRev":"9ce2f6cae4c296557f640d46a3aad2be53a647fc-dirty","dirtyShortRev":"9ce2f6c-dirty","lastModified":1758196165,"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"original":{"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"storePath":"/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source"}' │ ++ jq -r .storePath │ + store_path=/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source │ ++ echo │ '{"hash":"sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0=","locked":{"dirtyRev":"9ce2f6cae4c296557f640d46a3aad2be53a647fc-dirty","dirtyShortRev":"9ce2f6c-dirty","lastModified":1758196165,"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"original":{"type":"git","url":"file:///Users/onnimonni/Projects/my-project"},"storePath":"/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source"}' │ ++ jq -r .hash │ + nar_hash=sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0= │ + flake_url='path:/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source?narHash=sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0=' │ + nix_expr='(builtins.getFlake '\'''\''path:/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source?narHash=sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0='\'''\'').nixosConfigurations.my-server.extendModules { │ specialArgs = builtins.fromJSON '\'''\''{"terraformArgs":{"ipv6_block":"XXXX:YYY:ZZZ:WWW::1/64"}}'\'''\''; }' │ ++ nix build --no-link --json --expr '(builtins.getFlake │ '\'''\''path:/nix/store/pvir4zqw1bxm2ivskh3p4iyfgf92g7gw-source?narHash=sha256-45osbpHc8mTM6cxRTnzD7PCDhOZ6u8OD3gWKb5hnoq0='\'''\'').nixosConfigurations.my-server.extendModules { specialArgs = │ builtins.fromJSON '\'''\''{"terraformArgs":{"ipv6_block":"XXXX:YYY:ZZZ:WWW::1/64"}}'\'''\''; }' config.system.build.toplevel │ these 5 derivations will be built: │ /nix/store/1qi155ilplcyz960l3nsz3x9gmp8pdsq-shutdown-ramfs-contents.json.drv │ /nix/store/hk4svijzzhsva5b0z0ni5alf9ikxwjf2-unit-generate-shutdown-ramfs.service.drv │ /nix/store/9kmwx5b7prsx2dc4f9myjlljk12jr3l5-system-units.drv │ /nix/store/vbvkzjpf8w4vjb74isnmqg7jqnbaz3r2-etc.drv │ /nix/store/b1w6kxv2yhp4kc9b74934ymhq2wwsp5l-nixos-system-my-server-25.11.20250914.a870b74.drv │ error: Cannot build '/nix/store/1qi155ilplcyz960l3nsz3x9gmp8pdsq-shutdown-ramfs-contents.json.drv'. │ Reason: required system or feature not available │ Required system: 'aarch64-linux' with features {} │ Current system: 'aarch64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test} │ error: Cannot build '/nix/store/hk4svijzzhsva5b0z0ni5alf9ikxwjf2-unit-generate-shutdown-ramfs.service.drv'. │ Reason: 1 dependency failed. │ Output paths: │ /nix/store/9ip08kmd4wva6hz29az9sb9cm2lk4zv2-unit-generate-shutdown-ramfs.service │ error: Cannot build '/nix/store/9kmwx5b7prsx2dc4f9myjlljk12jr3l5-system-units.drv'. │ Reason: 1 dependency failed. │ Output paths: │ /nix/store/0v3bz0ycb9g9mwpb20l7jkipwc1absd7-system-units │ error: Cannot build '/nix/store/vbvkzjpf8w4vjb74isnmqg7jqnbaz3r2-etc.drv'. │ Reason: 1 dependency failed. │ Output paths: │ /nix/store/34fi3i0i0cblz2hhmfihmnxlakziy47y-etc │ error: Cannot build '/nix/store/b1w6kxv2yhp4kc9b74934ymhq2wwsp5l-nixos-system-my-server-25.11.20250914.a870b74.drv'. │ Reason: 1 dependency failed. │ Output paths: │ /nix/store/j4w2wv2b5n0v45fpl6nqw75pslc1cawh-nixos-system-my-server-25.11.20250914.a870b74 │ + out= │ │ State: exit status 1 ``` ### Command Used tofu apply -auto-approve ### Target System Cloud server (AWS, DigitalOcean, etc.) ### NixOS Version unstable ### Environment Information - Host OS: - Nix version: - Target architecture: ### Configuration Files ```nix ``` ### Additional Context _No response_
2 条评论