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: Use args ? attr for passthru (closes #94246) #94251

Merged
merged 1 commit into from Aug 16, 2020

Conversation

twhitehead
Copy link
Contributor

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). Replaced with args ? attr as the args set does not contain defaulted values.

Motivation for this change

Closes #94246.

Things done

Besides verifying that accessing the derivation no longer forces any provided phase override strings, I rebuild a random haskell project I had after apply this change. The nix environment produced all the required packages and the program ran, so I presume all is still good.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@cdepillabout
Copy link
Member

@GrahamcOfBorg build haskellPackages.lens

// optionalAttrs (args ? preBuild) { inherit preBuild; }
// optionalAttrs (args ? postBuild) { inherit postBuild; }
// optionalAttrs (args ? doBenchmark) { inherit doBenchmark; }
// optionalAttrs (args ? checkPhase) { inherit checkPhase; }
Copy link
Member

Choose a reason for hiding this comment

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

In this PR, it looks like you're changing lines like

// optionalAttrs (checkPhase != "")     { inherit checkPhase; }

to lines like

// optionalAttrs (args ? checkPhase)             { inherit checkPhase; }

I think I understand your argument as to why this is a good change, but the logic changes slightly. Instead of comparing checkPhase to the empty string, you're now just checking whether args has a checkPhase field.

Is this going to cause any subtle bugs for users using things like checkPhase is a weird way?

It is hard to say whether this PR is okay, because I don't quite understand all the ramifications of this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of the code would be the only difference (beyond the increased laziness) is that the new one will pass through explicitly empty strings where the former would eat them (as it couldn't distinguish a passed empty string from a default empty string).

Copy link
Member

Choose a reason for hiding this comment

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

In that case, it sounds like this change is pretty good.

Copy link
Member

@cdepillabout cdepillabout left a comment

Choose a reason for hiding this comment

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

This looks good to me.

cc @peti and @maralorn about this as well.

@maralorn
Copy link
Member

This looks like a nice and reasonable change, but my nix foo is too weak to be sure about this.
Would be really good to know if e.g. cabal2nix makes assumptions about this. Even if we can build everything in nixpkgs with this, we could still break some downstream uses. (but maybe we should then)

@peti peti force-pushed the haskell-updates branch 3 times, most recently from 8a7eb3e to ed16234 Compare August 7, 2020 18:35
@maralorn
Copy link
Member

This somehow got forgotten, sorry. I think the change is reasonable and am willing to merge it.

But sadly can you first rebase it and clean the diff up?

…4246)

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).
@twhitehead
Copy link
Contributor Author

Should be good now (was just issues with other commits in the Haskell branch).

@maralorn
Copy link
Member

Great, thanks!

But now I am a bit worried about the test results. ofBorg is claiming this changes the output hash of quite a lot of packages..

I mean this could be completely harmless but I am a bit worried about it. And would feel much more at ease if we were to know, how those packages changed. It is my understanding that this change is not supposed to change packages, is it?

@maralorn
Copy link
Member

I have the feeling that nearly all this packages are opengl related. So this might well come down to one single weird package that uses some in-band coding …

@twhitehead
Copy link
Contributor Author

It will now pass on empty strings where the prior one would eat them (i.e., if you passed postBuild = "", the prior version would eat it, now it will honor it and pass on postBuild = ""). It may be that a base OpenGL package, for example, does this.

@maralorn
Copy link
Member

Okay, I think the culprit is:

preConfigure = pkgs.lib.optionalString pkgs.stdenv.isDarwin ... for OpenGLRaw in configuration-nix.nix.

@maralorn
Copy link
Member

@GrahamcOfBorg build haskellPackages.OpenGLRaw

@twhitehead
Copy link
Contributor Author

That would make sense. preConfigure would be "" on linux, which the previous would have eaten. Now it passes it along.

If I recall the shell scripts that do the actually building, they don't distinguish between not set and set to empty, so it won't change the result, but it will change the hash.

Technically you do a quoted attribute name expression on the LHS that returns null if you don't want the attribute to avoid passing in "", but it isn't very standard.

@maralorn
Copy link
Member

Thx for the PR!

@maralorn maralorn merged commit 78efdb0 into NixOS:haskell-updates Aug 16, 2020
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