1 # make sure to use NON EXISTING kernel settings else they may conflict with
9 lts_kernel = pkgs.linuxPackages.kernel;
11 # to see the result once the module transformed the lose structured config
12 getConfig = structuredConfig:
13 (lts_kernel.override {
14 structuredExtraConfig = structuredConfig;
15 }).configfile.structuredConfig;
17 mandatoryVsOptionalConfig = mkMerge [
18 { NIXOS_FAKE_USB_DEBUG = yes;}
19 { NIXOS_FAKE_USB_DEBUG = option yes; }
22 freeformConfig = mkMerge [
23 { NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "32"; } # same as default, won't trigger any error
24 { NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "64"; } # will trigger an error but the message is not great:
27 mkDefaultWorksConfig = mkMerge [
28 { "NIXOS_TEST_BOOLEAN" = yes; }
29 { "NIXOS_TEST_BOOLEAN" = lib.mkDefault no; }
32 allOptionalRemainOptional = mkMerge [
33 { NIXOS_FAKE_USB_DEBUG = option yes;}
34 { NIXOS_FAKE_USB_DEBUG = option yes;}
39 expr = (getConfig { NIXOS_FAKE_USB_DEBUG = yes;}).NIXOS_FAKE_USB_DEBUG;
40 expected = { tristate = "y"; optional = false; freeform = null; };
43 # mandatory flag should win over optional
44 testMandatoryCheck = {
45 expr = (getConfig mandatoryVsOptionalConfig).NIXOS_FAKE_USB_DEBUG.optional;
50 expr = (getConfig mkDefaultWorksConfig)."NIXOS_TEST_BOOLEAN".tristate;
54 testAllOptionalRemainOptional = {
55 expr = (getConfig allOptionalRemainOptional)."NIXOS_FAKE_USB_DEBUG".optional;
59 # check that freeform options are unique
61 # > The option `settings.NIXOS_FAKE_MMC_BLOCK_MINORS.freeform' has conflicting definitions, in `<unknown-file>' and `<unknown-file>'
63 res = builtins.tryEval ( (getConfig freeformConfig).NIXOS_FAKE_MMC_BLOCK_MINORS.freeform);
72 lib.optional (failures != [])
73 (throw "The following kernel unit tests failed: ${lib.generators.toPretty {} failures}")