Help overriding a derivations runtime Haskell dependencies (reproducible pinned nix file included)

Edit: I’m working through the problem on my own and pasting progress in hopes maybe someone can correct any of my misunderstandings, but feel free to just post a solution if you have one and don’t feel like sorting through my confusions :laughing:

I’m trying to use ob-diagrams which requires diagrams-builder, a package currently broken in nixpkgs unstable (and others too).

my attempt in a pinned and self-contained `diagrams-builder.nix` file
# Command
# nix-build diagrams-builder.nix 

# Error
#
# Setup: Encountered missing or private dependencies:
# haskell-src-exts ==1.22.*

# builder for '/nix/store/9mwklkck5gjjd0adk2jdkrm5zbhyy16b-haskell-src-exts-simple-1.22.0.0.drv' failed with exit code 1
# cannot build derivation '/nix/store/iw613czqivarhr12xbgj8rri7j4m0w8x-diagrams-builder.drv': 1 dependencies couldn't be built
# error: build of '/nix/store/iw613czqivarhr12xbgj8rri7j4m0w8x-diagrams-builder.drv' failed

# Code
let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") {};
    my-haskell-src-exts =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts";
          ver = "1.22.0";
          sha256 = "0jwp8vhk3ncfxprbmg0jx001g7mh1kyp16973mjkjqz0d60zarwi";
        } {};
    my-haskell-src-exts-simple =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts-simple";
          ver = "1.22.0.0";
          sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
        } {};
    diagrams-postscript = 
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "diagrams-postscript";
          ver = "1.4.1";
          sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
        } {};
in pkgs.diagrams-builder.overrideAttrs( oldAttrs : {
  haskell-src-exts = my-haskell-src-exts;
  haskell-src-exts-simple = my-haskell-src-exts-simple;
})

Alright, I’ve simplified to the subproblem of building my older version of haskell-src-exts-simple and that seems to be working (but is stil compiling):

let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") {};
    my-haskell-src-exts =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts";
          ver = "1.22.0";
          sha256 = "0jwp8vhk3ncfxprbmg0jx001g7mh1kyp16973mjkjqz0d60zarwi";
        } {};
    my-haskell-src-exts-simple =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts-simple";
          ver = "1.22.0.0";
          sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
        } {};
in my-haskell-src-exts-simple.override( {
  haskell-src-exts = my-haskell-src-exts;
})

Didn’t build. Is haskell-src-exts a boot package?

Guess so:

nix-repl> pkgs.haskell.compiler.ghc883.bootPkgs.haskell-src-exts
«derivation /nix/store/kymisyrf6rgyjkilvkqdx1hhjd612nvc-haskell-src-exts-1.23.1.drv»

I was trying to override each package and thinking it would work out. What I really wnated to do was override haskellPackages for this build of the diagrams-builder derivations digrams-builder haskell dependency like this (still compiling… but feel like this will work):

let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") {};
    my-haskell-src-exts =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts";
          ver = "1.22.0";
          sha256 = "0jwp8vhk3ncfxprbmg0jx001g7mh1kyp16973mjkjqz0d60zarwi";
        } {};
    my-haskell-src-exts-simple =
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "haskell-src-exts-simple";
          ver = "1.22.0.0";
          sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
        } {};
    diagrams-postscript = 
      pkgs.haskellPackages.callHackageDirect 
        { pkg = "diagrams-postscript";
          ver = "1.4.1";
          sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
        } {};
    myHaskellPackages = pkgs.haskellPackages.override {
      overrides = self: super: {
        haskell-src-exts = my-haskell-src-exts;
        haskell-src-exts-simple = my-haskell-src-exts-simple;
      };
    };
in pkgs.diagrams-builder.override( {
      diagrams-builder = myHaskellPackages.diagrams-builder;
})

I got closer, then was stymied by infinite recursion encountered in the end:

$ nix-build nixpkgs/b.nix
error: infinite recursion encountered, at /home/cody/hci/nixpkgs/b.nix:11:13
(use '--show-trace' to show detailed location information)

using:

let
  mypkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") { overlays = [overlay]; };
  overlay = self: super: {
    haskellPackages = 
      super.haskell.packages.ghc883.override (old: {

        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {

            ghcWithPackages = hself.ghc.withPackages;
            diagrams-postscript = self.haskell.lib.doJailbreak (hself.callHackageDirect 
                  { pkg = "diagrams-postscript";
                    ver = "1.4.1";
                    sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
                  } {});

            diagrams-builder = self.haskell.lib.doJailbreak (hsuper.diagrams-builder);


          });
      }
      );
  };
# This is building now, so progress
# in mypkgs.haskellPackages.diagrams-builder

# The following gives:
# error: infinite recursion encountered, at /home/cody/hci/nixpkgs/b.nix:11:13
# (use '--show-trace' to show detailed location information)
in mypkgs.diagrams-builder

What helped me was working by default from within the nix repl from the lowest level dependency I had an issue with:

[cody@nixos:~/hci/nixpkgs]$ nix repl
Welcome to Nix version 2.3.6. Type :? for help.

nix-repl> pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") {}
nix-repl> :b pkgs.haskellPackages.diagrams-builder                                                        builder for '/nix/store/abggggz6k0wwalyc6p22czp6swdh4k81-diagrams-builder-0.8.0.5.drv' failed with exit code 1; last 10 log lines:
    configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:475:12 in Cabal-3.0.1.0:Distribution.Simple.Configure
    configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:625:20 in Cabal-3.0.1.0:Distribution.Simple
    confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.0.1.0:Distribution.Simple.UserHooks
    configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.0.1.0:Distribution.Simple
    defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.0.1.0:Distribution.Simple
    defaultMain, called at Setup.hs:2:8 in main:Main
  Setup: Encountered missing or private dependencies:
  haskell-src-exts >=1.18 && <1.23,
  haskell-src-exts-simple >=1.18 && <1.23
[0 built (1 failed)]
error: build of '/nix/store/abggggz6k0wwalyc6p22czp6swdh4k81-diagrams-builder-0.8.0.5.drv' failed

nix-repl> :b pkgs.haskell.lib.doJailbreak pkgs.haskellPackages.diagrams-builder
builder for '/nix/store/h7c2zgrjrrcc2w6qalk52y8c0sbc8m4l-diagrams-builder-0.8.0.5.drv' failed with exit code 1; last 10 log lines:
    die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:1022:20 in Cabal-3.0.1.0:Distribution.Simple.Configure
    configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:475:12 in Cabal-3.0.1.0:Distribution.Simple.Configure
    configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:625:20 in Cabal-3.0.1.0:Distribution.Simple
    confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.0.1.0:Distribution.Simple.UserHooks
    configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.0.1.0:Distribution.Simple
    defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.0.1.0:Distribution.Simple
    defaultMain, called at Setup.hs:2:8 in main:Main
  Setup: Encountered missing or private dependencies:
  diagrams-postscript ==1.4.*
[0 built (1 failed)]
error: build of '/nix/store/h7c2zgrjrrcc2w6qalk52y8c0sbc8m4l-diagrams-builder-0.8.0.5.drv' failed

nix-repl> 

Then I added the overlay into my file, but pasted the multiple line overlay directly into the repl to test things work there.

This super incremental workflow helped, whereas yesterday all the moving pieces made things very confusing.

Edit: I’ll also note that I hit a lot of recursion errors because of things like mixing up self/super such as diagrams-builder = self.haskell.lib.doJailbreak (hself.diagrams-builder). I thought that hself was correct here because it would be the end result but before things were tied together. Since I’m using hsuper here actually, it means that none of the overlays in the block will take affect on the diagrams-builder dependency right?

Maybe that’s part of my problem?

I looked at the source of diagrams-builder.nix and see it takes ghcWithPackages as an argument.

I passed mine in and got:

nix-build nixpkgs/b.nix
error: infinite recursion encountered, at /home/cody/hci/nixpkgs/b.nix:10:13
(use '--show-trace' to show detailed location information)

Using code:

let
  mypkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") { overlays = [overlay]; };
  overlay = self: super: {
    myHaskellPackages = 
      super.haskell.packages.ghc883.override (old: {

        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {

            ghcWithPackages = hself.ghc.withPackages;
            diagrams-postscript = self.haskell.lib.doJailbreak (hself.callHackageDirect 
                  { pkg = "diagrams-postscript";
                    ver = "1.4.1";
                    sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
                  } {});

            diagrams-builder = self.haskell.lib.doJailbreak (hsuper.diagrams-builder);

          });
      }
      );
  };

# try using my overlayed version of haskellPackages
in mypkgs.diagrams-builder.override( { ghcWithPackages = mypkgs.myHaskellPackages.ghcWithPackages; } )
# error:
# error: infinite recursion encountered, at /home/cody/hci/nixpkgs/b.nix:10:13
# (use '--show-trace' to show detailed location information)

# verify it works without my overriden version; it does

# in mypkgs.diagrams-builder.override( { ghcWithPackages = mypkgs.haskellPackages.ghcWithPackages; } )

# first thought this would work, no luck

# in mypkgs.diagrams-builder { ghcWithPackages = mypkgs.myHaskellPackages.ghcWithPackages; }

# looked at the source of diagrams-builder.nix, see ghcWithPackages can be passed in

I can kind of see why this would happen in a fuzzy way… maybe.

The ghcWithpackages I pass in is used to build:

  wrappedGhc = ghcWithPackages 
    (self: [ diagrams-builder ] ++ extraPackages self);

I don’t think my overlay ever overrode pkgs.diagrams-builder though, which is what I understand diagrams-builder to mean there rather than pkgs.haskellPackages.diagrams-builder. Unless both are the same?

It looks like this line causes it:

ghcWithPackages = hself.ghc.withPackages;

However without that line I’m just back to my overlay not applying:

CallStack (from HasCallStack):
  die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:1022:20 in Cabal-3.0.1.0:Distribution.Simple.Configure
  configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:475:12 in Cabal-3.0.1.0:Distribution.Simple.Configure
  configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:625:20 in Cabal-3.0.1.0:Distribution.Simple
  confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:65:5 in Cabal-3.0.1.0:Distribution.Simple.UserHooks
  configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:180:19 in Cabal-3.0.1.0:Distribution.Simple
  defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:116:27 in Cabal-3.0.1.0:Distribution.Simple
  defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing or private dependencies:
haskell-src-exts >=1.18 && <1.23,
haskell-src-exts-simple >=1.18 && <1.23

I do wonder if I’m affected by Overriding (Haskell) packages repeatedly is surprising and non-modular #25887

Edit: Well I guess the official issue is “haskellPackages.extend” and “haskellPackages.override” are incompatible #26561

Nope, nevermind. This is the reason the guide I grabbed the override code from suggested:

haskellPackages.override (old: {
  overrides = lib.composeExtensions (old.overrides or (_: _: {})) (self: super: {
    # ...
  });
})

But for some reason I’m getting a (maybe unrelated) infinite recursion error.

minimal code for the infinite recursion error:

let
  mypkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") { overlays = [overlay]; };
  overlay = self: super: {
    myHaskellPackages = 
      super.haskell.packages.ghc883.override (old: {
        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {
            ghcWithPackages = hself.ghc.withPackages;
          });
      }
      );
  };

in mypkgs.diagrams-builder.override( { ghcWithPackages = mypkgs.myHaskellPackages.ghcWithPackages; } )

# error:
# error: infinite recursion encountered, at /home/cody/hci/nixpkgs/b.nix:10:13
# (use '--show-trace' to show detailed location information)

In the repl I actually discovered myHaskellPackages itself is somehow wrong and encounters infinite recursion:

nix-repl> mypkgs.myHaskellPackages.ghcWithPackages
error: infinite recursion encountered, at (string):6:13
          (hself: hsuper: {
            ghcWithPackages = hself.ghc.withPackages;
          });

The problem here is simply that ghc.withPackages is internally defined as self.ghcWithPackages so every attempt of doing this will fail. If you rename the left-hand-side, everything is good. However, you needn’t even go through the trouble, as both myHaskellPackages.ghcWithPackages and the withPackages versions are automatically computed from your fixpoint.

1 Like

Thanks!

From “rename the left hand side” I got that I should do:

   (hself: hsuper: {
            myGhcWithPackages = hself.ghc.withPackages;
          });

and use it like:

in mypkgs.diagrams-builder.override(
  { ghcWithPackages = mypkgs.myHaskellPackages.myGhcWithPackages;
  } )

I’m a little fuzzy on this one. Does that mean that if I get rid of myGhcWithPackages = hself.ghc.withPackages; entirely then when I later try to access myHaskellPackages.ghcWithPackages it will contain any of the overlay definitions I’ve provided?

This explicitly bound the left hand side first as you suggested, and that lets me build mypkgs.myHaskellPackages.diagrams-builder successfully. Here is the working code:

Working Code to build pkgs.myHaskellPackages.diagrams-builder
let
  mypkgs = import
    (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz")
    { overlays = [overlay]; };

  overlay = self: super: {
    myHaskellPackages = 
      super.haskell.packages.ghc883.override (old: {

        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {

            myGhcWithPackages = hself.ghc.withPackages;

            haskell-src-exts = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts";
                  ver = "1.22.0";
                  sha256 = "1w1fzpid798b5h090pwpz7n4yyxw4hq3l4r493ygyr879dvjlr8d";
                } {});

            haskell-src-exts-simple = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts-simple";
                  ver = "1.22.0.0";
                  sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
                } {});

            diagrams-postscript = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "diagrams-postscript";
                  ver = "1.4.1";
                  sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
                } {});

            diagrams-builder = self.haskell.lib.doJailbreak (
              hsuper.diagrams-builder);

          });
      }
      );
  };
in mypkgs.myHaskellPackages.diagrams-builder

That doesn’t solve my overall issue of getting mypkgs.diagrams-builder to build however:

Failing attempt to build pkgs.diagrams-builder with myHaskellPackages passed in
let
  mypkgs = import
    (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz")
    { overlays = [overlay]; };

  overlay = self: super: {
    myHaskellPackages = 
      super.haskell.packages.ghc883.override (old: {

        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {

            myGhcWithPackages = hself.ghc.withPackages;

            haskell-src-exts = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts";
                  ver = "1.22.0";
                  sha256 = "1w1fzpid798b5h090pwpz7n4yyxw4hq3l4r493ygyr879dvjlr8d";
                } {});

            haskell-src-exts-simple = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts-simple";
                  ver = "1.22.0.0";
                  sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
                } {});

            diagrams-postscript = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "diagrams-postscript";
                  ver = "1.4.1";
                  sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
                } {});

            diagrams-builder = self.haskell.lib.doJailbreak (
              hsuper.diagrams-builder);

          });
      }
      );
  };

in mypkgs.diagrams-builder.override(
  { ghcWithPackages = mypkgs.myHaskellPackages.myGhcWithPackages;
  } )

Returns:

Setup: Encountered missing or private dependencies:
haskell-src-exts >=1.18 && <1.23,
haskell-src-exts-simple >=1.18 && <1.23

builder for '/nix/store/abggggz6k0wwalyc6p22czp6swdh4k81-diagrams-builder-0.8.0.5.drv' failed with exit code 1
cannot build derivation '/nix/store/g62x0xqf6fhk7lmryvzx7yga04v5adzd-diagrams-builder.drv': 1 dependencies couldn't be built
error: build of '/nix/store/g62x0xqf6fhk7lmryvzx7yga04v5adzd-diagrams-builder.drv' failed

I think this is a separate issue though and we’ve solved the subproblem I had of overriding pkgs.myHaskellPackages.diagrams-builder.

Now I think I’m overriding ghcWithPackages for pkgs.diagrams-builder incorrectly somehow but not sure how yet.

I also tried defining my override in the same place just in case that mattered, but I don’t think it does and I get the same error:

Code moving diagrams-builder overrides into overlay that still doesn't work
let
  mypkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz") { overlays = [overlay]; };

  overlay = self: super: {

    diagrams-builder = super.diagrams-builder.override({
      ghcWithPackages = mypkgs.myHaskellPackages.myGhcWithPackages;
    });

    myHaskellPackages = 
      super.haskell.packages.ghc883.override (old: {

        overrides = self.lib.composeExtensions (old.overrides or (_: _: {})) 
          (hself: hsuper: {

            myGhcWithPackages = hself.ghc.withPackages;

            haskell-src-exts = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts";
                  ver = "1.22.0";
                  sha256 = "1w1fzpid798b5h090pwpz7n4yyxw4hq3l4r493ygyr879dvjlr8d";
                } {});

            haskell-src-exts-simple = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "haskell-src-exts-simple";
                  ver = "1.22.0.0";
                  sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
                } {});

            diagrams-postscript = self.haskell.lib.doJailbreak (
              hself.callHackageDirect 
                { pkg = "diagrams-postscript";
                  ver = "1.4.1";
                  sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
                } {});

            diagrams-builder = self.haskell.lib.doJailbreak (
              hsuper.diagrams-builder);

          });
      }
      );
  };

in mypkgs.diagrams-builder

I can prove the pkgs.diagrams-builder overlay is working in some sense though, because setting it to null causes the expected error.

code
  overlay = self: super: {
    diagrams-builder = super.diagrams-builder.override(old: {
      ghcWithPackages = mypkgs.myHaskellPackages.myGhcWithPackages;
    });

returns:


nix-build nixpkgs/b.nix
error: attempt to call something which is not a function but null, at /nix/store/w6dk02ic80jvwmy61gag4sprr4q85dc2-source/pkgs/tools/graphics/diagrams-builder/default.nix:18:16
(use '--show-trace' to show detailed location information)

I’ve kind of lost track of the experiments by now, so let me give a working solution instead. I’ve tried to separate out the explanation of callHackage troubles. I’m not sure exactly what gave you troubles in the simpler case where we’re not touching cabal2nix dependencies, so please feel free to ask.

Your attempt (more or less, cleaned up a bit)

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz";
  pkgs = import nixpkgs {
    overlays = [ overlay ];
    config.allowBroken = true;
  };

  overlay = self: super: {
    haskellPackages = super.haskellPackages.override (old: with self.haskell.lib; {
      overrides = self.lib.composeExtensions (old.overrides or (_: _: {}))
      (hself: hsuper: {
        # call[...] all depend upon cabal2nix which in turn depends
        # (transitively) upon haskell-src-exts. Break the cycle here.
        # There are many way to do this, and which is preferable depends on the
        # use case. I like to cheese it massively by just borrowing cabal2nix
        # from the old pkgs.
        cabal2nix = super.haskellPackages.cabal2nix;

        haskell-src-exts = hself.callHackageDirect {
          pkg = "haskell-src-exts";
          ver = "1.22.0";
          sha256 = "1w1fzpid798b5h090pwpz7n4yyxw4hq3l4r493ygyr879dvjlr8d";
        } {};

        haskell-src-exts-simple = hself.callHackageDirect {
          pkg = "haskell-src-exts-simple";
          ver = "1.22.0.0";
          sha256 = "1ixx2bpc7g6lclzrdjrnyf026g581rwm0iji1mn1iv03yzl3y215";
        } {};

        diagrams-postscript = doJailbreak (hself.callHackageDirect {
          pkg = "diagrams-postscript";
          ver = "1.4.1";
          sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
        } {});

        diagrams-builder = doJailbreak (hsuper.diagrams-builder);
      });
    });
  };
in
  pkgs.diagrams-builder

Or minimal attempt, since you’re already jailbreaking:

let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c71518e75bf067fb639d44264fdd8cf80f53d75a.tar.gz";
  pkgs = import nixpkgs {
    overlays = [ overlay ];
    config.allowBroken = true;
  };

  overlay = self: super: {
    haskellPackages = super.haskellPackages.override (old: with self.haskell.lib; {
      overrides = self.lib.composeExtensions (old.overrides or (_: _: {}))
      (hself: hsuper: {
        diagrams-postscript = doJailbreak (hself.callHackageDirect {
          pkg = "diagrams-postscript";
          ver = "1.4.1";
          sha256 = "0174y4s6rx6cckkbhph22ybl96h00wjqqkzkrcni7ylxcvgf37bd";
        } {});

        diagrams-builder = doJailbreak (hsuper.diagrams-builder);
      });
    });
  };
in
  pkgs.diagrams-builder
1 Like

Oh and, to preempt a question, maybe:

I didn’t need to override pkgs.diagrams-builder directly, because I’m overriding its default inputs instead, namely ghcWithPackages and haskellPackages.diagram-builder. If instead I had called the new package set myHaskellPackages, I would have needed to explicitly override it like:

    diagrams-builder = super.diagrams-builder.override {
      inherit (self.myHaskellPackages) ghcWithPackages diagrams-builder;
    };
1 Like