kernel: Test laziness of certain arguments

+25 -2
+25 -2
pkgs/os-specific/linux/kernel/generic.nix
··· 1 { buildPackages 2 , callPackage 3 , perl 4 , bison ? null 5 , flex ? null ··· 15 , nixosTests 16 }@args': 17 18 lib.makeOverridable ({ # The kernel source tarball. 19 src 20 ··· 241 + toString (lib.attrNames (lib.toFunction args { })) 242 ) overridableKernel; 243 }; 244 - in [ (nixosTests.kernel-generic.passthru.testsForKernel overridableKernel) ] ++ kernelTests; 245 }; 246 247 - }))
··· 1 { buildPackages 2 , callPackage 3 + , emptyFile 4 , perl 5 , bison ? null 6 , flex ? null ··· 16 , nixosTests 17 }@args': 18 19 + let overridableKernel = 20 lib.makeOverridable ({ # The kernel source tarball. 21 src 22 ··· 243 + toString (lib.attrNames (lib.toFunction args { })) 244 ) overridableKernel; 245 }; 246 + versionDoesNotDependOnPatchesEtc = 247 + builtins.seq 248 + (import ./generic.nix args' (args // ( 249 + let explain = attrName: 250 + '' 251 + The ${attrName} attribute must be able to access the kernel.version attribute without an infinite recursion. 252 + That means that the kernel attrset (attrNames) and the kernel.version attribute must not depend on the ${attrName} argument. 253 + The fact that this exception is raised shows that such a dependency does exist. 254 + This is a problem for the configurability of ${attrName} in version-aware logic such as that in NixOS. 255 + Strictness can creep in through optional attributes, or assertions and warnings that run as part of code that shouldn't access what is checked. 256 + ''; 257 + in { 258 + kernelPatches = throw (explain "kernelPatches"); 259 + structuredExtraConfig = throw (explain "structuredExtraConfig"); 260 + modDirVersion = throw (explain "modDirVersion"); 261 + }))).version 262 + emptyFile; 263 + in [ 264 + (nixosTests.kernel-generic.passthru.testsForKernel overridableKernel) 265 + versionDoesNotDependOnPatchesEtc 266 + ] ++ kernelTests; 267 }; 268 269 + })); 270 + in overridableKernel