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: don't lose packageOverrides for native-bignum and integer-simple #167956

Conversation

cdepillabout
Copy link
Member

@cdepillabout cdepillabout commented Apr 9, 2022

Description of changes

This updates haskell.packages.{native-bignum,integer-simple}.* so that the new haskell packages added to packageOverrides are kept in the native-bignum and integer-simple package sets.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@cdepillabout cdepillabout force-pushed the haskell-bignum-dont-lose-overrides branch from 75ceffd to 49d1461 Compare April 9, 2022 02:15
@cdepillabout
Copy link
Member Author

cdepillabout commented Apr 9, 2022

Here is a file that can be used to test this change:

test.nix:

let

  nixpkgs-src = /some/path/to/your/nixpkgs/repo;

  my-overlay = final: prev: {
    haskell = prev.haskell // {
      packageOverrides =
        final.lib.composeExtensions
          (prev.haskell.packageOverrides or (_: _: {}))
          (hfinal: hprev: {
            my-new-package = hfinal.conduit;
          });
    };
  };

  pkgs = import nixpkgs-src { overlays = [my-overlay]; };
in
pkgs.haskell.packages.native-bignum.ghc902.my-new-package

If you build this with the change from this PR, it successfully builds conduit through the my-new-package attribute:

$ nix-build test.nix
...
/nix/store/hcd5c14hcx0dw76cbk9xhnbyf0xs9181-conduit-1.3.4.2

However, if you're not using this PR, then you get an error about the my-new-package attribute not being able to be found (for instance, with commit d685083):

$ nix-build test.nix
error: attribute 'my-new-package' missing

       at /home/illabout/temp/what012.nix:21:1:

           21| pkgs.pkgsStatic.haskellPackages.my-new-package
             | ^

Comment on lines 269 to 278
native-bignum =
let
nativeBignumGhcNames = pkgs.lib.filter
(name: builtins.elem name nativeBignumIncludes)
(pkgs.lib.attrNames compiler);
in
pkgs.lib.genAttrs nativeBignumGhcNames
(name:
packages.${name}.override (oldAttrs: {
ghc = bh.compiler.native-bignum.${name};
buildHaskellPackages = bh.packages.native-bignum.${name};
overrides =
pkgs.lib.composeExtensions
(oldAttrs.overrides or (_: _: {}))
(_: _: { integer-gmp = null; });
})
);
Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored this to make it a little easier to see exactly what is going on.

The only non-whitespace change is going from

      overrides = _self : _super : {
        integer-gmp = null;
      };

to

            overrides =
              pkgs.lib.composeExtensions
                (oldAttrs.overrides or (_: _: {}))
                (_: _: { integer-gmp = null; });

With this change, we make sure to keep any old overrides.

This is important because package.${name} is going to refer to one of the Haskell package sets. For instance:

ghc902 = callPackage ../development/haskell-modules {
buildHaskellPackages = bh.packages.ghc902;
ghc = bh.compiler.ghc902;
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-9.0.x.nix { };
};

You can see that this is defined with callPackage, which is defined in that same file:

callPackage = newScope {
haskellLib = haskellLibUncomposable.compose;
overrides = pkgs.haskell.packageOverrides;
};

callPackage specifically defines overrides as packageOverrides. The change in this PR makes sure not to lose this.

pkgs/top-level/haskell-packages.nix Outdated Show resolved Hide resolved
pkgs/top-level/haskell-packages.nix Outdated Show resolved Hide resolved
@cdepillabout cdepillabout force-pushed the haskell-bignum-dont-lose-overrides branch from 49d1461 to aaf6ac1 Compare April 12, 2022 05:11
It appears that integer-gmp is already set to null for all compilers,
so there is no need to explicitly set it to null in the integer-simple
and native-bignum package sets.
@cdepillabout cdepillabout force-pushed the haskell-bignum-dont-lose-overrides branch from aaf6ac1 to 1be5cae Compare April 12, 2022 05:16
@sternenseemann sternenseemann merged commit 88d8a0f into NixOS:haskell-updates Apr 12, 2022
@cdepillabout cdepillabout deleted the haskell-bignum-dont-lose-overrides branch April 12, 2022 11:26
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.

2 participants