diff --git a/nixos/tests/kernel-generic.nix b/nixos/tests/kernel-generic.nix index 5993d0e6ab78..391a93e36981 100644 --- a/nixos/tests/kernel-generic.nix +++ b/nixos/tests/kernel-generic.nix @@ -6,10 +6,10 @@ with pkgs.lib; let - makeKernelTest = version: linuxPackages: (import ./make-test-python.nix ({ pkgs, ... }: { - name = "kernel-${version}"; + testsForLinuxPackages = linuxPackages: (import ./make-test-python.nix ({ pkgs, ... }: { + name = "kernel-${linuxPackages.kernel.version}"; meta = with pkgs.lib.maintainers; { - maintainers = [ nequissimus ]; + maintainers = [ nequissimus atemu ]; }; machine = { ... }: @@ -23,20 +23,26 @@ let assert "${linuxPackages.kernel.modDirVersion}" in machine.succeed("uname -a") ''; }) args); -in -with pkgs; { - linux_4_4 = makeKernelTest "4.4" linuxPackages_4_4; - linux_4_9 = makeKernelTest "4.9" linuxPackages_4_9; - linux_4_14 = makeKernelTest "4.14" linuxPackages_4_14; - linux_4_19 = makeKernelTest "4.19" linuxPackages_4_19; - linux_5_4 = makeKernelTest "5.4" linuxPackages_5_4; - linux_5_10 = makeKernelTest "5.10" linuxPackages_5_10; - linux_5_13 = makeKernelTest "5.13" linuxPackages_5_13; + kernels = { + inherit (pkgs) + linuxPackages_4_4 + linuxPackages_4_9 + linuxPackages_4_14 + linuxPackages_4_19 + linuxPackages_5_4 + linuxPackages_5_10 + linuxPackages_5_13 - linux_hardened_4_14 = makeKernelTest "4.14" linuxPackages_4_14_hardened; - linux_hardened_4_19 = makeKernelTest "4.19" linuxPackages_4_19_hardened; - linux_hardened_5_4 = makeKernelTest "5.4" linuxPackages_5_4_hardened; - linux_hardened_5_10 = makeKernelTest "5.10" linuxPackages_5_10_hardened; + linuxPackages_4_14_hardened + linuxPackages_4_19_hardened + linuxPackages_5_4_hardened + linuxPackages_5_10_hardened - linux_testing = makeKernelTest "testing" linuxPackages_testing; + linuxPackages_testing; + }; + +in mapAttrs (_: lP: testsForLinuxPackages lP) kernels // { + inherit testsForLinuxPackages; + + testsForKernel = kernel: testsForLinuxPackages (pkgs.linuxPackagesFor kernel); } diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 7f4f0f2d6bb6..7f2a97d868ed 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -58,6 +58,7 @@ , preferBuiltin ? stdenv.hostPlatform.linux-kernel.preferBuiltin or false , kernelArch ? stdenv.hostPlatform.linuxArch , kernelTests ? [] +, nixosTests , ... }: @@ -192,7 +193,16 @@ let kernelOlder = lib.versionOlder version; kernelAtLeast = lib.versionAtLeast version; passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]); - tests = kernelTests; + tests = let + overridableKernel = finalKernel // { + override = args: + lib.warn ( + "override is stubbed for NixOS kernel tests, not applying changes these arguments: " + + toString (lib.attrNames (if lib.isAttrs args then args else args {})) + ) overridableKernel; + }; + in [ (nixosTests.kernel-generic.testsForKernel overridableKernel) ] ++ kernelTests; }; -in lib.extendDerivation true passthru kernel + finalKernel = lib.extendDerivation true passthru kernel; +in finalKernel diff --git a/pkgs/os-specific/linux/kernel/linux-4.14.nix b/pkgs/os-specific/linux/kernel/linux-4.14.nix index 6f72d35fcf4b..c2c0078dc60c 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.14.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.14.nix @@ -15,6 +15,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; sha256 = "0x554dck5f78ljknwahjvf49952s1w0zja3yh4vfz6lmf6hvzq5n"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_4_14 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-4.19.nix b/pkgs/os-specific/linux/kernel/linux-4.19.nix index 62de063c29da..8b739463a2d0 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.19.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.19.nix @@ -15,6 +15,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; sha256 = "1rcx99sz4fgr2d138i92dw2vfplnqgys58hxywgmjb56c83l3qy4"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_4_19 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-4.4.nix b/pkgs/os-specific/linux/kernel/linux-4.4.nix index 146ff42c060e..f1f26e601d33 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.4.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.4.nix @@ -9,6 +9,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; sha256 = "12grr2vc2mcvy7k8w1apqs9mhfg0lvz6mrpksym234m4n5yy48ng"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_4_4 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-4.9.nix b/pkgs/os-specific/linux/kernel/linux-4.9.nix index bbc5a58ec0cc..daafa08def49 100644 --- a/pkgs/os-specific/linux/kernel/linux-4.9.nix +++ b/pkgs/os-specific/linux/kernel/linux-4.9.nix @@ -9,6 +9,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; sha256 = "0am9qg9j18j4fc5zi6bk1g0mi8dp31pl62wlihxhhkc5yspzrna3"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_4_9 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-5.10.nix b/pkgs/os-specific/linux/kernel/linux-5.10.nix index 292691fea2ac..cde04b146928 100644 --- a/pkgs/os-specific/linux/kernel/linux-5.10.nix +++ b/pkgs/os-specific/linux/kernel/linux-5.10.nix @@ -15,6 +15,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; sha256 = "13gpamqj0shvad4nd9v11iv8qdfbjgb242nbvcim2z3c7xszfvv9"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_5_10 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-5.13.nix b/pkgs/os-specific/linux/kernel/linux-5.13.nix index dbbd4a9e8763..e7f9aaede27b 100644 --- a/pkgs/os-specific/linux/kernel/linux-5.13.nix +++ b/pkgs/os-specific/linux/kernel/linux-5.13.nix @@ -15,6 +15,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; sha256 = "0948w1zc2gqnl8x60chjqngfzdi0kcxm12i1nx3nx4ksiwj5vc98"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_5_13 ]; } // (args.argsOverride or { })) diff --git a/pkgs/os-specific/linux/kernel/linux-5.4.nix b/pkgs/os-specific/linux/kernel/linux-5.4.nix index 7cf9473451c2..cc86b1a991be 100644 --- a/pkgs/os-specific/linux/kernel/linux-5.4.nix +++ b/pkgs/os-specific/linux/kernel/linux-5.4.nix @@ -15,6 +15,4 @@ buildLinux (args // rec { url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; sha256 = "0l8l4cg04p5vx890jm45r35js1v0nljd0lp5qwkvlr45jql5fy4r"; }; - - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_5_4 ]; } // (args.argsOverride or {})) diff --git a/pkgs/os-specific/linux/kernel/linux-testing.nix b/pkgs/os-specific/linux/kernel/linux-testing.nix index 4e2ef7b4652e..2caea08416ea 100644 --- a/pkgs/os-specific/linux/kernel/linux-testing.nix +++ b/pkgs/os-specific/linux/kernel/linux-testing.nix @@ -14,8 +14,6 @@ buildLinux (args // rec { sha256 = "sha256-PunFd6tOsmrsPItp2QX4TEVxHnvvi1BMSwWio/DTlMU="; }; - kernelTests = args.kernelTests or [ nixosTests.kernel-generic.linux_testing ]; - # Should the testing kernels ever be built on Hydra? extraMeta.hydraPlatforms = [];