Commit 9c9848be authored by dramforever's avatar dramforever
Browse files

linuxManualConfig: Handle only y and m in readConfig

Parsing Linux config files in Nix in full is complicated, primarily due
to string values. Currently, the regular expression used is fragile and
breaks with string values containing equal signs or (escaped) quotes.

The primary use of these options is system.requiredKernelConfig, which
only really needs to track "yes" and "module". Therefore, only parse
those.

This is a breaking change. However, this is a very obscure corner of
linuxManualConfig and should have few if any affected users.
parent 12bd2301
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
@@ -32,24 +32,18 @@ let

  readConfig =
    configfile:
    lib.listToAttrs (
      map
        (
    let
      matchLine =
        line:
        let
            match = lib.match "(.*)=\"?(.*)\"?" line;
          match = lib.match "(CONFIG_[^=]+)=([ym])" line;
        in
          {
        lib.optional (match != null) {
          name = lib.elemAt match 0;
          value = lib.elemAt match 1;
          }
        )
        (
          lib.filter (line: !(lib.hasPrefix "#" line || line == "")) (
            lib.splitString "\n" (builtins.readFile configfile)
          )
        )
    );
        };
    in
    lib.listToAttrs (lib.concatMap matchLine (lib.splitString "\n" (builtins.readFile configfile)));
in
lib.makeOverridable (
  {