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

Haskell generic builder is strict in all the optionalAttrs #94246

Closed
twhitehead opened this issue Jul 30, 2020 · 2 comments
Closed

Haskell generic builder is strict in all the optionalAttrs #94246

twhitehead opened this issue Jul 30, 2020 · 2 comments

Comments

@twhitehead
Copy link
Contributor

twhitehead commented Jul 30, 2020

Describe the bug

I believe the way the various stage overrides were implemented using set extensions calls with optionalAttrs at the end of the generic builder has the unintended consequence of making these all strict at the level of the derivation itself.

That is, the final expressions like

...
// optionalAttrs (postInstall != "")    { inherit postInstall; }
...

extend the derivation set, so they need to be evaluated to the point of their attribute names if any part of the derivation is accessed. The means that the arguments like postInstall are full forced in order to compare to "".

This causes top-level haskell breakage when there is any quoting that references a broken package.

To Reproduce

Here is a simple example using the current haskell-updates

$ [tyson@tux:~/nixpkgs]$ nix build -I nixpkgs=. --argstr crossSystem powerpc64le-linux nixpkgs.haskell.packages.ghc8101
error: Package ‘z3-4.8.7’ in /home/tyson/nixpkgs/pkgs/applications/science/logic/z3/default.nix:36 is not supported on ‘powerpc64le-linux’, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.

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

When you run with --show-trace and dig through it, z3 is getting evaluated as the cryptol package (which is actually marked as broken) has a configuration-common override that quotes the z3 package

    postInstall = drv.postInstall or "" + ''
      for b in $out/bin/cryptol $out/bin/cryptol-html; do
        wrapProgram $b --prefix 'PATH' ':' "${pkgs.lib.getBin pkgs.z3}/bin"
      done
    '';

Expected behavior

The z3 package should not have any effect on a request for ghc as it is not a dependency.

Additional context

I believe the safe way to test if arguments were passed or defaulted is to check if they are in args as it is strictly the ones that were passed

nix-repl> example = { value ? throw "evaluated" } @ args: if args ? value then "provided" else "not provided"
nix-repl> example { }
"not provided"
nix-repl> example { value = throw "looked"; }
"provided"

I'll put together a pull request.

Notify maintainers

@peti @infinisil @jmininger as writer of original lines and people who have made recent larger modifications to the generic builder

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.4.42, NixOS, 20.03.1950.48723f48ab9 (Markhor)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(root): "nixos-20.03.1950.48723f48ab9"
  • channels(tyson): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@twhitehead
Copy link
Contributor Author

twhitehead commented Jul 30, 2020

Just noticed that the example I distilled to present was to build the ghc8101 package set itself, which doesn't actually make sense. A better example would have been to build the ghc8101.cryptol package (as an example of one that provides a phase with a quoted broken package in it)

Corrected To Reproduce

$ [tyson@tux:~/nixpkgs]$ nix build -I nixpkgs=. --argstr crossSystem powerpc64le-linux nixpkgs.haskell.packages.ghc8101.cryptol
error: Package ‘z3-4.8.7’ in /home/tyson/nixpkgs/pkgs/applications/science/logic/z3/default.nix:36 is not supported on ‘powerpc64le-linux’, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.

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

Corrected Expected behavior

The cryptol package is marked as broken, so there should be a message to this effect.

maralorn pushed a commit that referenced this issue Aug 16, 2020
Comparing to a default value to detect if an argument was provided
forces it to at least WHNF, which can cause failure (e.g., if the
argument is a string with a quoted path from a broken package).
maralorn added a commit that referenced this issue Aug 16, 2020
haskell-generic-builder: Use args ? attr for passthru (closes #94246)
@maralorn
Copy link
Member

I guess this is fixed via the merge of #94251.

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

No branches or pull requests

2 participants