about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <sternenseemann@systemli.org>2024-09-05 22:58:39 +0200
committersternenseemann <sternenseemann@systemli.org>2024-09-05 22:58:39 +0200
commit24248d01d35f305b8d42c8861337cc98857d2ff3 (patch)
tree30d40de62be781f70f572d93b361fd2768740d1d
parent86160b149a771ca9531ac2e37904e01693f5888f (diff)
modules/tests: use default linux version wg-quick test if not latest
We could of course introspect pkgs.nixosTests to find out which tests
are actually available, but this would probably make evaluation even
more expensive.
-rw-r--r--modules/core/tests.nix12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/core/tests.nix b/modules/core/tests.nix
index b1078758..96e4169e 100644
--- a/modules/core/tests.nix
+++ b/modules/core/tests.nix
@@ -3,9 +3,15 @@
 let
   inherit (lib) any elem;
 
-  # TODO(@sternenseemann): tie this to boot.kernelPackages.kernel.version again
-  # after https://github.com/NixOS/nixpkgs/pull/338632 hits the channels.
-  wgTestSuffix = "linux-latest";
+  isLatestKernel = config.boot.kernelPackages.kernel.version
+                == pkgs.linuxPackages_latest.kernel.version;
+  # Assumes nixpkgs has a test for the latest and default kernel
+  wgTestSuffix = "linux-" + (
+    if isLatestKernel
+    then "latest"
+    else lib.replaceStrings [ "." ] [ "_" ]
+      (lib.versions.majorMinor pkgs.linuxPackages.kernel.version)
+  );
 
   mkTest = attrs: if attrs.check then attrs.paths or [ attrs.path ] else [];