[Boot] Improve kernel cmdline generator

This commit is contained in:
Antoine Viallon 2022-04-08 01:49:12 +02:00
parent 7e26d25066
commit 2f4e012e0c
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -25,9 +25,16 @@ let
toCmdlineValue = v: if (isBool v) then (if v then "y" else "n") toCmdlineValue = v: if (isBool v) then (if v then "y" else "n")
else if (isInt v || isString v) then (toString v) else if (isInt v || isString v) then (toString v)
else if (isList v) then (concatStringsSep "," v)
else throw "Invalid value for kernel cmdline parameter"; else throw "Invalid value for kernel cmdline parameter";
toCmdlineList = set: mapAttrsToList (key: value: "${key}=${toCmdlineValue value}") set; toCmdlineList = set: mapAttrsToList
(key: value:
if (value == "") then
"${key}"
else
"${key}=${toCmdlineValue value}"
) set;
cfg = config.aviallon.boot; cfg = config.aviallon.boot;
generalCfg = config.aviallon.general; generalCfg = config.aviallon.general;
@ -70,7 +77,7 @@ in
description = "Kernel params as attributes (instead of list)"; description = "Kernel params as attributes (instead of list)";
default = { }; default = { };
example = { "i915.fastboot" = true; }; example = { "i915.fastboot" = true; };
type = types.attrsOf (types.oneOf [ types.bool types.int types.str ]); type = types.attrsOf (types.oneOf [ types.bool types.int types.str (types.listOf types.str) ]);
}; };
}; };