about summary refs log tree commit diff
path: root/nixos/tests/lxd.nix
diff options
context:
space:
mode:
authorArnout Engelen <arnout@bzzt.net>2022-04-26 12:12:01 +0200
committerArnout Engelen <arnout@bzzt.net>2022-04-26 23:20:10 +0200
commitb779b46dd2f032c70aa2cb72a88f597d6c0f0cff (patch)
treece06941c320f753061d3e8e4210d8a686a34d257 /nixos/tests/lxd.nix
parentbc41b01dd7a9fdffd32d9b03806798797532a5fe (diff)
lxd: fix nixos tests on aarch64
Tested on a RPi3 B+ with a 2g swapfile. On that system the test
still sometimes fails, but I suspect this is because it is really
just not powerful enough for this task.

Fixes #170395
Diffstat (limited to 'nixos/tests/lxd.nix')
-rw-r--r--nixos/tests/lxd.nix39
1 files changed, 35 insertions, 4 deletions
diff --git a/nixos/tests/lxd.nix b/nixos/tests/lxd.nix
index 81b36124cc6b2..162bbcc47e871 100644
--- a/nixos/tests/lxd.nix
+++ b/nixos/tests/lxd.nix
@@ -6,16 +6,47 @@ let
   #
   # I've chosen to import Alpine Linux, because its image is turbo-tiny and,
   # generally, sufficient for our tests.
-  alpine-meta = pkgs.fetchurl {
+  alpine-meta-x86 = pkgs.fetchurl {
     url = "https://tarballs.nixos.org/alpine/3.12/lxd.tar.xz";
     hash = "sha256-1tcKaO9lOkvqfmG/7FMbfAEToAuFy2YMewS8ysBKuLA=";
   };
+  alpine-meta-for = arch: pkgs.stdenv.mkDerivation {
+    name = "alpine-meta-${arch}";
+    version = "3.12";
+    unpackPhase = "true";
+    buildPhase = ''
+      runHook preBuild
 
-  alpine-rootfs = pkgs.fetchurl {
-    url = "https://tarballs.nixos.org/alpine/3.12/rootfs.tar.xz";
-    hash = "sha256-Tba9sSoaiMtQLY45u7p5DMqXTSDgs/763L/SQp0bkCA=";
+      tar xvf ${alpine-meta-x86}
+      sed -i 's/architecture: .*/architecture: ${arch}/' metadata.yaml
+
+      runHook postBuild
+    '';
+    installPhase = ''
+      runHook preInstall
+
+      tar czRf $out *
+
+      runHook postInstall
+    '';
   };
 
+  alpine-meta = {
+    x86_64-linux = alpine-meta-x86;
+    aarch64-linux = alpine-meta-for "aarch64";
+  }.${pkgs.system} or (throw "Unsupported system: ${pkgs.system}");
+
+  alpine-rootfs = {
+    x86_64-linux = pkgs.fetchurl {
+      url = "https://tarballs.nixos.org/alpine/3.12/rootfs.tar.xz";
+      hash = "sha256-Tba9sSoaiMtQLY45u7p5DMqXTSDgs/763L/SQp0bkCA=";
+    };
+    aarch64-linux = pkgs.fetchurl {
+      url = "https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/aarch64/alpine-minirootfs-3.15.4-aarch64.tar.gz";
+      hash = "sha256-9kBz8Jwmo8XepJhTMt5zilCaHHpflnUH7y9+0To39Us=";
+    };
+  }.${pkgs.system} or (throw "Unsupported system: ${pkgs.system}");
+
   lxd-config = pkgs.writeText "config.yaml" ''
     storage_pools:
       - name: default