From 035627dff23c4524345c4013e5e01ca95597452b Mon Sep 17 00:00:00 2001 From: zimbatm Date: Sat, 12 Sep 2020 16:33:56 +0200 Subject: 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) ]; } --- lib/modules.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/modules.nix') diff --git a/lib/modules.nix b/lib/modules.nix index 412c7f1df71..e7012742a98 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; + }; } -- cgit 1.4.1