diff options
author | Silvan Mosberger <contact@infinisil.com> | 2023-11-21 01:35:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-21 01:35:11 +0100 |
commit | 6361b223707b8010f5699da7012710395390db76 (patch) | |
tree | 5df5992e7d441493333096638a4414205e22fef5 /pkgs | |
parent | 5d80334f66a180a062b35cbfa8c22f626bcd7127 (diff) | |
parent | ca97497bfdd7adf39759f785845d60cefc165027 (diff) |
Merge pull request #267048 from narang99/hariom/257748/check-by-name-msg
fix long error messages in nix-instantiate
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/default.nix | 9 | ||||
-rw-r--r-- | pkgs/test/nixpkgs-check-by-name/src/eval.rs | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/default.nix b/pkgs/test/nixpkgs-check-by-name/default.nix index 0d4e2fcc48a78..fc24b1fd33982 100644 --- a/pkgs/test/nixpkgs-check-by-name/default.nix +++ b/pkgs/test/nixpkgs-check-by-name/default.nix @@ -5,8 +5,10 @@ rustfmt, clippy, mkShell, + makeWrapper, }: let + runtimeExprPath = ./src/eval.nix; package = rustPlatform.buildRustPackage { name = "nixpkgs-check-by-name"; @@ -16,7 +18,9 @@ let nix rustfmt clippy + makeWrapper ]; + env.NIX_CHECK_BY_NAME_EXPR_PATH = "${runtimeExprPath}"; # Needed to make Nix evaluation work inside the nix build preCheck = '' export TEST_ROOT=$(pwd)/test-tmp @@ -34,7 +38,12 @@ let cargo fmt --check cargo clippy -- -D warnings ''; + postInstall = '' + wrapProgram $out/bin/nixpkgs-check-by-name \ + --set NIX_CHECK_BY_NAME_EXPR_PATH "$NIX_CHECK_BY_NAME_EXPR_PATH" + ''; passthru.shell = mkShell { + env.NIX_CHECK_BY_NAME_EXPR_PATH = toString runtimeExprPath; inputsFrom = [ package ]; }; }; diff --git a/pkgs/test/nixpkgs-check-by-name/src/eval.rs b/pkgs/test/nixpkgs-check-by-name/src/eval.rs index e4f986748b4f4..161d013374e7f 100644 --- a/pkgs/test/nixpkgs-check-by-name/src/eval.rs +++ b/pkgs/test/nixpkgs-check-by-name/src/eval.rs @@ -35,8 +35,6 @@ enum AttributeVariant { Other, } -const EXPR: &str = include_str!("eval.nix"); - /// Check that the Nixpkgs attribute values corresponding to the packages in pkgs/by-name are /// of the form `callPackage <package_file> { ... }`. /// See the `eval.nix` file for how this is achieved on the Nix side @@ -60,9 +58,10 @@ pub fn check_values( attrs_file_path.display() ))?; + let expr_path = std::env::var("NIX_CHECK_BY_NAME_EXPR_PATH") + .context("Could not get environment variable NIX_CHECK_BY_NAME_EXPR_PATH")?; // With restrict-eval, only paths in NIX_PATH can be accessed, so we explicitly specify the // ones needed needed - let mut command = process::Command::new("nix-instantiate"); command // Inherit stderr so that error messages always get shown @@ -76,8 +75,6 @@ pub fn check_values( "--readonly-mode", "--restrict-eval", "--show-trace", - "--expr", - EXPR, ]) // Pass the path to the attrs_file as an argument and add it to the NIX_PATH so it can be // accessed in restrict-eval mode @@ -96,6 +93,8 @@ pub fn check_values( command.arg("-I"); command.arg(path); } + command.args(["-I", &expr_path]); + command.arg(expr_path); let result = command .output() |