aboutsummaryrefslogtreecommitdiff
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2020-09-12 16:33:56 +0200
committerzimbatm <zimbatm@zimbatm.com>2020-09-12 16:37:50 +0200
commit035627dff23c4524345c4013e5e01ca95597452b (patch)
treede27c6c543845a0909596d9e516691ff5a19c1a0 /lib/modules.nix
parent947a7d33f997d8782ae74e2e76fb7645e86b663e (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 '')
-rw-r--r--lib/modules.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 412c7f1df712..e7012742a982 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;
+ };
}