tests.nixpkgs-check-by-name: Don't error for pkgs/by-name aliases
This was an oversight in https://github.com/NixOS/nixpkgs/pull/275539 not accounted for, which would've failed in CI
This commit is contained in:
parent
3ebd239cd5
commit
0f27917d9a
@ -168,14 +168,23 @@ pub fn check_values(
|
||||
// so the UsesByName ratchet is already as tight as it can be
|
||||
NonAttributeSet => Success(Tight),
|
||||
NonCallPackage => Success(Tight),
|
||||
// This is an odd case when _internalCallByNamePackageFile is used to define a package.
|
||||
// This is the case when the `pkgs/by-name`-internal _internalCallByNamePackageFile
|
||||
// is used for a package outside `pkgs/by-name`
|
||||
CallPackage(CallPackageInfo {
|
||||
call_package_variant: Auto,
|
||||
..
|
||||
}) => NixpkgsProblem::InternalCallPackageUsed {
|
||||
attr_name: attribute_name.clone(),
|
||||
}) => {
|
||||
// With the current detection mechanism, this also triggers for aliases
|
||||
// to pkgs/by-name packages, and there's no good method of
|
||||
// distinguishing alias vs non-alias.
|
||||
// Using `config.allowAliases = false` at least currently doesn't work
|
||||
// because there's nothing preventing people from defining aliases that
|
||||
// are present even with that disabled.
|
||||
// In the future we could kind of abuse this behavior to have better
|
||||
// enforcement of conditional aliases, but for now we just need to not
|
||||
// give an error.
|
||||
Success(Tight)
|
||||
}
|
||||
.into(),
|
||||
// Only derivations can be in pkgs/by-name,
|
||||
// so this attribute doesn't qualify
|
||||
CallPackage(CallPackageInfo {
|
||||
|
@ -88,9 +88,6 @@ pub enum NixpkgsProblem {
|
||||
text: String,
|
||||
io_error: io::Error,
|
||||
},
|
||||
InternalCallPackageUsed {
|
||||
attr_name: String,
|
||||
},
|
||||
MovedOutOfByName {
|
||||
package_name: String,
|
||||
call_package_path: Option<PathBuf>,
|
||||
@ -227,11 +224,6 @@ impl fmt::Display for NixpkgsProblem {
|
||||
subpath.display(),
|
||||
text,
|
||||
),
|
||||
NixpkgsProblem::InternalCallPackageUsed { attr_name } =>
|
||||
write!(
|
||||
f,
|
||||
"pkgs.{attr_name}: This attribute is defined using `_internalCallByNamePackageFile`, which is an internal function not intended for manual use.",
|
||||
),
|
||||
NixpkgsProblem::MovedOutOfByName { package_name, call_package_path, empty_arg } => {
|
||||
let call_package_arg =
|
||||
if let Some(path) = &call_package_path {
|
||||
|
@ -0,0 +1,3 @@
|
||||
self: super: {
|
||||
baz = self.foo;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
self: super: {
|
||||
bar = self.foo;
|
||||
}
|
@ -0,0 +1 @@
|
||||
import <test-nixpkgs> { root = ./.; }
|
@ -0,0 +1 @@
|
||||
{ someDrv }: someDrv
|
@ -1 +0,0 @@
|
||||
pkgs.foo: This attribute is defined using `_internalCallByNamePackageFile`, which is an internal function not intended for manual use.
|
@ -77,12 +77,21 @@ let
|
||||
else
|
||||
[ ];
|
||||
|
||||
# A list optionally containing the `aliases.nix` file from the test case as an overlay
|
||||
# But only if config.allowAliases is not false
|
||||
optionalAliasesOverlay =
|
||||
if (config.allowAliases or true) && builtins.pathExists (root + "/aliases.nix") then
|
||||
[ (import (root + "/aliases.nix")) ]
|
||||
else
|
||||
[ ];
|
||||
|
||||
# All the overlays in the right order, including the user-supplied ones
|
||||
allOverlays =
|
||||
[
|
||||
autoCalledPackages
|
||||
]
|
||||
++ optionalAllPackagesOverlay
|
||||
++ optionalAliasesOverlay
|
||||
++ overlays;
|
||||
|
||||
# Apply all the overlays in order to the base fixed-point function pkgsFun
|
||||
|
Loading…
Reference in New Issue
Block a user