From 872f944743dc5ae200d94ed6aaea5c47f192df8b Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sat, 1 Jan 2022 16:41:35 -0800 Subject: [PATCH] eval.nix: Skip recursive type checking when cross-referencing configs through the nodes argument This makes evaluation faster especially when `nodes` is heavily used in the configuration (like in my auto-meshing setup). This matches the behavior of Morph. --- src/nix/hive/eval.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/nix/hive/eval.nix b/src/nix/hive/eval.nix index 28e4471..e911404 100644 --- a/src/nix/hive/eval.nix +++ b/src/nix/hive/eval.nix @@ -445,13 +445,27 @@ let hive.defaults ] ++ configs ++ (import (npkgs.path + "/nixos/modules/module-list.nix")); specialArgs = hive.meta.specialArgs // { - inherit name nodes; + inherit name; + nodes = uncheckedNodes; modulesPath = npkgs.path + "/nixos/modules"; }; }; nodeNames = filter (name: ! elem name reservedNames) (attrNames hive); + # Used as the `nodes` argument in modules. We skip recursive type checking + # for performance. + uncheckedNodes = listToAttrs (map (name: let + configs = [ + { + _module.check = false; + } + ] ++ configsFor name; + in { + inherit name; + value = evalNode name configs; + }) nodeNames); + # Exported attributes # # Functions are intended to be called with `nix-instantiate --eval --json`