diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5298847..6403b15 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,31 +47,32 @@ The most important tools and commands in this environment are: ### Integration tests Integration tests are declared in [`./tests`](./tests) as subdirectories imitating Nixpkgs with these files: -- `default.nix`: - Always contains - ```nix - import { root = ./.; } - ``` - which makes - ``` - nix-instantiate --eval -A --arg overlays - ``` - work very similarly to the real Nixpkgs, just enough for the program to be able to test it. -- `pkgs/by-name`: - The `pkgs/by-name` directory to check. - -- `pkgs/top-level/all-packages.nix` (optional): - Contains an overlay of the form - ```nix - self: super: { - # ... - } - ``` - allowing the simulation of package overrides to the real [`pkgs/top-level/all-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix). - The default is an empty overlay. +- `main`: A Nixpkgs root directory with: + - `default.nix`: + Always contains + ```nix + import { root = ./.; } + ``` + which makes + ``` + nix-instantiate --eval -A --arg overlays + ``` + work very similarly to the real Nixpkgs, just enough for the program to be able to test it. + - `pkgs/by-name`: + The `pkgs/by-name` directory to check. + + - `pkgs/top-level/all-packages.nix` (optional): + Contains an overlay of the form + ```nix + self: super: { + # ... + } + ``` + allowing the simulation of package overrides to the real [`pkgs/top-level/all-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix). + The default is an empty overlay. - `base` (optional): - Contains another subdirectory imitating Nixpkgs with potentially any of the above structures. + Contains another Nixpkgs root directory with potentially any of the above structures. This is used to test [ratchet checks](./README.md#ratchet-checks). - `expected` (optional): diff --git a/src/eval.rs b/src/eval.rs index 653b458..d2e11e7 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::{env, fs, process}; @@ -156,7 +157,7 @@ pub fn check_values( nixpkgs_path: &Path, nix_file_store: &mut NixFileStore, package_names: &[String], -) -> validation::Result { +) -> validation::Result> { let work_dir = tempfile::Builder::new() .prefix("nixpkgs-vet") .tempdir() @@ -255,9 +256,7 @@ pub fn check_values( .collect_vec()?, ); - Ok(check_result.map(|elems| ratchet::Nixpkgs { - packages: elems.into_iter().collect(), - })) + Ok(check_result.map(|elems| elems.into_iter().collect())) } /// Handle the evaluation result for an attribute in `pkgs/by-name`, making it a validation result. @@ -372,7 +371,7 @@ fn by_name( // Independently report problems about whether it's a derivation and the callPackage // variant. - is_derivation_result.and(variant_result) + is_derivation_result.and_(variant_result) } }; Ok( diff --git a/src/files.rs b/src/files.rs new file mode 100644 index 0000000..26b95e6 --- /dev/null +++ b/src/files.rs @@ -0,0 +1,116 @@ +use crate::problem::npv_169; +use crate::ratchet::RatchetState; +use relative_path::RelativePath; +use relative_path::RelativePathBuf; + +use rnix::SyntaxKind; +use rowan::ast::AstNode; +use std::collections::BTreeMap; +use std::path::Path; + +use crate::nix_file::NixFileStore; +use crate::validation::ResultIteratorExt; +use crate::validation::Validation::Success; +use crate::{nix_file, ratchet, structure, validation}; + +fn find_invalid_withs(syntax: &rnix::SyntaxNode) -> Option { + syntax + .descendants() + .filter(|node| node.kind() == rnix::SyntaxKind::NODE_WITH) + .filter(|node| { + node.descendants() + .map(|child| { + if child == *node { + return None; + } + match child.kind() { + SyntaxKind::NODE_WITH => Some(node), + SyntaxKind::NODE_LET_IN => Some(node), + SyntaxKind::NODE_ATTR_SET => Some(node), + _ => None, + } + }) + .any(|node| node.is_some()) + }) + .take(1) + .last() +} + +pub fn check_files( + nixpkgs_path: &Path, + nix_file_store: &mut NixFileStore, +) -> validation::Result> { + process_nix_files(nixpkgs_path, nix_file_store, |nix_file| { + Ok(Success(ratchet::File { + top_level_with: check_files_top_level_with_lib(nixpkgs_path, nix_file), + })) + }) +} + +fn check_files_top_level_with_lib( + nixpkgs_path: &Path, + nix_file: &nix_file::NixFile, +) -> RatchetState { + if let Some(open_scope_with_lib) = find_invalid_withs(nix_file.syntax_root.syntax()) { + RatchetState::Loose( + { + npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new( + RelativePathBuf::from_path( + nix_file.path.clone().strip_prefix(nixpkgs_path).unwrap(), + ) + .unwrap(), + open_scope_with_lib.to_string(), + ) + } + .into(), + ) + } else { + RatchetState::Tight + } +} + +fn collect_nix_files( + base: &Path, + dir: &RelativePath, + files: &mut Vec, +) -> anyhow::Result<()> { + for entry in structure::read_dir_sorted(&dir.to_path(base))? { + let mut relative_path = dir.to_relative_path_buf(); + relative_path.push(entry.file_name().to_string_lossy().into_owned()); + + let absolute_path = entry.path(); + + if absolute_path.is_symlink() { + continue; + } + if absolute_path.is_dir() { + collect_nix_files(base, &relative_path, files)? + } else if absolute_path.extension().is_some_and(|x| x == "nix") { + files.push(relative_path) + } + } + Ok(()) +} + +fn process_nix_files validation::Result>( + nixpkgs_path: &Path, + nix_file_store: &mut NixFileStore, + f: F, +) -> validation::Result> { + let files = { + let mut files = vec![]; + collect_nix_files(nixpkgs_path, &RelativePathBuf::new(), &mut files)?; + files + }; + + let file_results: Vec> = files + .into_iter() + .map(|path| { + let nix_file = nix_file_store.get(&path.to_path(nixpkgs_path))?; + let val = f(nix_file)?.map(|file| (path, file)); + Ok::<_, anyhow::Error>(val) + }) + .collect_vec()?; + + Ok(validation::sequence(file_results).map(|entries| entries.into_iter().collect())) +} diff --git a/src/main.rs b/src/main.rs index e46e708..4ca9d98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ // #![allow(clippy::missing_const_for_fn)] mod eval; +mod files; mod location; mod nix_file; mod problem; @@ -21,6 +22,7 @@ mod validation; use anyhow::Context as _; use clap::Parser; +use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::process::ExitCode; use std::{panic, thread}; @@ -113,20 +115,30 @@ fn check_nixpkgs(nixpkgs_path: &Path) -> validation::Result { ) })?; - if !nixpkgs_path.join(structure::BASE_SUBPATH).exists() { - // No pkgs/by-name directory, always valid - return Ok(Success(ratchet::Nixpkgs::default())); - } - let mut nix_file_store = NixFileStore::default(); - let structure = check_structure(&nixpkgs_path, &mut nix_file_store)?; - // Only if we could successfully parse the structure, we do the evaluation checks - let result = structure.result_map(|package_names| { - eval::check_values(&nixpkgs_path, &mut nix_file_store, package_names.as_slice()) - })?; + let package_result = { + if !nixpkgs_path.join(structure::BASE_SUBPATH).exists() { + // No pkgs/by-name directory, always valid + Success(BTreeMap::new()) + } else { + let structure = check_structure(&nixpkgs_path, &mut nix_file_store)?; + + // Only if we could successfully parse the structure, we do the evaluation checks + structure.result_map(|package_names| { + eval::check_values(&nixpkgs_path, &mut nix_file_store, package_names.as_slice()) + })? + } + }; + + let file_result = files::check_files(&nixpkgs_path, &mut nix_file_store)?; - Ok(result) + Ok( + package_result.and(file_result, |packages, files| ratchet::Nixpkgs { + packages, + files, + }), + ) } #[cfg(test)] @@ -178,7 +190,7 @@ mod tests { return Ok(()); } - let base = path.join(BASE_SUBPATH); + let base = path.join("main").join(BASE_SUBPATH); fs::create_dir_all(base.join("fo/foo"))?; fs::write(base.join("fo/foo/package.nix"), "{ someDrv }: someDrv")?; @@ -237,7 +249,7 @@ mod tests { .build() .expect("valid regex"); - let path = path.to_owned(); + let main_path = path.join("main"); let base_path = path.join("base"); let base_nixpkgs = if base_path.exists() { base_path @@ -251,7 +263,7 @@ mod tests { let nix_conf_dir = nix_conf_dir.path().as_os_str(); let status = temp_env::with_var("NIX_CONF_DIR", Some(nix_conf_dir), || { - process(base_nixpkgs, &path) + process(base_nixpkgs, &main_path) }); let actual_errors = format!("{status}\n"); diff --git a/src/problem/mod.rs b/src/problem/mod.rs index 981c0ea..d8d848d 100644 --- a/src/problem/mod.rs +++ b/src/problem/mod.rs @@ -34,6 +34,8 @@ pub mod npv_161; pub mod npv_162; pub mod npv_163; +pub mod npv_169; + #[derive(Clone, Display, EnumFrom)] pub enum Problem { /// NPV-100: attribute is not defined but it should be defined automatically @@ -123,6 +125,11 @@ pub enum Problem { NewTopLevelPackageShouldBeByNameWithCustomArgument( npv_163::NewTopLevelPackageShouldBeByNameWithCustomArgument, ), + + /// NPV-169: top-level with may shadow variables and break static checks + TopLevelWithMayShadowVariablesAndBreakStaticChecks( + npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks, + ), } fn indent_definition(column: usize, definition: &str) -> String { diff --git a/src/problem/npv_169.rs b/src/problem/npv_169.rs new file mode 100644 index 0000000..633d179 --- /dev/null +++ b/src/problem/npv_169.rs @@ -0,0 +1,21 @@ +use relative_path::RelativePathBuf; +use std::fmt; + +#[derive(Clone)] +pub struct TopLevelWithMayShadowVariablesAndBreakStaticChecks { + file: RelativePathBuf, + node: String, +} + +impl TopLevelWithMayShadowVariablesAndBreakStaticChecks { + pub fn new(file: RelativePathBuf, node: String) -> Self { + Self { file, node } + } +} + +impl fmt::Display for TopLevelWithMayShadowVariablesAndBreakStaticChecks { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Self { file, node: _node } = self; + write!(f, "- {file}: Top level with is discouraged as it may shadow variables and break static checks.") + } +} diff --git a/src/ratchet.rs b/src/ratchet.rs index 10e7e90..0178645 100644 --- a/src/ratchet.rs +++ b/src/ratchet.rs @@ -2,6 +2,7 @@ //! //! Each type has a `compare` method that validates the ratchet checks for that item. +use relative_path::RelativePath; use std::collections::BTreeMap; use relative_path::RelativePathBuf; @@ -15,6 +16,7 @@ use crate::validation::{self, Validation, Validation::Success}; pub struct Nixpkgs { /// The ratchet values for all packages pub packages: BTreeMap, + pub files: BTreeMap, } impl Nixpkgs { @@ -27,6 +29,9 @@ impl Nixpkgs { .into_iter() .map(|(name, pkg)| Package::compare(&name, from.packages.get(&name), &pkg)), ) + .and_(validation::sequence_(to.files.into_iter().map( + |(name, file)| File::compare(&name, from.files.get(&name), &file), + ))) } } @@ -57,6 +62,21 @@ impl Package { } } +pub struct File { + pub top_level_with: RatchetState, +} + +impl File { + /// Validates the ratchet checks for a top-level package + pub fn compare(name: &RelativePath, optional_from: Option<&Self>, to: &Self) -> Validation<()> { + validation::sequence_([RatchetState::compare( + name.as_str(), + optional_from.map(|x| &x.top_level_with), + &to.top_level_with, + )]) + } +} + /// The ratchet state of a generic ratchet check. pub enum RatchetState { /// The ratchet is loose. It can be tightened more. In other words, this is the legacy state @@ -173,3 +193,16 @@ impl ToProblem for UsesByName { } } } + +// The ratchet value of an attribute for the check that new nixpkgs changes do not +// introduce top level with or withs that could shadow scope. + +pub enum DoesNotIntroduceToplevelWiths {} + +impl ToProblem for DoesNotIntroduceToplevelWiths { + type ToContext = Problem; + + fn to_problem(_name: &str, _optional_from: Option<()>, to: &Self::ToContext) -> Problem { + to.clone() + } +} diff --git a/src/structure.rs b/src/structure.rs index b4df6b9..aab6d2e 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -96,7 +96,7 @@ pub fn check_structure( .into() }); - let result = result.and(validation::sequence_(duplicate_results)); + let result = result.and_(validation::sequence_(duplicate_results)); let package_results = entries .into_iter() @@ -111,7 +111,7 @@ pub fn check_structure( }) .collect_vec()?; - result.and(validation::sequence(package_results)) + result.and_(validation::sequence(package_results)) }) }) .collect_vec()?; @@ -147,7 +147,7 @@ fn check_package( }; let correct_relative_package_dir = relative_dir_for_package(&package_name); - let result = result.and(if relative_package_dir != correct_relative_package_dir { + let result = result.and_(if relative_package_dir != correct_relative_package_dir { // Only show this error if we have a valid shard and package name. // If one of those is wrong, you should fix that first. if shard_name_valid && package_name_valid { @@ -164,7 +164,7 @@ fn check_package( }); let package_nix_path = package_path.join(PACKAGE_NIX_FILENAME); - let result = result.and(if !package_nix_path.exists() { + let result = result.and_(if !package_nix_path.exists() { npv_143::PackageNixMissing::new(package_name.clone()).into() } else if !package_nix_path.is_file() { npv_144::PackageNixIsNotFile::new(package_name.clone()).into() @@ -172,7 +172,7 @@ fn check_package( Success(()) }); - let result = result.and(references::check_references( + let result = result.and_(references::check_references( nix_file_store, &relative_package_dir, &relative_package_dir.to_path(path), diff --git a/src/validation.rs b/src/validation.rs index 8264f4a..8720574 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -75,9 +75,17 @@ impl Validation { impl Validation<()> { /// Combine two validations, both of which need to be successful for the return value to be /// successful. The `Problem`s of both sides are returned concatenated. - pub fn and(self, other: Validation) -> Validation { + pub fn and_(self, other: Validation) -> Validation { + self.and(other, |(), b| b) + } +} + +impl Validation { + /// Combine two validations, both of which need to be successful for the return value to be + /// successful. The `Problem`s of both sides are returned concatenated. + pub fn and C>(self, other: Validation, f: F) -> Validation { match (self, other) { - (Success(_), Success(right_value)) => Success(right_value), + (Success(a), Success(b)) => Success(f(a, b)), (Failure(errors_l), Failure(errors_r)) => Failure(concat([errors_l, errors_r])), (Failure(errors), Success(_)) | (Success(_), Failure(errors)) => Failure(errors), } diff --git a/tests/aliases/aliases.nix b/tests/aliases/main/aliases.nix similarity index 100% rename from tests/aliases/aliases.nix rename to tests/aliases/main/aliases.nix diff --git a/tests/aliases/default.nix b/tests/aliases/main/default.nix similarity index 100% rename from tests/aliases/default.nix rename to tests/aliases/main/default.nix diff --git a/tests/aliases/pkgs/by-name/fo/foo/package.nix b/tests/aliases/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/aliases/pkgs/by-name/fo/foo/package.nix rename to tests/aliases/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/aliases/pkgs/top-level/all-packages.nix b/tests/aliases/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/aliases/pkgs/top-level/all-packages.nix rename to tests/aliases/main/pkgs/top-level/all-packages.nix diff --git a/tests/alt-callPackage/default.nix b/tests/alt-callPackage/main/default.nix similarity index 100% rename from tests/alt-callPackage/default.nix rename to tests/alt-callPackage/main/default.nix diff --git a/tests/alt-callPackage/pkgs/by-name/fo/foo/package.nix b/tests/alt-callPackage/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/alt-callPackage/pkgs/by-name/fo/foo/package.nix rename to tests/alt-callPackage/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/alt-callPackage/pkgs/top-level/all-packages.nix b/tests/alt-callPackage/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/alt-callPackage/pkgs/top-level/all-packages.nix rename to tests/alt-callPackage/main/pkgs/top-level/all-packages.nix diff --git a/tests/base-fixed/default.nix b/tests/base-fixed/main/default.nix similarity index 100% rename from tests/base-fixed/default.nix rename to tests/base-fixed/main/default.nix diff --git a/tests/base-fixed/pkgs/by-name/README.md b/tests/base-fixed/main/pkgs/by-name/README.md similarity index 100% rename from tests/base-fixed/pkgs/by-name/README.md rename to tests/base-fixed/main/pkgs/by-name/README.md diff --git a/tests/base-still-broken/default.nix b/tests/base-still-broken/main/default.nix similarity index 100% rename from tests/base-still-broken/default.nix rename to tests/base-still-broken/main/default.nix diff --git a/tests/base-still-broken/pkgs/by-name/bar b/tests/base-still-broken/main/pkgs/by-name/bar similarity index 100% rename from tests/base-still-broken/pkgs/by-name/bar rename to tests/base-still-broken/main/pkgs/by-name/bar diff --git a/tests/broken-autocall/default.nix b/tests/broken-autocall/main/default.nix similarity index 100% rename from tests/broken-autocall/default.nix rename to tests/broken-autocall/main/default.nix diff --git a/tests/broken-autocall/pkgs/by-name/fo/foo/package.nix b/tests/broken-autocall/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/broken-autocall/pkgs/by-name/fo/foo/package.nix rename to tests/broken-autocall/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/by-name-failure/default.nix b/tests/by-name-failure/main/default.nix similarity index 100% rename from tests/by-name-failure/default.nix rename to tests/by-name-failure/main/default.nix diff --git a/tests/by-name-failure/pkgs/by-name/fo/foo/package.nix b/tests/by-name-failure/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/by-name-failure/pkgs/by-name/fo/foo/package.nix rename to tests/by-name-failure/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/callPackage-syntax/default.nix b/tests/callPackage-syntax/main/default.nix similarity index 100% rename from tests/callPackage-syntax/default.nix rename to tests/callPackage-syntax/main/default.nix diff --git a/tests/callPackage-syntax/pkgs/by-name/README.md b/tests/callPackage-syntax/main/pkgs/by-name/README.md similarity index 100% rename from tests/callPackage-syntax/pkgs/by-name/README.md rename to tests/callPackage-syntax/main/pkgs/by-name/README.md diff --git a/tests/callPackage-syntax/pkgs/top-level/all-packages.nix b/tests/callPackage-syntax/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/callPackage-syntax/pkgs/top-level/all-packages.nix rename to tests/callPackage-syntax/main/pkgs/top-level/all-packages.nix diff --git a/tests/empty-base/default.nix b/tests/empty-base/main/default.nix similarity index 100% rename from tests/empty-base/default.nix rename to tests/empty-base/main/default.nix diff --git a/tests/empty-base/pkgs/by-name/README.md b/tests/empty-base/main/pkgs/by-name/README.md similarity index 100% rename from tests/empty-base/pkgs/by-name/README.md rename to tests/empty-base/main/pkgs/by-name/README.md diff --git a/tests/incorrect-shard/default.nix b/tests/incorrect-shard/main/default.nix similarity index 100% rename from tests/incorrect-shard/default.nix rename to tests/incorrect-shard/main/default.nix diff --git a/tests/incorrect-shard/pkgs/by-name/aa/FOO/package.nix b/tests/incorrect-shard/main/pkgs/by-name/aa/FOO/package.nix similarity index 100% rename from tests/incorrect-shard/pkgs/by-name/aa/FOO/package.nix rename to tests/incorrect-shard/main/pkgs/by-name/aa/FOO/package.nix diff --git a/tests/internalCallPackage/default.nix b/tests/internalCallPackage/main/default.nix similarity index 100% rename from tests/internalCallPackage/default.nix rename to tests/internalCallPackage/main/default.nix diff --git a/tests/internalCallPackage/foo.nix b/tests/internalCallPackage/main/foo.nix similarity index 100% rename from tests/internalCallPackage/foo.nix rename to tests/internalCallPackage/main/foo.nix diff --git a/tests/internalCallPackage/pkgs/by-name/README.md b/tests/internalCallPackage/main/pkgs/by-name/README.md similarity index 100% rename from tests/internalCallPackage/pkgs/by-name/README.md rename to tests/internalCallPackage/main/pkgs/by-name/README.md diff --git a/tests/internalCallPackage/pkgs/by-name/fo/foo/package.nix b/tests/internalCallPackage/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/internalCallPackage/pkgs/by-name/fo/foo/package.nix rename to tests/internalCallPackage/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/internalCallPackage/pkgs/top-level/all-packages.nix b/tests/internalCallPackage/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/internalCallPackage/pkgs/top-level/all-packages.nix rename to tests/internalCallPackage/main/pkgs/top-level/all-packages.nix diff --git a/tests/invalid-package-name/default.nix b/tests/invalid-package-name/main/default.nix similarity index 100% rename from tests/invalid-package-name/default.nix rename to tests/invalid-package-name/main/default.nix diff --git a/tests/invalid-package-name/pkgs/by-name/fo/fo@/package.nix b/tests/invalid-package-name/main/pkgs/by-name/fo/fo@/package.nix similarity index 100% rename from tests/invalid-package-name/pkgs/by-name/fo/fo@/package.nix rename to tests/invalid-package-name/main/pkgs/by-name/fo/fo@/package.nix diff --git a/tests/invalid-shard-name/default.nix b/tests/invalid-shard-name/main/default.nix similarity index 100% rename from tests/invalid-shard-name/default.nix rename to tests/invalid-shard-name/main/default.nix diff --git a/tests/invalid-shard-name/pkgs/by-name/A/A/.git-keep b/tests/invalid-shard-name/main/pkgs/by-name/A/A/.git-keep similarity index 100% rename from tests/invalid-shard-name/pkgs/by-name/A/A/.git-keep rename to tests/invalid-shard-name/main/pkgs/by-name/A/A/.git-keep diff --git a/tests/invalid-shard-name/pkgs/by-name/A/A/package.nix b/tests/invalid-shard-name/main/pkgs/by-name/A/A/package.nix similarity index 100% rename from tests/invalid-shard-name/pkgs/by-name/A/A/package.nix rename to tests/invalid-shard-name/main/pkgs/by-name/A/A/package.nix diff --git a/tests/manual-definition/default.nix b/tests/manual-definition/main/default.nix similarity index 100% rename from tests/manual-definition/default.nix rename to tests/manual-definition/main/default.nix diff --git a/tests/manual-definition/pkgs/by-name/no/noEval/package.nix b/tests/manual-definition/main/pkgs/by-name/no/noEval/package.nix similarity index 100% rename from tests/manual-definition/pkgs/by-name/no/noEval/package.nix rename to tests/manual-definition/main/pkgs/by-name/no/noEval/package.nix diff --git a/tests/manual-definition/pkgs/by-name/on/onlyMove/package.nix b/tests/manual-definition/main/pkgs/by-name/on/onlyMove/package.nix similarity index 100% rename from tests/manual-definition/pkgs/by-name/on/onlyMove/package.nix rename to tests/manual-definition/main/pkgs/by-name/on/onlyMove/package.nix diff --git a/tests/manual-definition/pkgs/top-level/all-packages.nix b/tests/manual-definition/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/manual-definition/pkgs/top-level/all-packages.nix rename to tests/manual-definition/main/pkgs/top-level/all-packages.nix diff --git a/tests/missing-package-nix/default.nix b/tests/missing-package-nix/main/default.nix similarity index 100% rename from tests/missing-package-nix/default.nix rename to tests/missing-package-nix/main/default.nix diff --git a/tests/missing-package-nix/pkgs/by-name/fo/foo/.git-keep b/tests/missing-package-nix/main/pkgs/by-name/fo/foo/.git-keep similarity index 100% rename from tests/missing-package-nix/pkgs/by-name/fo/foo/.git-keep rename to tests/missing-package-nix/main/pkgs/by-name/fo/foo/.git-keep diff --git a/tests/move-to-non-by-name/default.nix b/tests/move-to-non-by-name/main/default.nix similarity index 100% rename from tests/move-to-non-by-name/default.nix rename to tests/move-to-non-by-name/main/default.nix diff --git a/tests/move-to-non-by-name/pkgs/by-name/README.md b/tests/move-to-non-by-name/main/pkgs/by-name/README.md similarity index 100% rename from tests/move-to-non-by-name/pkgs/by-name/README.md rename to tests/move-to-non-by-name/main/pkgs/by-name/README.md diff --git a/tests/move-to-non-by-name/pkgs/top-level/all-packages.nix b/tests/move-to-non-by-name/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/move-to-non-by-name/pkgs/top-level/all-packages.nix rename to tests/move-to-non-by-name/main/pkgs/top-level/all-packages.nix diff --git a/tests/move-to-non-by-name/with-config.nix b/tests/move-to-non-by-name/main/with-config.nix similarity index 100% rename from tests/move-to-non-by-name/with-config.nix rename to tests/move-to-non-by-name/main/with-config.nix diff --git a/tests/move-to-non-by-name/without-config.nix b/tests/move-to-non-by-name/main/without-config.nix similarity index 100% rename from tests/move-to-non-by-name/without-config.nix rename to tests/move-to-non-by-name/main/without-config.nix diff --git a/tests/multiple-failures/default.nix b/tests/multiple-failures/main/default.nix similarity index 100% rename from tests/multiple-failures/default.nix rename to tests/multiple-failures/main/default.nix diff --git a/tests/multiple-failures/pkgs/by-name/A/fo@/foo b/tests/multiple-failures/main/pkgs/by-name/A/fo@/foo similarity index 100% rename from tests/multiple-failures/pkgs/by-name/A/fo@/foo rename to tests/multiple-failures/main/pkgs/by-name/A/fo@/foo diff --git a/tests/multiple-failures/pkgs/by-name/A/fo@/package.nix b/tests/multiple-failures/main/pkgs/by-name/A/fo@/package.nix similarity index 100% rename from tests/multiple-failures/pkgs/by-name/A/fo@/package.nix rename to tests/multiple-failures/main/pkgs/by-name/A/fo@/package.nix diff --git a/tests/multiple-failures/pkgs/by-name/aa b/tests/multiple-failures/main/pkgs/by-name/aa similarity index 100% rename from tests/multiple-failures/pkgs/by-name/aa rename to tests/multiple-failures/main/pkgs/by-name/aa diff --git a/tests/multiple-failures/pkgs/by-name/ba/bar b/tests/multiple-failures/main/pkgs/by-name/ba/bar similarity index 100% rename from tests/multiple-failures/pkgs/by-name/ba/bar rename to tests/multiple-failures/main/pkgs/by-name/ba/bar diff --git a/tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix b/tests/multiple-failures/main/pkgs/by-name/ba/baz/package.nix/default.nix similarity index 100% rename from tests/multiple-failures/pkgs/by-name/ba/baz/package.nix/default.nix rename to tests/multiple-failures/main/pkgs/by-name/ba/baz/package.nix/default.nix diff --git a/tests/multiple-failures/pkgs/by-name/ba/foo/package.nix b/tests/multiple-failures/main/pkgs/by-name/ba/foo/package.nix similarity index 100% rename from tests/multiple-failures/pkgs/by-name/ba/foo/package.nix rename to tests/multiple-failures/main/pkgs/by-name/ba/foo/package.nix diff --git a/tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep b/tests/multiple-failures/main/pkgs/by-name/fo/foo/.git-keep similarity index 100% rename from tests/multiple-failures/pkgs/by-name/fo/foo/.git-keep rename to tests/multiple-failures/main/pkgs/by-name/fo/foo/.git-keep diff --git a/tests/multiple-failures/someDrv.nix b/tests/multiple-failures/main/someDrv.nix similarity index 100% rename from tests/multiple-failures/someDrv.nix rename to tests/multiple-failures/main/someDrv.nix diff --git a/tests/new-package-non-by-name/default.nix b/tests/new-package-non-by-name/main/default.nix similarity index 100% rename from tests/new-package-non-by-name/default.nix rename to tests/new-package-non-by-name/main/default.nix diff --git a/tests/new-package-non-by-name/pkgs/by-name/README.md b/tests/new-package-non-by-name/main/pkgs/by-name/README.md similarity index 100% rename from tests/new-package-non-by-name/pkgs/by-name/README.md rename to tests/new-package-non-by-name/main/pkgs/by-name/README.md diff --git a/tests/new-package-non-by-name/pkgs/top-level/all-packages.nix b/tests/new-package-non-by-name/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/new-package-non-by-name/pkgs/top-level/all-packages.nix rename to tests/new-package-non-by-name/main/pkgs/top-level/all-packages.nix diff --git a/tests/new-package-non-by-name/with-config.nix b/tests/new-package-non-by-name/main/with-config.nix similarity index 100% rename from tests/new-package-non-by-name/with-config.nix rename to tests/new-package-non-by-name/main/with-config.nix diff --git a/tests/new-package-non-by-name/without-config.nix b/tests/new-package-non-by-name/main/without-config.nix similarity index 100% rename from tests/new-package-non-by-name/without-config.nix rename to tests/new-package-non-by-name/main/without-config.nix diff --git a/tests/no-by-name/default.nix b/tests/no-by-name/main/default.nix similarity index 100% rename from tests/no-by-name/default.nix rename to tests/no-by-name/main/default.nix diff --git a/tests/no-eval/default.nix b/tests/no-eval/main/default.nix similarity index 100% rename from tests/no-eval/default.nix rename to tests/no-eval/main/default.nix diff --git a/tests/no-eval/pkgs/by-name/README.md b/tests/no-eval/main/pkgs/by-name/README.md similarity index 100% rename from tests/no-eval/pkgs/by-name/README.md rename to tests/no-eval/main/pkgs/by-name/README.md diff --git a/tests/no-eval/pkgs/top-level/all-packages.nix b/tests/no-eval/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/no-eval/pkgs/top-level/all-packages.nix rename to tests/no-eval/main/pkgs/top-level/all-packages.nix diff --git a/tests/non-attrs/default.nix b/tests/non-attrs/main/default.nix similarity index 100% rename from tests/non-attrs/default.nix rename to tests/non-attrs/main/default.nix diff --git a/tests/non-attrs/pkgs/by-name/no/nonDerivation/package.nix b/tests/non-attrs/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/non-attrs/pkgs/by-name/no/nonDerivation/package.nix rename to tests/non-attrs/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/non-by-name-trace/README.md b/tests/non-by-name-trace/main/README.md similarity index 100% rename from tests/non-by-name-trace/README.md rename to tests/non-by-name-trace/main/README.md diff --git a/tests/non-by-name-trace/default.nix b/tests/non-by-name-trace/main/default.nix similarity index 100% rename from tests/non-by-name-trace/default.nix rename to tests/non-by-name-trace/main/default.nix diff --git a/tests/non-by-name-trace/pkgs/top-level/all-packages.nix b/tests/non-by-name-trace/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/non-by-name-trace/pkgs/top-level/all-packages.nix rename to tests/non-by-name-trace/main/pkgs/top-level/all-packages.nix diff --git a/tests/non-derivation/default.nix b/tests/non-derivation/main/default.nix similarity index 100% rename from tests/non-derivation/default.nix rename to tests/non-derivation/main/default.nix diff --git a/tests/non-derivation/pkgs/by-name/no/nonDerivation/package.nix b/tests/non-derivation/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/non-derivation/pkgs/by-name/no/nonDerivation/package.nix rename to tests/non-derivation/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/non-syntactical-callPackage-by-name/default.nix b/tests/non-syntactical-callPackage-by-name/main/default.nix similarity index 100% rename from tests/non-syntactical-callPackage-by-name/default.nix rename to tests/non-syntactical-callPackage-by-name/main/default.nix diff --git a/tests/non-syntactical-callPackage-by-name/pkgs/by-name/fo/foo/package.nix b/tests/non-syntactical-callPackage-by-name/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/non-syntactical-callPackage-by-name/pkgs/by-name/fo/foo/package.nix rename to tests/non-syntactical-callPackage-by-name/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix b/tests/non-syntactical-callPackage-by-name/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/non-syntactical-callPackage-by-name/pkgs/top-level/all-packages.nix rename to tests/non-syntactical-callPackage-by-name/main/pkgs/top-level/all-packages.nix diff --git a/tests/nowith-basic/expected b/tests/nowith-basic/expected new file mode 100644 index 0000000..defae26 --- /dev/null +++ b/tests/nowith-basic/expected @@ -0,0 +1 @@ +Validated successfully diff --git a/tests/one-letter/default.nix b/tests/nowith-basic/main/default.nix similarity index 100% rename from tests/one-letter/default.nix rename to tests/nowith-basic/main/default.nix diff --git a/tests/nowith-basic/main/test.nix b/tests/nowith-basic/main/test.nix new file mode 100644 index 0000000..2c1be06 --- /dev/null +++ b/tests/nowith-basic/main/test.nix @@ -0,0 +1,3 @@ +with lib; + +2 diff --git a/tests/nowith-meta-toplevel-lib/expected b/tests/nowith-meta-toplevel-lib/expected new file mode 100644 index 0000000..94d8a9f --- /dev/null +++ b/tests/nowith-meta-toplevel-lib/expected @@ -0,0 +1,2 @@ +- test.nix: Top level with is discouraged as it may shadow variables and break static checks. +This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/only-callPackage-derivations/default.nix b/tests/nowith-meta-toplevel-lib/main/default.nix similarity index 100% rename from tests/only-callPackage-derivations/default.nix rename to tests/nowith-meta-toplevel-lib/main/default.nix diff --git a/tests/nowith-meta-toplevel-lib/main/test.nix b/tests/nowith-meta-toplevel-lib/main/test.nix new file mode 100644 index 0000000..02bdb21 --- /dev/null +++ b/tests/nowith-meta-toplevel-lib/main/test.nix @@ -0,0 +1,15 @@ +{ + stdenv, + lib, +}: + +stdenv.mkDerivation { + pname = "test"; + version = "1.0"; + + src = ./.; + + meta = with lib; { + maintainers = [ maintainers.johndoe ]; + }; +} diff --git a/tests/nowith-meta-with-maintainers/expected b/tests/nowith-meta-with-maintainers/expected new file mode 100644 index 0000000..defae26 --- /dev/null +++ b/tests/nowith-meta-with-maintainers/expected @@ -0,0 +1 @@ +Validated successfully diff --git a/tests/override-different-file/default.nix b/tests/nowith-meta-with-maintainers/main/default.nix similarity index 100% rename from tests/override-different-file/default.nix rename to tests/nowith-meta-with-maintainers/main/default.nix diff --git a/tests/nowith-meta-with-maintainers/main/test.nix b/tests/nowith-meta-with-maintainers/main/test.nix new file mode 100644 index 0000000..920b0e1 --- /dev/null +++ b/tests/nowith-meta-with-maintainers/main/test.nix @@ -0,0 +1,15 @@ +{ + stdenv, + lib, +}: + +stdenv.mkDerivation { + pname = "test"; + version = "1.0"; + + src = ./.; + + meta = { + maintainers = with lib.maintainers; [ johndoe ]; + }; +} diff --git a/tests/override-empty-arg-gradual/default.nix b/tests/nowith-nixos-submodule-shadow-changed/base/default.nix similarity index 100% rename from tests/override-empty-arg-gradual/default.nix rename to tests/nowith-nixos-submodule-shadow-changed/base/default.nix diff --git a/tests/nowith-nixos-submodule-shadow-changed/base/test.nix b/tests/nowith-nixos-submodule-shadow-changed/base/test.nix new file mode 100644 index 0000000..00bf57c --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-changed/base/test.nix @@ -0,0 +1,39 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.foo = lib.mkOption { + type = # random example from nixpkgs + with lib.types; + attrsOf ( + either path (submodule { + options = { + service = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/nowith-nixos-submodule-shadow-changed/expected b/tests/nowith-nixos-submodule-shadow-changed/expected new file mode 100644 index 0000000..94d8a9f --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-changed/expected @@ -0,0 +1,2 @@ +- test.nix: Top level with is discouraged as it may shadow variables and break static checks. +This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/override-empty-arg/default.nix b/tests/nowith-nixos-submodule-shadow-changed/main/default.nix similarity index 100% rename from tests/override-empty-arg/default.nix rename to tests/nowith-nixos-submodule-shadow-changed/main/default.nix diff --git a/tests/nowith-nixos-submodule-shadow-changed/main/test.nix b/tests/nowith-nixos-submodule-shadow-changed/main/test.nix new file mode 100644 index 0000000..442437d --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-changed/main/test.nix @@ -0,0 +1,45 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.foo = lib.mkOption { + type = # random example from nixpkgs + with lib.types; + attrsOf ( + either path (submodule { + options = { + service = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + anotherOption = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/override-no-call-package/default.nix b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/base/default.nix similarity index 100% rename from tests/override-no-call-package/default.nix rename to tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/base/default.nix diff --git a/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/base/test.nix b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/base/test.nix new file mode 100644 index 0000000..00bf57c --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/base/test.nix @@ -0,0 +1,39 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.foo = lib.mkOption { + type = # random example from nixpkgs + with lib.types; + attrsOf ( + either path (submodule { + options = { + service = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/expected b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/expected new file mode 100644 index 0000000..defae26 --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/expected @@ -0,0 +1 @@ +Validated successfully diff --git a/tests/override-no-file/default.nix b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/main/default.nix similarity index 100% rename from tests/override-no-file/default.nix rename to tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/main/default.nix diff --git a/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/main/test.nix b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/main/test.nix new file mode 100644 index 0000000..25c9f00 --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow-do-not-touch-if-not-changed/main/test.nix @@ -0,0 +1,42 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.bar = lib.mkOption { + type = lib.types.str; + }; + options.foo = lib.mkOption { + type = # random example from nixpkgs + with lib.types; + attrsOf ( + either path (submodule { + options = { + service = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/nowith-nixos-submodule-shadow/expected b/tests/nowith-nixos-submodule-shadow/expected new file mode 100644 index 0000000..94d8a9f --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow/expected @@ -0,0 +1,2 @@ +- test.nix: Top level with is discouraged as it may shadow variables and break static checks. +This PR introduces additional instances of discouraged patterns as listed above. Merging is discouraged but would not break the base branch. diff --git a/tests/override-non-path/default.nix b/tests/nowith-nixos-submodule-shadow/main/default.nix similarity index 100% rename from tests/override-non-path/default.nix rename to tests/nowith-nixos-submodule-shadow/main/default.nix diff --git a/tests/nowith-nixos-submodule-shadow/main/test.nix b/tests/nowith-nixos-submodule-shadow/main/test.nix new file mode 100644 index 0000000..00bf57c --- /dev/null +++ b/tests/nowith-nixos-submodule-shadow/main/test.nix @@ -0,0 +1,39 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.foo = lib.mkOption { + type = # random example from nixpkgs + with lib.types; + attrsOf ( + either path (submodule { + options = { + service = lib.mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/nowith-nixos-submodule-unshadow-inherit/expected b/tests/nowith-nixos-submodule-unshadow-inherit/expected new file mode 100644 index 0000000..defae26 --- /dev/null +++ b/tests/nowith-nixos-submodule-unshadow-inherit/expected @@ -0,0 +1 @@ +Validated successfully diff --git a/tests/override-success/default.nix b/tests/nowith-nixos-submodule-unshadow-inherit/main/default.nix similarity index 100% rename from tests/override-success/default.nix rename to tests/nowith-nixos-submodule-unshadow-inherit/main/default.nix diff --git a/tests/nowith-nixos-submodule-unshadow-inherit/main/test.nix b/tests/nowith-nixos-submodule-unshadow-inherit/main/test.nix new file mode 100644 index 0000000..a91b7af --- /dev/null +++ b/tests/nowith-nixos-submodule-unshadow-inherit/main/test.nix @@ -0,0 +1,53 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; + + inherit (lib) + mkOption + elem + ; + + inherit (lib.types) + attrsOf + either + path + submodule + nullOr + str + addCheck + ; +in +{ + options.foo = mkOption { + type = # random example from nixpkgs + attrsOf ( + either path (submodule { + options = { + service = mkOption { + type = nullOr str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = mkOption { + type = addCheck str ( + x: + cfg.svcManager == "command" + || elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + }) + ); + }; +} diff --git a/tests/nowith-nixos-submodule-unshadow/expected b/tests/nowith-nixos-submodule-unshadow/expected new file mode 100644 index 0000000..defae26 --- /dev/null +++ b/tests/nowith-nixos-submodule-unshadow/expected @@ -0,0 +1 @@ +Validated successfully diff --git a/tests/package-dir-is-file/default.nix b/tests/nowith-nixos-submodule-unshadow/main/default.nix similarity index 100% rename from tests/package-dir-is-file/default.nix rename to tests/nowith-nixos-submodule-unshadow/main/default.nix diff --git a/tests/nowith-nixos-submodule-unshadow/main/test.nix b/tests/nowith-nixos-submodule-unshadow/main/test.nix new file mode 100644 index 0000000..b654d61 --- /dev/null +++ b/tests/nowith-nixos-submodule-unshadow/main/test.nix @@ -0,0 +1,40 @@ +{ + config, + lib, +}: + +let + cfg = config.foo; +in +{ + options.foo = lib.mkOption { + type = # random example from nixpkgs + lib.types.attrsOf ( + lib.types.either lib.types.path ( + lib.types.submodule { + options = { + service = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "The service on which to perform \ after fetching."; + }; + + action = lib.mkOption { + type = lib.types.addCheck lib.types.str ( + x: + cfg.svcManager == "command" + || lib.elem x [ + "restart" + "reload" + "nop" + ] + ); + default = "nop"; + description = "The action to take after fetching."; + }; + }; + } + ) + ); + }; +} diff --git a/tests/package-nix-dir/default.nix b/tests/one-letter/main/default.nix similarity index 100% rename from tests/package-nix-dir/default.nix rename to tests/one-letter/main/default.nix diff --git a/tests/one-letter/pkgs/by-name/a/a/package.nix b/tests/one-letter/main/pkgs/by-name/a/a/package.nix similarity index 100% rename from tests/one-letter/pkgs/by-name/a/a/package.nix rename to tests/one-letter/main/pkgs/by-name/a/a/package.nix diff --git a/tests/package-variants/default.nix b/tests/only-callPackage-derivations/main/default.nix similarity index 100% rename from tests/package-variants/default.nix rename to tests/only-callPackage-derivations/main/default.nix diff --git a/tests/only-callPackage-derivations/pkgs/by-name/README.md b/tests/only-callPackage-derivations/main/pkgs/by-name/README.md similarity index 100% rename from tests/only-callPackage-derivations/pkgs/by-name/README.md rename to tests/only-callPackage-derivations/main/pkgs/by-name/README.md diff --git a/tests/only-callPackage-derivations/pkgs/top-level/all-packages.nix b/tests/only-callPackage-derivations/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/only-callPackage-derivations/pkgs/top-level/all-packages.nix rename to tests/only-callPackage-derivations/main/pkgs/top-level/all-packages.nix diff --git a/tests/ref-absolute/default.nix b/tests/override-different-file/main/default.nix similarity index 100% rename from tests/ref-absolute/default.nix rename to tests/override-different-file/main/default.nix diff --git a/tests/override-different-file/pkgs/by-name/no/nonDerivation/package.nix b/tests/override-different-file/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/override-different-file/pkgs/by-name/no/nonDerivation/package.nix rename to tests/override-different-file/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/override-different-file/pkgs/top-level/all-packages.nix b/tests/override-different-file/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-different-file/pkgs/top-level/all-packages.nix rename to tests/override-different-file/main/pkgs/top-level/all-packages.nix diff --git a/tests/override-different-file/someDrv.nix b/tests/override-different-file/main/someDrv.nix similarity index 100% rename from tests/override-different-file/someDrv.nix rename to tests/override-different-file/main/someDrv.nix diff --git a/tests/ref-escape/default.nix b/tests/override-empty-arg-gradual/main/default.nix similarity index 100% rename from tests/ref-escape/default.nix rename to tests/override-empty-arg-gradual/main/default.nix diff --git a/tests/override-empty-arg-gradual/pkgs/by-name/no/nonDerivation/package.nix b/tests/override-empty-arg-gradual/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/override-empty-arg-gradual/pkgs/by-name/no/nonDerivation/package.nix rename to tests/override-empty-arg-gradual/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix b/tests/override-empty-arg-gradual/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-empty-arg-gradual/pkgs/top-level/all-packages.nix rename to tests/override-empty-arg-gradual/main/pkgs/top-level/all-packages.nix diff --git a/tests/ref-nix-path/default.nix b/tests/override-empty-arg/main/default.nix similarity index 100% rename from tests/ref-nix-path/default.nix rename to tests/override-empty-arg/main/default.nix diff --git a/tests/override-empty-arg/pkgs/by-name/no/nonDerivation/package.nix b/tests/override-empty-arg/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/override-empty-arg/pkgs/by-name/no/nonDerivation/package.nix rename to tests/override-empty-arg/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/override-empty-arg/pkgs/top-level/all-packages.nix b/tests/override-empty-arg/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-empty-arg/pkgs/top-level/all-packages.nix rename to tests/override-empty-arg/main/pkgs/top-level/all-packages.nix diff --git a/tests/ref-path-subexpr/default.nix b/tests/override-no-call-package/main/default.nix similarity index 100% rename from tests/ref-path-subexpr/default.nix rename to tests/override-no-call-package/main/default.nix diff --git a/tests/override-no-call-package/pkgs/by-name/no/nonDerivation/package.nix b/tests/override-no-call-package/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/override-no-call-package/pkgs/by-name/no/nonDerivation/package.nix rename to tests/override-no-call-package/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/override-no-call-package/pkgs/top-level/all-packages.nix b/tests/override-no-call-package/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-no-call-package/pkgs/top-level/all-packages.nix rename to tests/override-no-call-package/main/pkgs/top-level/all-packages.nix diff --git a/tests/ref-success/default.nix b/tests/override-no-file/main/default.nix similarity index 100% rename from tests/ref-success/default.nix rename to tests/override-no-file/main/default.nix diff --git a/tests/override-no-file/pkgs/by-name/no/nonDerivation/package.nix b/tests/override-no-file/main/pkgs/by-name/no/nonDerivation/package.nix similarity index 100% rename from tests/override-no-file/pkgs/by-name/no/nonDerivation/package.nix rename to tests/override-no-file/main/pkgs/by-name/no/nonDerivation/package.nix diff --git a/tests/override-no-file/pkgs/top-level/all-packages.nix b/tests/override-no-file/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-no-file/pkgs/top-level/all-packages.nix rename to tests/override-no-file/main/pkgs/top-level/all-packages.nix diff --git a/tests/shard-file/default.nix b/tests/override-non-path/main/default.nix similarity index 100% rename from tests/shard-file/default.nix rename to tests/override-non-path/main/default.nix diff --git a/tests/override-non-path/pkgs/by-name/fo/foo/package.nix b/tests/override-non-path/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/override-non-path/pkgs/by-name/fo/foo/package.nix rename to tests/override-non-path/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/override-non-path/pkgs/top-level/all-packages.nix b/tests/override-non-path/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-non-path/pkgs/top-level/all-packages.nix rename to tests/override-non-path/main/pkgs/top-level/all-packages.nix diff --git a/tests/sorted-order/default.nix b/tests/override-success/main/default.nix similarity index 100% rename from tests/sorted-order/default.nix rename to tests/override-success/main/default.nix diff --git a/tests/override-success/pkgs/by-name/fo/foo/package.nix b/tests/override-success/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/override-success/pkgs/by-name/fo/foo/package.nix rename to tests/override-success/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/override-success/pkgs/top-level/all-packages.nix b/tests/override-success/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/override-success/pkgs/top-level/all-packages.nix rename to tests/override-success/main/pkgs/top-level/all-packages.nix diff --git a/tests/success/default.nix b/tests/package-dir-is-file/main/default.nix similarity index 100% rename from tests/success/default.nix rename to tests/package-dir-is-file/main/default.nix diff --git a/tests/package-dir-is-file/pkgs/by-name/fo/foo b/tests/package-dir-is-file/main/pkgs/by-name/fo/foo similarity index 100% rename from tests/package-dir-is-file/pkgs/by-name/fo/foo rename to tests/package-dir-is-file/main/pkgs/by-name/fo/foo diff --git a/tests/symlink-escape/default.nix b/tests/package-nix-dir/main/default.nix similarity index 100% rename from tests/symlink-escape/default.nix rename to tests/package-nix-dir/main/default.nix diff --git a/tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix b/tests/package-nix-dir/main/pkgs/by-name/fo/foo/package.nix/default.nix similarity index 100% rename from tests/package-nix-dir/pkgs/by-name/fo/foo/package.nix/default.nix rename to tests/package-nix-dir/main/pkgs/by-name/fo/foo/package.nix/default.nix diff --git a/tests/symlink-invalid/default.nix b/tests/package-variants/main/default.nix similarity index 100% rename from tests/symlink-invalid/default.nix rename to tests/package-variants/main/default.nix diff --git a/tests/package-variants/package.nix b/tests/package-variants/main/package.nix similarity index 100% rename from tests/package-variants/package.nix rename to tests/package-variants/main/package.nix diff --git a/tests/package-variants/pkgs/by-name/fo/foo/package.nix b/tests/package-variants/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/package-variants/pkgs/by-name/fo/foo/package.nix rename to tests/package-variants/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/package-variants/pkgs/top-level/all-packages.nix b/tests/package-variants/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/package-variants/pkgs/top-level/all-packages.nix rename to tests/package-variants/main/pkgs/top-level/all-packages.nix diff --git a/tests/unknown-location/default.nix b/tests/ref-absolute/main/default.nix similarity index 100% rename from tests/unknown-location/default.nix rename to tests/ref-absolute/main/default.nix diff --git a/tests/ref-absolute/pkgs/by-name/aa/aa/package.nix b/tests/ref-absolute/main/pkgs/by-name/aa/aa/package.nix similarity index 100% rename from tests/ref-absolute/pkgs/by-name/aa/aa/package.nix rename to tests/ref-absolute/main/pkgs/by-name/aa/aa/package.nix diff --git a/tests/uppercase/default.nix b/tests/ref-escape/main/default.nix similarity index 100% rename from tests/uppercase/default.nix rename to tests/ref-escape/main/default.nix diff --git a/tests/ref-escape/pkgs/by-name/aa/aa/package.nix b/tests/ref-escape/main/pkgs/by-name/aa/aa/package.nix similarity index 100% rename from tests/ref-escape/pkgs/by-name/aa/aa/package.nix rename to tests/ref-escape/main/pkgs/by-name/aa/aa/package.nix diff --git a/tests/with-readme/default.nix b/tests/ref-nix-path/main/default.nix similarity index 100% rename from tests/with-readme/default.nix rename to tests/ref-nix-path/main/default.nix diff --git a/tests/ref-nix-path/pkgs/by-name/aa/aa/package.nix b/tests/ref-nix-path/main/pkgs/by-name/aa/aa/package.nix similarity index 100% rename from tests/ref-nix-path/pkgs/by-name/aa/aa/package.nix rename to tests/ref-nix-path/main/pkgs/by-name/aa/aa/package.nix diff --git a/tests/ref-path-subexpr/main/default.nix b/tests/ref-path-subexpr/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/ref-path-subexpr/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/ref-path-subexpr/pkgs/by-name/aa/aa/package.nix b/tests/ref-path-subexpr/main/pkgs/by-name/aa/aa/package.nix similarity index 100% rename from tests/ref-path-subexpr/pkgs/by-name/aa/aa/package.nix rename to tests/ref-path-subexpr/main/pkgs/by-name/aa/aa/package.nix diff --git a/tests/ref-success/main/default.nix b/tests/ref-success/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/ref-success/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/ref-success/pkgs/by-name/aa/aa/dir/default.nix b/tests/ref-success/main/pkgs/by-name/aa/aa/dir/default.nix similarity index 100% rename from tests/ref-success/pkgs/by-name/aa/aa/dir/default.nix rename to tests/ref-success/main/pkgs/by-name/aa/aa/dir/default.nix diff --git a/tests/ref-success/pkgs/by-name/aa/aa/file b/tests/ref-success/main/pkgs/by-name/aa/aa/file similarity index 100% rename from tests/ref-success/pkgs/by-name/aa/aa/file rename to tests/ref-success/main/pkgs/by-name/aa/aa/file diff --git a/tests/ref-success/pkgs/by-name/aa/aa/file.nix b/tests/ref-success/main/pkgs/by-name/aa/aa/file.nix similarity index 100% rename from tests/ref-success/pkgs/by-name/aa/aa/file.nix rename to tests/ref-success/main/pkgs/by-name/aa/aa/file.nix diff --git a/tests/ref-success/pkgs/by-name/aa/aa/package.nix b/tests/ref-success/main/pkgs/by-name/aa/aa/package.nix similarity index 100% rename from tests/ref-success/pkgs/by-name/aa/aa/package.nix rename to tests/ref-success/main/pkgs/by-name/aa/aa/package.nix diff --git a/tests/shard-file/main/default.nix b/tests/shard-file/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/shard-file/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/shard-file/pkgs/by-name/fo b/tests/shard-file/main/pkgs/by-name/fo similarity index 100% rename from tests/shard-file/pkgs/by-name/fo rename to tests/shard-file/main/pkgs/by-name/fo diff --git a/tests/sorted-order/main/default.nix b/tests/sorted-order/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/sorted-order/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/sorted-order/pkgs/by-name/a/a/package.nix b/tests/sorted-order/main/pkgs/by-name/a/a/package.nix similarity index 100% rename from tests/sorted-order/pkgs/by-name/a/a/package.nix rename to tests/sorted-order/main/pkgs/by-name/a/a/package.nix diff --git a/tests/sorted-order/pkgs/by-name/c/c/package.nix b/tests/sorted-order/main/pkgs/by-name/c/c/package.nix similarity index 100% rename from tests/sorted-order/pkgs/by-name/c/c/package.nix rename to tests/sorted-order/main/pkgs/by-name/c/c/package.nix diff --git a/tests/sorted-order/pkgs/top-level/all-packages.nix b/tests/sorted-order/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/sorted-order/pkgs/top-level/all-packages.nix rename to tests/sorted-order/main/pkgs/top-level/all-packages.nix diff --git a/tests/success/main/default.nix b/tests/success/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/success/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/success/pkgs/by-name/fo/foo/package.nix b/tests/success/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/success/pkgs/by-name/fo/foo/package.nix rename to tests/success/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/symlink-escape/main/default.nix b/tests/symlink-escape/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/symlink-escape/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/symlink-escape/pkgs/by-name/fo/foo/package.nix b/tests/symlink-escape/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/symlink-escape/pkgs/by-name/fo/foo/package.nix rename to tests/symlink-escape/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/symlink-escape/someDrv.nix b/tests/symlink-escape/main/someDrv.nix similarity index 100% rename from tests/symlink-escape/someDrv.nix rename to tests/symlink-escape/main/someDrv.nix diff --git a/tests/symlink-invalid/main/default.nix b/tests/symlink-invalid/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/symlink-invalid/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/symlink-invalid/pkgs/by-name/fo/foo/foo b/tests/symlink-invalid/main/pkgs/by-name/fo/foo/foo similarity index 100% rename from tests/symlink-invalid/pkgs/by-name/fo/foo/foo rename to tests/symlink-invalid/main/pkgs/by-name/fo/foo/foo diff --git a/tests/symlink-invalid/pkgs/by-name/fo/foo/package.nix b/tests/symlink-invalid/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/symlink-invalid/pkgs/by-name/fo/foo/package.nix rename to tests/symlink-invalid/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/symlink-invalid/someDrv.nix b/tests/symlink-invalid/main/someDrv.nix similarity index 100% rename from tests/symlink-invalid/someDrv.nix rename to tests/symlink-invalid/main/someDrv.nix diff --git a/tests/unknown-location/main/default.nix b/tests/unknown-location/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/unknown-location/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/unknown-location/pkgs/by-name/fo/foo/package.nix b/tests/unknown-location/main/pkgs/by-name/fo/foo/package.nix similarity index 100% rename from tests/unknown-location/pkgs/by-name/fo/foo/package.nix rename to tests/unknown-location/main/pkgs/by-name/fo/foo/package.nix diff --git a/tests/unknown-location/pkgs/top-level/all-packages.nix b/tests/unknown-location/main/pkgs/top-level/all-packages.nix similarity index 100% rename from tests/unknown-location/pkgs/top-level/all-packages.nix rename to tests/unknown-location/main/pkgs/top-level/all-packages.nix diff --git a/tests/uppercase/main/default.nix b/tests/uppercase/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/uppercase/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/uppercase/pkgs/by-name/fo/FOO/package.nix b/tests/uppercase/main/pkgs/by-name/fo/FOO/package.nix similarity index 100% rename from tests/uppercase/pkgs/by-name/fo/FOO/package.nix rename to tests/uppercase/main/pkgs/by-name/fo/FOO/package.nix diff --git a/tests/with-readme/main/default.nix b/tests/with-readme/main/default.nix new file mode 100644 index 0000000..861260c --- /dev/null +++ b/tests/with-readme/main/default.nix @@ -0,0 +1 @@ +import { root = ./.; } diff --git a/tests/with-readme/pkgs/by-name/README.md b/tests/with-readme/main/pkgs/by-name/README.md similarity index 100% rename from tests/with-readme/pkgs/by-name/README.md rename to tests/with-readme/main/pkgs/by-name/README.md