Use latest version of scotty when using Nix

I’m using Nix and Haskell using the Serokell flake template (meaning I just use haskellPackages.callCabal2nix packageName to package my application). I have build-depends: scotty in my .cabal file. That pulls in an old version of scotty (0.12). I’m seeing a newer version available in nixpkgs as haskellPackages.scotty_0_21. How do I tell Nix to use that version instead?

Since it’s pulling from nixpkgs, you probably need to run nix flake update to pin a newer version.

Seems like that template uses it’s own flake registry which points to serokell’s own fork of nixpkgs …

For that reason it’s probably a poor starting point :sweat_smile:

Maybe trying starting from something like this instead - https://github.com/isovector/cornelis/blob/master/flake.nix - it’s a bit more idiomatic.

I’m not sure what serokell’s flake looks like, but assuming you’re using something like haskellPackages, you can add an override like:

compiler = pkgs.haskell.packages."${ghc-version}".override {
  overrides = final: prev: {
    # if it's in nixpkgs but not the default
    scotty = prev.scotty_0_21;

    # not in nixpkgs, but in cabal per nixpkgs' cabal's index-state
    # scotty = final.callHackage "scotty" "0.21" { };

    # last resort, not in nixpkgs nor in index-state
    # scotty = (final.callHackageDirect
    #    {
    #      pkg = "scotty";
    #      ver = "0.21";
    #      sha256 = "sha256-<hash>";
    #    }
    #    { });
  }
}

2 Likes

That fixed it. Thanks!

1 Like

btw the latest-latest version is 0.22 :wink:

2 Likes