Hiding a (Haskell) package

I’m the developer of two related Haskell packages, sandi and omnicodec.

My rather naïve first attempt to use Nix to build them both is this

with (import <nixpkgs> {});

let
  t = lib.trivial;
  hl = haskell.lib;

  addBuildTools = (t.flip hl.addBuildTools) [haskellPackages.cabal-install];

  sandiPkg = haskellPackages.developPackage {
    root = ./sandi;

    modifier = (t.flip t.pipe)
      [addBuildTools];
  };

  omnicodecPkg = haskellPackages.developPackage {
    root = ./omnicodec;

    modifier = (t.flip t.pipe)
      [addBuildTools];
  };

in {
  sandi = sandiPkg;
  omnicodec = omnicodecPkg;
}

It does work, but one thing I noticed is that since sandi is packaged in nixpkgs it’s the upstream package that’s used rather than the local development version.

How do I go about forcing the build of omnicodec to use the local sandi instead of the one in nixpkgs?

After some help and a pointer to a SO question I managed to get this sorted.

The working expression I have is

with (import <nixpkgs> {});

let
  t = lib.trivial;
  hl = haskell.lib;

  addBuildTools = (t.flip hl.addBuildTools) [haskellPackages.cabal-install];

  sandiPkg = haskellPackages.developPackage {
    root = ./sandi;

    modifier = (t.flip t.pipe)
      [addBuildTools];
  };

  myHaskellPackages = pkgs.haskell.packages.ghc865.override {
    overrides = self: super: rec {
      sandi = sandiPkg;
    };
  };

  omnicodecPkg = myHaskellPackages.developPackage {
    root = ./omnicodec;

    modifier = (t.flip t.pipe)
      [addBuildTools];
  };

in {
  sandi = sandiPkg;
  omnicodec = omnicodecPkg;
}

Further comments and improvements are of course more than welcome!

Hosted by Flying Circus.