From 767247cc918167d73588c663f8404e7d18b61bf0 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sat, 11 May 2024 12:54:36 -0700 Subject: [PATCH] feat(aya): qemu-aarch64 builder (disabled) `binfmt_misc` does not currently work in containers... --- modules/extern/nixos/nix.nix | 10 ++++++++++ nixos/cross/aarch64.nix | 30 ++++++++++++++++++++++++++++++ systems/aya/nixos.nix | 1 + 3 files changed, 41 insertions(+) create mode 100644 nixos/cross/aarch64.nix diff --git a/modules/extern/nixos/nix.nix b/modules/extern/nixos/nix.nix index b6306dc4..78a0944f 100644 --- a/modules/extern/nixos/nix.nix +++ b/modules/extern/nixos/nix.nix @@ -10,6 +10,7 @@ inherit (gensokyo-zone.lib) unmerged mkAlmostOptionDefault; cfg = config.gensokyo-zone.nix; nixModule = { + lib, gensokyo-zone, nixosConfig, nixosOptions, @@ -17,6 +18,7 @@ ... }: let inherit (gensokyo-zone.lib) unmerged domain; + inherit (lib.modules) mkOptionDefault; inherit (nixosConfig.gensokyo-zone) access; in { options = with lib.types; { @@ -31,6 +33,10 @@ }; builder = { enable = mkEnableOption "aya nixbld remote builder"; + cross = { + aarch64 = mkEnableOption "qemu-aarch64"; + armv7l = mkEnableOption "qemu arm"; + }; domain = mkOption { type = str; default = "nixbld.${domain}"; @@ -98,6 +104,10 @@ }) ]; builder = { + systems = mkMerge [ + (mkIf config.builder.cross.aarch64 (mkOptionDefault [ "aarch64-linux" ])) + (mkIf config.builder.cross.armv7l (mkOptionDefault [ "armv7l-linux" ])) + ]; domain = mkMerge [ (mkIf access.tail.enabled (mkAlmostOptionDefault "nixbld.tail.${domain}")) (mkIf access.local.enable (mkDefault "nixbld.local.${domain}")) diff --git a/nixos/cross/aarch64.nix b/nixos/cross/aarch64.nix new file mode 100644 index 00000000..f8f18e10 --- /dev/null +++ b/nixos/cross/aarch64.nix @@ -0,0 +1,30 @@ +{ pkgs, config, lib, ... }: let + inherit (lib.options) mkEnableOption mkPackageOption; + inherit (lib.modules) mkIf; + cfg = config.boot.binfmt.cross.aarch64; +in { + options = { + boot.binfmt.cross.aarch64 = { + enable = mkEnableOption "qemu-aarch64" // { + default = true; + }; + package = mkPackageOption pkgs "qemu" { }; + armv7l = mkEnableOption "arm.cachix.org"; + }; + }; + + config = { + boot.binfmt = { + emulatedSystems = mkIf cfg.enable [ "aarch64-linux" ]; + registrations.aarch64-linux = mkIf cfg.enable { + interpreter = "${cfg.package}/bin/qemu-aarch64"; + wrapInterpreterInShell = false; + }; + }; + + nix.settings = mkIf cfg.armv7l { + substituters = [ "https://arm.cachix.org/" ]; + trusted-public-keys = [ "arm.cachix.org-1:5BZ2kjoL1q6nWhlnrbAl+G7ThY7+HaBRD9PZzqZkbnM=" ]; + }; + }; +} diff --git a/systems/aya/nixos.nix b/systems/aya/nixos.nix index 992f213c..6e4d4465 100644 --- a/systems/aya/nixos.nix +++ b/systems/aya/nixos.nix @@ -6,6 +6,7 @@ nixos.base nixos.reisen-ct nixos.nixbld + #nixos.cross.aarch64 nixos.tailscale nixos.github-runner.zone nixos.minecraft.bedrock