Skip to content
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: assert whether name or (pname and version) are given #53327

Closed
wants to merge 1 commit into from

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Jan 3, 2019

Without the assertion, when a pname was missing, the whole trace was

error: attribute 'pname' missing, at /home/freddy/Code/libraries/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:84:54

which is pretty useless if you happened to have changed a lot of
expressions.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Without the assertion, when a `pname` was missing, the whole trace was

    error: attribute 'pname' missing, at /home/freddy/Code/libraries/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:84:54

which is pretty useless if you happened to have changed a lot of
expressions.
@FRidh
Copy link
Member Author

FRidh commented Jan 3, 2019

At the same time, this doesn't improve it much either since now you're presented with an assertion error instead of a reason.

@GrahamcOfBorg GrahamcOfBorg added the 6.topic: stdenv Standard environment label Jan 3, 2019
@FRidh
Copy link
Member Author

FRidh commented Jan 3, 2019

@vbgl @jwiegley about coq, could the recursing be limited to derivations that are actually possible to evaluate?

while evaluating 'getOutput' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/stdenv/generic/make-derivation.nix:135:17, called from undefined position:
while evaluating the attribute 'coq' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:102:3:
while evaluating 'recurseIntoAttrs' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/all-packages.nix:65:22, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:99:17:
while evaluating 'mapDerivationAttrset' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/meta.nix:46:29, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:99:35:
while evaluating 'mkCoqPackages' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:71:19, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:97:21:
while evaluating 'filterCoqPackages' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:48:28, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:74:10:
while evaluating anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:50:22, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:50:7:
while evaluating 'optional' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/lists.nix:241:20, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:53:9:
while evaluating the attribute 'QuickChick' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:38:7:
while evaluating 'callPackageWith' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/customisation.nix:108:35, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/top-level/coq-packages.nix:38:20:
while evaluating 'makeOverridable' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/customisation.nix:67:24, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/customisation.nix:112:8:
while evaluating anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/development/coq-modules/QuickChick/default.nix:1:1, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/lib/customisation.nix:69:12:
while evaluating 'mkDerivation' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/stdenv/generic/make-derivation.nix:15:5, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/development/coq-modules/QuickChick/default.nix:26:1:
attribute '8.8' missing, at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-0-gleber.ewr1.nix.ci/pkgs/development/coq-modules/QuickChick/default.nix:23:11

@vbgl
Copy link
Contributor

vbgl commented Jan 3, 2019

The assertion that you added breaks a derivation that will be pruned later (hence never evaluated): it forces the evaluation of its name argument.

Can that assertion trigger only when the mkDerivation is forced?

Copy link
Contributor

@vbgl vbgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks evaluation of coqPackages.

@jtojnar
Copy link
Contributor

jtojnar commented Jan 4, 2019

Can we use lib.assertMsg?

@vbgl
Copy link
Contributor

vbgl commented Feb 6, 2019

What’s the status of this? Is it related to that recent change: c6f8f8d?

Note that you should use attrs ? name to test whether the name argument is given.

@matthewbauer
Copy link
Member

I don't think this is needed anymore. Nix shows an error if name is missing:

(import ./. {}).stdenv.mkDerivation {}

results in

error: derivation name missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: stdenv Standard environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants