Skip to content

Commit

Permalink
Merge pull request #285089 from tweag/by-name-syntactic-callPackage
Browse files Browse the repository at this point in the history
tests.nixpkgs-check-by-name: Syntactic `callPackage` detection and allow new package variants
  • Loading branch information
infinisil committed Feb 5, 2024
2 parents 01e3cec + 474e7e7 commit 70f9d31
Show file tree
Hide file tree
Showing 21 changed files with 901 additions and 243 deletions.
8 changes: 8 additions & 0 deletions pkgs/test/nixpkgs-check-by-name/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkgs/test/nixpkgs-check-by-name/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ anyhow = "1.0"
lazy_static = "1.4.0"
colored = "2.0.4"
itertools = "0.11.0"
rowan = "0.15.11"

[dev-dependencies]
temp-env = "0.3.5"
indoc = "2.0.4"
1 change: 1 addition & 0 deletions pkgs/test/nixpkgs-check-by-name/src/eval.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ let
CallPackage = {
call_package_variant = value._callPackageVariant;
is_derivation = pkgs.lib.isDerivation value;
location = builtins.unsafeGetAttrPos name pkgs;
};
};

Expand Down
346 changes: 216 additions & 130 deletions pkgs/test/nixpkgs-check-by-name/src/eval.rs

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions pkgs/test/nixpkgs-check-by-name/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::nix_file::NixFileStore;
mod eval;
mod nix_file;
mod nixpkgs_problem;
mod ratchet;
mod references;
Expand Down Expand Up @@ -116,6 +118,8 @@ pub fn check_nixpkgs<W: io::Write>(
keep_nix_path: bool,
error_writer: &mut W,
) -> validation::Result<ratchet::Nixpkgs> {
let mut nix_file_store = NixFileStore::default();

Ok({
let nixpkgs_path = nixpkgs_path.canonicalize().with_context(|| {
format!(
Expand All @@ -132,9 +136,9 @@ pub fn check_nixpkgs<W: io::Write>(
)?;
Success(ratchet::Nixpkgs::default())
} else {
check_structure(&nixpkgs_path)?.result_map(|package_names|
check_structure(&nixpkgs_path, &mut nix_file_store)?.result_map(|package_names|
// Only if we could successfully parse the structure, we do the evaluation checks
eval::check_values(&nixpkgs_path, package_names, keep_nix_path))?
eval::check_values(&nixpkgs_path, &mut nix_file_store, package_names, keep_nix_path))?
}
})
}
Expand Down Expand Up @@ -169,7 +173,7 @@ mod tests {

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

0 comments on commit 70f9d31

Please sign in to comment.