# Deploy NixOS configurations on other Machines

**URL:** https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940
**Category:** Help
**Created:** [November 2, 2022, 3:25pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940 "2022-11-02T15:25:38Z")
**Posts on this page:** 12
**Page:** 2

<div class="post-metadata">

### Author: ![ghostbuster91](https://discourse.nixos.org/user_avatar/discourse.nixos.org/ghostbuster91/32/9258_2.png) [@ghostbuster91](https://discourse.nixos.org/u/ghostbuster91)
#### Post date: [December 22, 2023, 9:09am UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/21 "2023-12-22T09:09:02Z")

</div>

it doesn’t work for me when the target architecture is different than the host architecture that calls the command.

This one works as it targets the same arch - x86\_64-linux

```auto
nixos-rebuild switch --flake .#deckard --target-host deckard --use-remote-sudo

```

Now, a similar command but I am targeting an aarch64 machine and using nixbuild builder (this one also works):

```auto
nixos-rebuild build --max-jobs 0 --build-host "eu.nixbuild.net" --target-host surfer --use-remote-sudo --flake .#surfer

```

However if I replace `build` with `switch` the command fails:

```auto
$ nixos-rebuild switch --max-jobs 0 --build-host "eu.nixbuild.net" --target-host surfer --use-remote-sudo --flake .#surfer
/nix/store/5yksn2xwy3aif5pxz353i64i0fwvj5gp-nixos-rebuild/bin/nixos-rebuild: line 382: /nix/store/zlh7zakv2fn97fb4q2y6abzsdp6jflfd-coreutils-9.3/bin/mktemp: cannot execute binary file: Exec format error

```

Any idea what could be wrong?

---

<div class="post-metadata">

### Author: ![Atemu](https://discourse.nixos.org/user_avatar/discourse.nixos.org/atemu/32/10383_2.png) [@Atemu](https://discourse.nixos.org/u/Atemu)
#### Post date: [December 22, 2023, 9:29am UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/22 "2023-12-22T09:29:34Z")

</div>

Did you declare the `hostSystem` in `surfer`’s config?

---

<div class="post-metadata">

### Author: ![ghostbuster91](https://discourse.nixos.org/user_avatar/discourse.nixos.org/ghostbuster91/32/9258_2.png) [@ghostbuster91](https://discourse.nixos.org/u/ghostbuster91)
#### Post date: [December 22, 2023, 10:19am UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/23 "2023-12-22T10:19:06Z")

</div>

No, I only have `system = "aarch64-linux`. I thought that `hostSystem` property is only required when doing some cross-compilation, isn’t it?

I kind of solved my problem, i.e. I found the correct set of flags that work but I would like to understand what is going on.

The correct command looks as follow:

```auto
nixos-rebuild --max-jobs 0 --builders "ssh://eu.nixbuild.net aarch64-linux - 100 1" --flake .#surfer --target-host surfer --fast --use-remote-sudo switch

```

what is interesting is that the documentation says:

```auto
--fast
Equivalent to --no-build-nix. This option is useful if you call nixos-rebuild frequently (e.g. if you’re hacking on a NixOS module).

```

where:

```auto
--no-build-nix
Normally, nixos-rebuild first builds the nixUnstable attribute in Nixpkgs, and uses the resulting instance of the Nix package manager to build the new system configuration. This is necessary if the NixOS modules use features not provided by the currently installed version of Nix. This option disables building a new Nix.

```

However running it with `--no-build-nix` instead of `--fast` fails as before:

```auto
 nixos-rebuild --no-build-nix --max-jobs 0 --builders "ssh://eu.nixbuild.net aarch64-linux - 100 1" --flake .#surfer --target-host surfer switch
/nix/store/5yksn2xwy3aif5pxz353i64i0fwvj5gp-nixos-rebuild/bin/nixos-rebuild: line 382: /nix/store/zlh7zakv2fn97fb4q2y6abzsdp6jflfd-coreutils-9.3/bin/mktemp: cannot execute binary file: Exec format error

```

---

<div class="post-metadata">

### Author: ![rei](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/ecd19e/32.png) [@rei](https://discourse.nixos.org/u/rei)
#### Post date: [June 17, 2024, 12:33pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/24 "2024-06-17T12:33:14Z")

</div>

What was this pointing at before? Right now the line is just a closing bracket.

---

<div class="post-metadata">

### Author: ![Nebucatnetzer](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nebucatnetzer/32/5770_2.png) [@Nebucatnetzer](https://discourse.nixos.org/u/Nebucatnetzer)
#### Post date: [June 17, 2024, 12:45pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/25 "2024-06-17T12:45:12Z")

</div>

Right, forget to make it a permalink. It would be this line here: [nixos/systems/gwyn/default.nix at dac50a1ab18bbf5628a6bcac96902d70da84dcb7 · Nebucatnetzer/nixos · GitHub](https://github.com/Nebucatnetzer/nixos/tree/dac50a1ab18bbf5628a6bcac96902d70da84dcb7/systems/gwyn/default.nix#L39)

---

<div class="post-metadata">

### Author: ![rei](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/r/ecd19e/32.png) [@rei](https://discourse.nixos.org/u/rei)
#### Post date: [June 17, 2024, 1:06pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/26 "2024-06-17T13:06:35Z")

</div>

Thanks! Of course, you need to be able to build on your own machine.

---

<div class="post-metadata">

### Author: ![clamydo](https://discourse.nixos.org/user_avatar/discourse.nixos.org/clamydo/32/6748_2.png) [@clamydo](https://discourse.nixos.org/u/clamydo)
#### Post date: [October 17, 2024, 4:58pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/27 "2024-10-17T16:58:27Z")

</div>

When `--build-host myremote` is given, what channel (nixos version) is used? The local or the remote one?

---

<div class="post-metadata">

### Author: ![Atemu](https://discourse.nixos.org/user_avatar/discourse.nixos.org/atemu/32/10383_2.png) [@Atemu](https://discourse.nixos.org/u/Atemu)
#### Post date: [October 17, 2024, 11:21pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/28 "2024-10-17T23:21:51Z")

</div>

Eval happens locally on the machine running nixos-rebuild, so that machine’s channel.

---

<div class="post-metadata">

### Author: ![clamydo](https://discourse.nixos.org/user_avatar/discourse.nixos.org/clamydo/32/6748_2.png) [@clamydo](https://discourse.nixos.org/u/clamydo)
#### Post date: [October 18, 2024, 5:15am UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/29 "2024-10-18T05:15:33Z")

</div>

Thx. Well, that can be annoying when I have auto update enabled on the remote host and the remote channel is more up to date than the local one.

Can I maintain a local channel just for the remote build eval independent from the channel used for my local configuration?

---

<div class="post-metadata">

### Author: ![Atemu](https://discourse.nixos.org/user_avatar/discourse.nixos.org/atemu/32/10383_2.png) [@Atemu](https://discourse.nixos.org/u/Atemu)
#### Post date: [October 18, 2024, 6:05am UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/30 "2024-10-18T06:05:24Z")

</div>

> [@clamydo](#):
>
> Thx. Well, that can be annoying when I have auto update enabled on the remote host and the channel remote channel is more up to date than the local one.

I don’t see an obvious solution to this unfortunately.

> [@clamydo](#):
>
> Can I maintain a local channel just for the remote build eval independent from the channel used for my local configuration?

Sure. You’d have to pass `-I nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs-for-machine` to `nixos-rebuild` every time though.

---

<div class="post-metadata">

### Author: ![rcambrj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rcambrj/32/28232_2.png) [@rcambrj](https://discourse.nixos.org/u/rcambrj)
#### Post date: [January 20, 2025, 7:09pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/31 "2025-01-20T19:09:41Z")

</div>

I was getting this error while doing the same thing on a Github runner (`x86_64-linux` building for `aarch64-linux`):

```auto
bin/mktemp: cannot execute binary file: Exec format error

```

…and of course changing `boot.binfmt.emulatedSystems = ["aarch64-linux"];` in a Github runner is impractical, but it turns out that with QEMU installed and `extra-platforms` set, it works for me:

```auto
      - name: Install QEMU
        uses: docker/setup-qemu-action@v3

      - name: Install nix
        uses: cachix/install-nix-action@v27
        with:
          enable_kvm: true
          extra_nix_config: |
            system-features = kvm
            extra-platforms = aarch64-linux

```

Hope this helps those who come next.

---

<div class="post-metadata">

### Author: ![onnimonni](https://discourse.nixos.org/user_avatar/discourse.nixos.org/onnimonni/32/28273_2.png) [@onnimonni](https://discourse.nixos.org/u/onnimonni)
#### Post date: [January 30, 2025, 9:36pm UTC](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940/32 "2025-01-30T21:36:49Z")

</div>

Hey,

Just wanted to let you know that I was also getting the following error when running `nixos-rebuild` from Apple silicon `aarch64-darwin` with virtual `x86_64-linux` capable builder:

```auto
/nix/.../coreutils-9.5/bin/mktemp: cannot execute binary file: Exec format error

```

But when I also added `--fast` flag for the `nixos-rebuild` command this started to work for me 👍

[Previous page](https://discourse.nixos.org/t/deploy-nixos-configurations-on-other-machines/22940.md?page=1)
