about summary refs log tree commit diff
path: root/nixos/modules/image
diff options
context:
space:
mode:
authornikstur <nikstur@outlook.com>2024-04-04 17:38:07 +0200
committernikstur <nikstur@outlook.com>2024-04-04 17:38:08 +0200
commitb9fe4b1e26e573089ae23a458151eb6898f2b011 (patch)
tree7816f4a58de4960fb5585ed06acc22a6277bd687 /nixos/modules/image
parentf819df36af7518fbc732533012c9436bc244c589 (diff)
nixos/repart-image: supply explicit --architecture to repart
This enables cross-compiling images.
Diffstat (limited to 'nixos/modules/image')
-rw-r--r--nixos/modules/image/repart-image.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/nixos/modules/image/repart-image.nix b/nixos/modules/image/repart-image.nix
index 83e766268cf04..59d5fc26efe9b 100644
--- a/nixos/modules/image/repart-image.nix
+++ b/nixos/modules/image/repart-image.nix
@@ -41,6 +41,25 @@
 }:
 
 let
+  systemdArch = let
+    inherit (stdenvNoCC) hostPlatform;
+  in
+    if hostPlatform.isAarch32 then "arm"
+    else if hostPlatform.isAarch64 then "arm64"
+    else if hostPlatform.isx86_32 then "x86"
+    else if hostPlatform.isx86_64 then "x86-64"
+    else if hostPlatform.isMips32 then "mips-le"
+    else if hostPlatform.isMips64 then "mips64-le"
+    else if hostPlatform.isPower then "ppc"
+    else if hostPlatform.isPower64 then "ppc64"
+    else if hostPlatform.isRiscV32 then "riscv32"
+    else if hostPlatform.isRiscV64 then "riscv64"
+    else if hostPlatform.isS390 then "s390"
+    else if hostPlatform.isS390x then "s390x"
+    else if hostPlatform.isLoongArch64 then "loongarch64"
+    else if hostPlatform.isAlpha then "alpha"
+    else hostPlatform.parsed.cpu.name;
+
   amendRepartDefinitions = runCommand "amend-repart-definitions.py"
     {
       # TODO: ruff does not splice properly in nativeBuildInputs
@@ -99,6 +118,7 @@ in
   finalRepartDefinitions = "repart.d";
 
   systemdRepartFlags = [
+    "--architecture=${systemdArch}"
     "--dry-run=no"
     "--size=auto"
     "--seed=${seed}"