Skip to content

Commit 70f9d31

Browse files
authored
Merge pull request #285089 from tweag/by-name-syntactic-callPackage
tests.nixpkgs-check-by-name: Syntactic `callPackage` detection and allow new package variants
2 parents 01e3cec + 474e7e7 commit 70f9d31

File tree

21 files changed

+901
-243
lines changed

21 files changed

+901
-243
lines changed

pkgs/test/nixpkgs-check-by-name/Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/test/nixpkgs-check-by-name/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ anyhow = "1.0"
1414
lazy_static = "1.4.0"
1515
colored = "2.0.4"
1616
itertools = "0.11.0"
17+
rowan = "0.15.11"
1718

1819
[dev-dependencies]
1920
temp-env = "0.3.5"
21+
indoc = "2.0.4"

pkgs/test/nixpkgs-check-by-name/src/eval.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ let
7676
CallPackage = {
7777
call_package_variant = value._callPackageVariant;
7878
is_derivation = pkgs.lib.isDerivation value;
79+
location = builtins.unsafeGetAttrPos name pkgs;
7980
};
8081
};
8182

pkgs/test/nixpkgs-check-by-name/src/eval.rs

Lines changed: 216 additions & 130 deletions
Large diffs are not rendered by default.

pkgs/test/nixpkgs-check-by-name/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
use crate::nix_file::NixFileStore;
12
mod eval;
3+
mod nix_file;
24
mod nixpkgs_problem;
35
mod ratchet;
46
mod references;
@@ -116,6 +118,8 @@ pub fn check_nixpkgs<W: io::Write>(
116118
keep_nix_path: bool,
117119
error_writer: &mut W,
118120
) -> validation::Result<ratchet::Nixpkgs> {
121+
let mut nix_file_store = NixFileStore::default();
122+
119123
Ok({
120124
let nixpkgs_path = nixpkgs_path.canonicalize().with_context(|| {
121125
format!(
@@ -132,9 +136,9 @@ pub fn check_nixpkgs<W: io::Write>(
132136
)?;
133137
Success(ratchet::Nixpkgs::default())
134138
} else {
135-
check_structure(&nixpkgs_path)?.result_map(|package_names|
139+
check_structure(&nixpkgs_path, &mut nix_file_store)?.result_map(|package_names|
136140
// Only if we could successfully parse the structure, we do the evaluation checks
137-
eval::check_values(&nixpkgs_path, package_names, keep_nix_path))?
141+
eval::check_values(&nixpkgs_path, &mut nix_file_store, package_names, keep_nix_path))?
138142
}
139143
})
140144
}
@@ -169,7 +173,7 @@ mod tests {
169173

170174
// tempfile::tempdir needs to be wrapped in temp_env lock
171175
// because it accesses TMPDIR environment variable.
172-
fn tempdir() -> anyhow::Result<TempDir> {
176+
pub fn tempdir() -> anyhow::Result<TempDir> {
173177
let empty_list: [(&str, Option<&str>); 0] = [];
174178
Ok(temp_env::with_vars(empty_list, tempfile::tempdir)?)
175179
}

0 commit comments

Comments
 (0)