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: Validate meta.outputsToInstall #46838

Merged
merged 2 commits into from Sep 18, 2018

Conversation

grahamc
Copy link
Member

@grahamc grahamc commented Sep 18, 2018

If meta.outputsToInstall is set to include absent outputs, various
tools break including channel updates and nix-env.

grahamc@Morbo> nix-env -i -f . -A elf-header-real
installing 'elf-header'
error: this derivation has bad 'meta.outputsToInstall'

This patch verifies each value in meta.outputsToInstall is a valid
output. It validates this condition only if checkMeta is true.

grahamc@Morbo> nix-build . -A elf-header-real
error: Package ‘elf-header’ in /home/grahamc/projects/nixpkgs/pkgs/development/libraries/elf-header/default.nix:36 has invalid meta.outputsToInstall, refusing to evaluate.

The package elf-header has set meta.outputsToInstall to: bin

however elf-header only has the outputs: out

and is missing the following ouputs:

  - bin

(use '--show-trace' to show detailed location information)

Note, now the nix-env experience is decidedly worse for users who have
checkMeta set to true:

grahamc@Morbo> nix-env -i -f . -A elf-header-real; echo $?
0

though since this is already an issue for unfree, broken, unsupported,
and insecure validity problems I'm not sure we should do something
different here.

(cherry picked from commit b80c9ce)

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)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg GrahamcOfBorg added the 6.topic: stdenv Standard environment label Sep 18, 2018
@grahamc
Copy link
Member Author

grahamc commented Sep 18, 2018

@GrahamcOfBorg eval

If meta.outputsToInstall is set to include absent outputs, various
tools break including channel updates and nix-env.

    grahamc@Morbo> nix-env -i -f . -A elf-header-real
    installing 'elf-header'
    error: this derivation has bad 'meta.outputsToInstall'

This patch verifies each value in meta.outputsToInstall is a valid
output. It validates this condition only if checkMeta is true.

    grahamc@Morbo> nix-build . -A elf-header-real
    error: Package ‘elf-header’ in /home/grahamc/projects/nixpkgs/pkgs/development/libraries/elf-header/default.nix:36 has invalid meta.outputsToInstall, refusing to evaluate.

    The package elf-header has set meta.outputsToInstall to: bin

    however elf-header only has the outputs: out

    and is missing the following ouputs:

      - bin

    (use '--show-trace' to show detailed location information)

Note, now the nix-env experience is decidedly worse for users who have
checkMeta set to true:

    grahamc@Morbo> nix-env -i -f . -A elf-header-real; echo $?
    0

though since this is already an issue for unfree, broken, unsupported,
and insecure validity problems I'm not sure we should do something
different here.

(cherry picked from commit b80c9ce)
@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: elf-header-real, stdenv

Partial log (click to expand)

these paths will be fetched (0.03 MiB download, 0.16 MiB unpacked):
  /nix/store/0psyvq9qnn2v0j2kv9zk6qkknpyf7wc0-elf-header
copying path '/nix/store/0psyvq9qnn2v0j2kv9zk6qkknpyf7wc0-elf-header' from 'https://cache.nixos.org'...
/nix/store/0psyvq9qnn2v0j2kv9zk6qkknpyf7wc0-elf-header
/nix/store/95bw3cdcgc8c0rrvqwvhvc805pdv7rmx-stdenv-darwin

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: elf-header-real, stdenv

Partial log (click to expand)

/nix/store/9wx3gfqmqcr2w5s9gnp79zfjbvca8zi1-elf-header
/nix/store/pjq5v1xgljr4ygb1h1xfybdjydczcqiw-stdenv-linux

@grahamc grahamc merged commit 374d22d into NixOS:release-18.09 Sep 18, 2018
@grahamc grahamc deleted the check-outputs-in-meta-18.09 branch September 18, 2018 16:45
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: elf-header-real, stdenv

Partial log (click to expand)

these paths will be fetched (0.04 MiB download, 0.20 MiB unpacked):
  /nix/store/d90nn8g9711j6xfb89a7wl0yc66l7gzj-elf-header
  /nix/store/i6vl5lwlz5jbkg4r6p340dwmj6fha3xq-stdenv-linux
copying path '/nix/store/d90nn8g9711j6xfb89a7wl0yc66l7gzj-elf-header' from 'https://nix-cache.s3.amazonaws.com'...
copying path '/nix/store/i6vl5lwlz5jbkg4r6p340dwmj6fha3xq-stdenv-linux' from 'https://nix-cache.s3.amazonaws.com'...
/nix/store/d90nn8g9711j6xfb89a7wl0yc66l7gzj-elf-header
/nix/store/i6vl5lwlz5jbkg4r6p340dwmj6fha3xq-stdenv-linux

@Ericson2314
Copy link
Member

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants