Skip to content

haskell: don't lose packageOverrides for native-bignum and integer-simple#167956

Merged
sternenseemann merged 2 commits intoNixOS:haskell-updatesfrom
cdepillabout:haskell-bignum-dont-lose-overrides
Apr 12, 2022
Merged

haskell: don't lose packageOverrides for native-bignum and integer-simple#167956
sternenseemann merged 2 commits intoNixOS:haskell-updatesfrom
cdepillabout:haskell-bignum-dont-lose-overrides

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 added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Apr 9, 2022
@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.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 9, 2022
@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

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants