Skip to content

Commit

Permalink
tests.nixpkgs-check-by-name: Allow new package variants
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Jan 30, 2024
1 parent 46da6c5 commit 41a2849
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pkgs/test/nixpkgs-check-by-name/src/eval.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::utils;
use crate::nixpkgs_problem::NixpkgsProblem;
use crate::ratchet;
use crate::structure;
Expand Down Expand Up @@ -223,7 +224,27 @@ pub fn check_values(
nixpkgs_path,
)? {
None => Success(NonApplicable),
Some(call_package_argument_info) => Success(Loose(call_package_argument_info))
Some(call_package_argument_info) => {
if let Some(ref rel_path) = call_package_argument_info.relative_path {
if rel_path.starts_with(utils::BASE_SUBPATH) {
// Package variants of by-name packages are explicitly allowed according to RFC 140
// https://github.com/NixOS/rfcs/blob/master/rfcs/0140-simple-package-paths.md#package-variants:
//
// foo-variant = callPackage ../by-name/fo/foo/package.nix {
// someFlag = true;
// }
//
// While such definitions could be moved to `pkgs/by-name` by using
// `.override { someFlag = true; }` instead, this changes the semantics in
// relation with overlays.
Success(NonApplicable)
} else {
Success(Loose(call_package_argument_info))
}
} else {
Success(Loose(call_package_argument_info))
}
},
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
self: super: {
foo-variant-unvarianted = self.callPackage ./package.nix { };

foo-variant-new = self.callPackage ./pkgs/by-name/fo/foo/package.nix { };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
self: super: {
foo-variant-unvarianted = self.callPackage ./pkgs/by-name/fo/foo/package.nix { };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import <test-nixpkgs> { root = ./.; }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ someDrv }: someDrv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import <test-nixpkgs> { root = ./.; }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ someDrv }: someDrv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ someDrv }: someDrv

0 comments on commit 41a2849

Please sign in to comment.