lib: allow to import JSON and TOML files

The vision here is that configuration tools can generate .json or .toml
files, which can be plugged into an existing configuration.

Eg:

    { lib, ... }:
    {
      imports = [
        (lib.modules.importJSON ./hardware-configuration.json)
      ];
    }
This commit is contained in:
zimbatm 2020-09-12 16:33:56 +02:00
parent 947a7d33f9
commit 035627dff2
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7

View file

@ -869,4 +869,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;
};
}