From 2b0bafa15557b540e42669b08d35ccfe27a45d0e Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Thu, 9 Jun 2022 11:31:49 -0700 Subject: [PATCH] eval.nix: Restore signature in introspect It was broken in 9bd5e7bb2540664fe1c728c85f80375fe0cbf9fa. --- src/nix/hive/eval.nix | 3 ++- src/nix/hive/tests/mod.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/nix/hive/eval.nix b/src/nix/hive/eval.nix index b094bd8..1595c26 100644 --- a/src/nix/hive/eval.nix +++ b/src/nix/hive/eval.nix @@ -190,7 +190,8 @@ let evalSelectedDrvPaths = names: lib.mapAttrs (k: v: v.drvPath) (evalSelected names); introspect = function: function { - inherit nixpkgs lib; + inherit lib; + pkgs = nixpkgs; nodes = uncheckedNodes; }; diff --git a/src/nix/hive/tests/mod.rs b/src/nix/hive/tests/mod.rs index 49a6b01..5d33b90 100644 --- a/src/nix/hive/tests/mod.rs +++ b/src/nix/hive/tests/mod.rs @@ -519,3 +519,26 @@ fn test_hive_autocall() { } "#); } + +#[test] +fn test_hive_introspect() { + let hive = TempHive::new(r#" + { + test = { ... }: { + boot.isContainer = true; + }; + } + "#); + + let expr = r#" + { pkgs, lib, nodes }: + assert pkgs ? hello; + assert lib ? versionAtLeast; + nodes.test.config.boot.isContainer + "#.to_string(); + + let eval = block_on(hive.introspect(expr, false)) + .unwrap(); + + assert_eq!("true", eval); +}