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: Fix developPackage ignoring extend #88841

Draft
wants to merge 23 commits into
base: haskell-updates
Choose a base branch
from

Conversation

Aver1y
Copy link
Contributor

@Aver1y Aver1y commented May 25, 2020

Motivation for this change

Previously developPackage would ignore extend, because extensible-self
would still refer to the unextended package set even after an extend,
i.e.:

(haskellPackages.extend f).developPackage = haskellPackages.developPackage

This fixes this by using extends on self.__unfix__ instead of using
extensible-self. Since extensible-self wasn't otherwise used it was
removed.

Things done
  • 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.

overrides))
.callCabal2nix name root {};
let
extendFix' = f: fixed: fix' (extends f fixed.__unfix__);
Copy link
Member

Choose a reason for hiding this comment

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

Would you be able to add a comment here on what extendFix' is doing? It is not immediately obvious to me what it is doing, or why it would be needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would like to call extend on self, but that is not available. However for fixed points that were taken using fix' we can get the same effect by calling extends on the __unfix__ attribute and taking the fixed point again.

Would that be OK?

@cdepillabout
Copy link
Member

@Aver1y Thanks for trying to fix this up.

Two things:

  • Do you have a short reproducible example of how developPackage fails without this change? (And how it is fixed with this change?)
  • Could you send this PR to the haskell-updates branch (instead of master).

cc @peti, @Ericson2314, and @matthewbauer to get some more eyeballs on this.

@Aver1y
Copy link
Contributor Author

Aver1y commented May 25, 2020

Here is an example:

default.nix

{ pkgs ? import <nixpkgs> {} }:

(pkgs.haskellPackages.extend (self: super: {
  base-with-a-strange-name = self.base;
})).developPackage {
  root = ./.;
}

example.cabal

name:                example
version:             0.1.0.0

library
  build-depends:       base-with-a-strange-name

Before patch

$ nix-build
error: anonymous function at [...] called without required argument 'base-with-a-strange-name', at [...]

After

$ nix-build --arg pkgs "import ../nixpkgs {}"
 derivations will be built:
  /nix/store/apdqihqw89l1z2d2sxcr02q0wz6dfjkx-example-0.1.0.0.drv
building '/nix/store/apdqihqw89l1z2d2sxcr02q0wz6dfjkx-example-0.1.0.0.drv'...
[...]

@Aver1y Aver1y changed the base branch from master to haskell-updates May 25, 2020 01:27
@Aver1y Aver1y force-pushed the haskell-developPackage-extend branch from 1b399af to 0cf7349 Compare May 25, 2020 01:35
@Aver1y Aver1y marked this pull request as draft May 25, 2020 01:40
@Aver1y Aver1y force-pushed the haskell-developPackage-extend branch from 0cf7349 to 924e509 Compare May 25, 2020 01:50
@Aver1y Aver1y marked this pull request as ready for review May 25, 2020 01:51
@Aver1y
Copy link
Contributor Author

Aver1y commented May 26, 2020

Noticed the same pattern pop up here:

let newScope = mkScope (fix' (extends f scope.__unfix__));

@Aver1y
Copy link
Contributor Author

Aver1y commented May 26, 2020

Maybe we could even add it to fixed-points.nix?

@peti peti force-pushed the haskell-updates branch 8 times, most recently from 7a3d6f0 to ad62b57 Compare June 5, 2020 19:58
@peti peti force-pushed the haskell-updates branch 3 times, most recently from 2c7ad11 to 0e5f7e8 Compare December 18, 2020 19:28
@peti peti force-pushed the haskell-updates branch 3 times, most recently from ba32886 to c9e5a3f Compare January 2, 2021 18:58
@peti peti force-pushed the haskell-updates branch 2 times, most recently from a0a57d7 to 952ebcf Compare January 22, 2021 19:34
@peti peti force-pushed the haskell-updates branch 4 times, most recently from 4c606a9 to 3ae580b Compare February 12, 2021 19:36
@peti peti force-pushed the haskell-updates branch 3 times, most recently from 56fa6fc to f3cb253 Compare February 19, 2021 19:56
@maralorn maralorn closed this May 7, 2021
@maralorn maralorn deleted the branch NixOS:haskell-updates May 7, 2021 21:55
@maralorn maralorn reopened this May 7, 2021
@sternenseemann sternenseemann deleted the branch NixOS:haskell-updates May 19, 2021 01:53
@Aver1y Aver1y requested a review from expipiplus1 as a code owner June 19, 2021 12:27
@stale
Copy link

stale bot commented Jan 3, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 3, 2022
@wegank wegank marked this pull request as draft March 20, 2024 15:45
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

9 participants