linux: parse configfile at eval-time if possible
Users might call `manualConfig` with a path presented at evaluation time, in which case they shouldn't need to set `allowImportFromDerivation` to true, since IFD wouldn't be needed.
This commit is contained in:
parent
294574264e
commit
35956ce40e
@ -32,16 +32,24 @@ let
|
|||||||
|
|
||||||
readConfig =
|
readConfig =
|
||||||
configfile:
|
configfile:
|
||||||
import
|
lib.listToAttrs (
|
||||||
(runCommand "config.nix" { } ''
|
map
|
||||||
echo "{" > "$out"
|
(
|
||||||
while IFS='=' read key val; do
|
line:
|
||||||
[ "x''${key#CONFIG_}" != "x$key" ] || continue
|
let
|
||||||
no_firstquote="''${val#\"}";
|
match = lib.match "(.*)=\"?(.*)\"?" line;
|
||||||
echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out"
|
in
|
||||||
done < "${configfile}"
|
{
|
||||||
echo "}" >> $out
|
name = lib.elemAt match 0;
|
||||||
'').outPath;
|
value = lib.elemAt match 1;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
lib.filter (line: !(lib.hasPrefix "#" line || line == "")) (
|
||||||
|
lib.splitString "\n" (builtins.readFile configfile)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
in
|
in
|
||||||
lib.makeOverridable (
|
lib.makeOverridable (
|
||||||
{
|
{
|
||||||
@ -64,7 +72,9 @@ lib.makeOverridable (
|
|||||||
configfile,
|
configfile,
|
||||||
# Manually specified nixexpr representing the config
|
# Manually specified nixexpr representing the config
|
||||||
# If unspecified, this will be autodetected from the .config
|
# If unspecified, this will be autodetected from the .config
|
||||||
config ? lib.optionalAttrs allowImportFromDerivation (readConfig configfile),
|
config ? lib.optionalAttrs (builtins.isPath configfile || allowImportFromDerivation) (
|
||||||
|
readConfig configfile
|
||||||
|
),
|
||||||
# Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is
|
# Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is
|
||||||
# automatically extended with extra per-version and per-config values.
|
# automatically extended with extra per-version and per-config values.
|
||||||
randstructSeed ? "",
|
randstructSeed ? "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user