Srid said:
The linux-builder in nix-darwin would streamline it even further,
https://nixcademy.com/2024/02/12/macos-linux-builder/
However, it:
- does not support rosetta
- does not build packages with IFD
Turns out I'm wrong here re: IFD.
This won't work:
nix --option system aarch64-linux build -L
But this will:
nix build -L .#packages.aarch64-linux.default
cf. https://github.com/NixOS/nixpkgs/issues/39664
That said, I still couldn't get x86_64-linux builds to work. It requires improving the nix-darwin linux builder to take arbitrary configuration, so I can set a binfmt.emulatedSystems
.
A message was moved here from #nixos > Home CI machine (portable) by Srid.
What will it take to merge all these PRs?
Using https://github.com/LnL7/nix-darwin/pull/878
I can get x86 packages to build via linux-builder. The config,
# To build Linux derivations whilst on macOS.
nix.linux-builder = {
enable = true;
systems = [
"x86_64-linux"
"aarch64-linux"
];
config = { lib, ... }: {
boot.binfmt.emulatedSystems = [ "x86_64-linux" ];
virtualisation = {
# Larger linux-builder cores, ram, and disk.
cores = 6;
memorySize = lib.mkForce (1024 * 16);
diskSize = lib.mkForce (1024 * 1); # In MB.
};
};
};
Incidentally, I gain the impression that the linux-builder is draining my battery faster than the parallels VM.
Timing for a) macOS native, b) arm linux, c) x86 emulation when building haskell-template. I'll do a thorough benchmark latter.
Got something working on macOS. Along with https://github.com/srid/nixci/pull/39 I can now build Emanote (PR) on arm Linux and mac, using the builders hosted on the same host (macbook),
jobs:
nix:
runs-on: self-hosted
strategy:
matrix:
# TODO: Disablig x86_64-linux for now, as it is causing qemu segfault.
# Fix treefmt check causing qemu segfault: https://nixos.zulipchat.com/#narrow/stream/413948-nixos/topic/QEMU.20internal.20SIGSEGV
system: [aarch64-linux, aarch64-darwin]
steps:
- uses: actions/checkout@v4
- name: Build Nix
run: |
nixci --build-systems "github:nix-systems/${{ matrix.system }}"
Last updated: Nov 15 2024 at 12:33 UTC