From ae6cce96a29e7e6d901593002b48e16b41e8b247 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 5 Oct 2025 20:14:01 -0400 Subject: [PATCH] Support running arm code on x86. --- nix/configuration/configuration.nix | 1 + nix/configuration/hosts/odo/default.nix | 1 + nix/configuration/hosts/quark/default.nix | 1 + .../roles/emulate_isa/default.nix | 33 +++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 nix/configuration/roles/emulate_isa/default.nix diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 256de92..8139139 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -22,6 +22,7 @@ ./roles/docker ./roles/ecc ./roles/emacs + ./roles/emulate_isa ./roles/firefox ./roles/firewall ./roles/flux diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 5379805..6776c31 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -71,6 +71,7 @@ me.docker.enable = false; me.ecc.enable = false; me.emacs_flavor = "full"; + me.emulate_isa.enable = true; me.firefox.enable = true; me.flux.enable = true; me.gcloud.enable = true; diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix index 09a61c9..25d8df7 100644 --- a/nix/configuration/hosts/quark/default.nix +++ b/nix/configuration/hosts/quark/default.nix @@ -64,6 +64,7 @@ me.docker.enable = false; me.ecc.enable = true; me.emacs_flavor = "full"; + me.emulate_isa.enable = true; me.firefox.enable = true; me.flux.enable = true; me.gcloud.enable = true; diff --git a/nix/configuration/roles/emulate_isa/default.nix b/nix/configuration/roles/emulate_isa/default.nix new file mode 100644 index 0000000..183eb4e --- /dev/null +++ b/nix/configuration/roles/emulate_isa/default.nix @@ -0,0 +1,33 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + emulate_isa.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to enable emulating other CPU architectures."; + }; + }; + + config = lib.mkIf config.me.emulate_isa.enable ( + lib.mkMerge [ + { + boot.binfmt.emulatedSystems = [ + "aarch64-linux" # Raspberry Pi gen 3 + "riscv64-linux" + # TODO: Should "x86_64-linux" be in this list or should this list be dependent on the host CPU? + "armv6l-linux" # Raspberry Pi gen 1 + ]; + } + ] + ); +} +# NOTE: build nixosConfigurations..config.system.build.sdImage