2 # nix-instantiate --eval --strict . -A tests.kernel-config
4 # make sure to use NON EXISTING kernel settings else they may conflict with
12 lts_kernel = pkgs.linuxPackages.kernel;
14 # to see the result once the module transformed the lose structured config
15 getConfig = structuredConfig:
16 (lts_kernel.override {
17 structuredExtraConfig = structuredConfig;
18 }).configfile.structuredConfig;
20 mandatoryVsOptionalConfig = mkMerge [
21 { NIXOS_FAKE_USB_DEBUG = yes;}
22 { NIXOS_FAKE_USB_DEBUG = option yes; }
25 freeformConfig = mkMerge [
26 { NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "32"; } # same as default, won't trigger any error
27 { NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "64"; } # will trigger an error but the message is not great:
30 mkDefaultWorksConfig = mkMerge [
31 { "NIXOS_TEST_BOOLEAN" = yes; }
32 { "NIXOS_TEST_BOOLEAN" = lib.mkDefault no; }
35 allOptionalRemainOptional = mkMerge [
36 { NIXOS_FAKE_USB_DEBUG = option yes;}
37 { NIXOS_FAKE_USB_DEBUG = option yes;}
43 expr = (getConfig { NIXOS_FAKE_USB_DEBUG = yes;}).NIXOS_FAKE_USB_DEBUG;
44 expected = { tristate = "y"; optional = false; freeform = null; };
47 # mandatory flag should win over optional
48 testMandatoryCheck = {
49 expr = (getConfig mandatoryVsOptionalConfig).NIXOS_FAKE_USB_DEBUG.optional;
54 expr = (getConfig mkDefaultWorksConfig)."NIXOS_TEST_BOOLEAN".tristate;
58 testAllOptionalRemainOptional = {
59 expr = (getConfig allOptionalRemainOptional)."NIXOS_FAKE_USB_DEBUG".optional;
63 # check that freeform options are unique
65 # > The option `settings.NIXOS_FAKE_MMC_BLOCK_MINORS.freeform' has conflicting definitions, in `<unknown-file>' and `<unknown-file>'
67 res = builtins.tryEval ( (getConfig freeformConfig).NIXOS_FAKE_MMC_BLOCK_MINORS.freeform);