-
-
Notifications
You must be signed in to change notification settings - Fork 13.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: support meta.broken as a string to explain why it's broken #109407
Conversation
Some bikeshedding:
|
I like your ideas. This makes it even simpler to specify a descriptive error message. |
A question I'm not sure about is, what the Is this supposed to be a As this is the value that the derivation receives, it might break some tools when changed. |
Do we really need |
@@ -61,7 +61,7 @@ in buildPythonPackage { | |||
platform = if stdenv.isDarwin then "mac" else "linux"; | |||
unit = if cudaSupport then "gpu" else "cpu"; | |||
key = "${platform}_py_${pyVerNoDot}_${unit}"; | |||
in fetchurl packages.${key}; | |||
in fetchurl packages.${key} or { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it relevant ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why it's needed, but running nixpkgs-review
without it will fail:
error: attribute 'linux_py_39_cpu' missing
nixpkgs-review error
$ nix-env --option system x86_64-linux -f /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs -qaP --xml --out-path --show-trace --meta
error: attribute 'linux_py_39_cpu' missing
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/pkgs/development/python-modules/tensorflow/bin.nix:69:15:
68| key = "${platform}_py_${pyVerNoDot}_${unit}";
69| in fetchurl packages.${key};
| ^
70|
… while evaluating the attribute 'src.name'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/pkgs/development/python-modules/tensorflow/bin.nix:64:3:
63|
64| src = let
| ^
65| pyVerNoDot = lib.strings.stringAsChars (x: if x == "." then "" else x) python.pythonVersion;
… while evaluating 'hasSuffix'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/lib/strings.nix:234:5:
233| # Input string
234| content:
| ^
235| let
… from call site
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:121:25:
120| pythonRemoveBinBytecodeHook
121| ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
| ^
122| unzip
… while evaluating 'optionals'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/lib/lists.nix:270:5:
269| # List to return if condition is true
270| elems: if cond then elems else [];
| ^
271|
… from call site
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/pkgs/development/interpreters/python/mk-python-derivation.nix:121:10:
120| pythonRemoveBinBytecodeHook
121| ] ++ lib.optionals (lib.hasSuffix "zip" (attrs.src.name or "")) [
| ^
122| unzip
… while evaluating 'chooseDevOutputs'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/lib/attrsets.nix:497:22:
496| /* Pick the outputs of packages to place in buildInputs */
497| chooseDevOutputs = drvs: builtins.map getDev drvs;
| ^
498|
… from call site
… while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.9-tensorflow-2.4.0'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
200| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
201| name =
| ^
202| let
… while evaluating the attribute 'out.outPath'
at /home/fabian/.cache/nixpkgs-review/rev-a249429bb8a506c78a39a49ff3ebbe34f8b9ba9d/nixpkgs/lib/customisation.nix:156:13:
155| drvPath = assert condition; drv.${outputName}.drvPath;
156| outPath = assert condition; drv.${outputName}.outPath;
| ^
157| };
… while querying the derivation named 'python3.9-tensorflow-2.4.0'
Running nix-instantiate --eval
on the other hand fails with the correct error:
nix-instantiate --eval --strict . -A python39Packages.tensorflow-bin.outPath
error: Package ‘python3.9-tensorflow-2.4.0’ in /home/fabian/Repo/nixpkgs/pkgs/development/python-modules/tensorflow/bin.nix:192 is marked as broken because interpreter python3.9 is not supported by this version, refusing to evaluate.
a) To temporarily allow broken packages, you can use an environment variable
for a single invocation of the nix tools.
$ export NIXPKGS_ALLOW_BROKEN=1
b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.
c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowBroken = true; }
to ~/.config/nixpkgs/config.nix.
(use '--show-trace' to show detailed location information)
lib/trivial.nix
Outdated
=> false | ||
*/ | ||
optionalBroken = cond: because: | ||
if cond then because else false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use optionalString instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using optionalString
is possible, but I tried to avoid a second not broken
value (false
and ""
) and optionalBroken
was my workaround.
But I admit, using optionalString
would remove the need for a new lib
function and perform the same task.
lets use optionalString instead of optionalBroken. This PR would be very helpful for the haskell ecosystem where packages regularly break. I wanted to update one package and I know from experience this can be a painful but sometimes a fix is just a jailbreak/donTest away and so being able to distinguish between the cases would be nice.
|
pkgs/stdenv/generic/check-meta.nix
Outdated
@@ -53,7 +53,7 @@ let | |||
hasLicense attrs && | |||
isUnfree (lib.lists.toList attrs.meta.license); | |||
|
|||
isMarkedBroken = attrs: attrs.meta.broken or false; | |||
isMarkedBroken = attrs: attrs.meta.broken or false != false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isMarkedBroken = attrs: attrs.meta.broken or false != false; | |
isMarkedBroken = attrs: attrs.meta.broken or true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would mark all packages without a meta.broken
attribute as broken.
The original meta.broken or false != false
is correct, because the or
is binding stronger than the !=
.
This allows to override the `disabled` attribute with `overridePythonAttrs`.
2a9dc3f
to
e4d7bae
Compare
I rebased the changes and replaced I'm still not sure whether the return value for
|
I managed to make this pass the test locally via rebasing + this diff:
|
After searching around the code it does not look like it would immediately break anything if we allowed strings in Other than that - great pull request, looks ready for un-draft-ing to me. |
I've opened a rebased version #140325 |
Motivation for this change
This draft is based on the idea of @FRidh in #48663 to add a new
meta.disabledBecause
attribute which can describe why a Python package can't be build. Instead of adding a new attribute with a similar purpose as an existing one (meta.broken
), I tried to add the wanted feature to the existing attribute.meta.brokenBecause
allows to add a custom text to the currentPackage ... is marked as broken ...
message. Setting a message also impliesbroken = true
to reduce the chance of only setting a message, but not actually marking the package as broken.Instead of only booleans,
meta.broken
can now also be set to astring
containing a descriptive message which will be included in thePackage ... is marked as broken ...
message.For example the message for disabled Python would look like this:
I included the
buildPythonPackage
change in this PR to show the potential usage of the attribute. It can be split off when needed.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)