Basic override for haskell package not working

New to nix. I’m trying to move my haskell project tinytools over to use nix. I have the following release.nix file

let
  nixpkgs = import <nixpkgs> {}; 
  compiler = "ghc96";
  mypkgs = nixpkgs.pkgs.haskell.packages.${compiler}.override {
    overrides = self: super: {
        reflex-test-host = nixpkgs.pkgs.haskellPackages.callHackageDirect {
            pkg = "reflex-test-host";
            ver = "0.1.2.3";
            sha256 = "9ee3ad9ac4fc58c6dcabcd9fbc6d109a51d8e86ba2682cee8367bc6b452f09ea";
          } {};
        reflex-vty = nixpkgs.pkgs.haskellPackages.callHackageDirect {
            pkg = "reflex-vty";
            ver = "0.5.1.0";
            sha256 = "ff25d77e771a08214f7e4e699fc31e16a6406bce51d3f35515430b882caafebd";
          } {};
        tinytools = nixpkgs.pkgs.haskellPackages.callHackageDirect {
            pkg = "tinytools";
            ver = "0.1.0.7";
            sha256 = "ff25d77e771a08214f7e4e699fc31e16a6406bce51d3f35515430b882caafebd";
          } {};
      };
    };

in
  mypkgs.callCabal2nix "tinytools-vty" (./.) { }

However, nix doesn’t seem to be fetching the overrides. Specifically, nix tries to build reflex-test-host-0.1.2.2 (as opposed to the override version 0.1.2.3) which will fail. I’m pretty sure it’s also not pulling the other dependencies listed as the hash for tinytools is incorrect and it did not complain about it.

I’ve tried a half dozen other slight variations thereof and continue running into the same issue. I don’t understand what I’m doing wrong. I’m following the guide here https://github.com/Gabriella439/haskell-nix/tree/main/project1

Anyone know how I might get this working?

Thanks in advance!

edit:

no matter what version I set for reflex-test-host in callHackageDirect, it outputs the following:

~/kitchen/faucet/tinytools-vty:potato$ nix-build release.nix
these 3 derivations will be built:
  /nix/store/mhc9yrdj6y9pk1p2sv4wkvih9z97c6w7-reflex-test-host-0.1.2.2.drv
  /nix/store/n03vcci91rxl8wr9qpn2gg50cb5jcnry-reflex-test-host-0.1.2.2.drv
  /nix/store/21pbrc0hwkl4mp9qih3ric9ji3j7v0l0-tinytools-vty-0.1.0.7.drv

I do not understand why it keeps trying to build 0.1.2.2.
Actually I even tried removing all erefrences to reflex-test-host throughout my entire project and it’s still producing the same output :sweat:

this turned out to be some weird caching related issue where in this case changing the sha256 and/or version field did nothing. I know there’s an issue where if the sha256 matched an older version caused it to use that one but in this case changing the sha256 did nothing. It was super weird. I setup a basically empty release.nix and it was still trying to build reflex-test-host-0.1.2.2 :.

running nix-collect-garbage fixed the issue.

Your inner calls to nixpkgs.pkgs.haskellPackages.callHackageDirect should instead be self.callHackageDirect, since you specifically want to use callHackageDirect from your overridden package set.

Also, when posting code snippets like this, you should really make sure to pin nixpkgs, otherwise it is more difficult for people to help you.

1 Like