diff options
author | zimbatm <zimbatm@zimbatm.com> | 2020-09-12 16:33:56 +0200 |
---|---|---|
committer | zimbatm <zimbatm@zimbatm.com> | 2020-09-12 16:37:50 +0200 |
commit | 035627dff23c4524345c4013e5e01ca95597452b (patch) | |
tree | de27c6c543845a0909596d9e516691ff5a19c1a0 /lib | |
parent | 947a7d33f997d8782ae74e2e76fb7645e86b663e (diff) |
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) ]; }
Diffstat (limited to 'lib')
-rw-r--r-- | lib/modules.nix | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 412c7f1df712f..e7012742a9821 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -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; + }; } |