Merge pull request #96641 from zimbatm/data-module-imports

nixos: Data module imports
gstqt5
zimbatm 2020-10-09 17:07:51 +00:00 committed by GitHub
commit d8e4c8e612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -66,7 +66,7 @@ let
stringLength sub substring tail; stringLength sub substring tail;
inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor inherit (trivial) id const pipe concat or and bitAnd bitOr bitXor
bitNot boolToString mergeAttrs flip mapNullable inNixShell min max bitNot boolToString mergeAttrs flip mapNullable inNixShell min max
importJSON warn info showWarnings nixpkgsVersion version mod compare importJSON importTOML warn info showWarnings nixpkgsVersion version mod compare
splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits; splitByAndCompare functionArgs setFunctionArgs isFunction toHexString toBaseDigits;
inherit (fixedPoints) fix fix' converge extends composeExtensions inherit (fixedPoints) fix fix' converge extends composeExtensions
makeExtensible makeExtensibleWithCustomName; makeExtensible makeExtensibleWithCustomName;

View File

@ -875,4 +875,21 @@ rec {
]; ];
}; };
/* Use this function to import a JSON file as NixOS configuration.
importJSON -> path -> attrs
*/
importJSON = file: {
_file = file;
config = lib.importJSON file;
};
/* Use this function to import a TOML file as NixOS configuration.
importTOML -> path -> attrs
*/
importTOML = file: {
_file = file;
config = lib.importTOML file;
};
} }

View File

@ -281,6 +281,12 @@ rec {
importJSON = path: importJSON = path:
builtins.fromJSON (builtins.readFile path); builtins.fromJSON (builtins.readFile path);
/* Reads a TOML file.
Type :: path -> any
*/
importTOML = path:
builtins.fromTOML (builtins.readFile path);
## Warnings ## Warnings