5

I use NixOS, and I'm trying to set up a Nix Haskell environment for my Haskell project. I have this Haskell package written in Nix that I'm trying to get working via nix-shell, but the dependent Haskell package Clay won't build, as described in this bug report I just opened. How can I override this package with a different (older or newer, I guess it doesn't matter) version of this Haskell package that works?

1

2 Answers 2

3

Not completely relevant, however I needed to modify an existing package that failed to build. I ended up with:

nixpkgs.config.packageOverrides = pkgs: {
    haskellPackages = pkgs.haskellPackages.override {
      overrides = hsSelf: hsSuper: {
        greenclip  = pkgs.haskell.lib.overrideCabal hsSuper.greenclip  (oa: {
          version = "3.1.1";
          sha256 = "1axh1q7kcvcnhn4rl704i4gcix5yn5v0sb3bdgjk4vgkd7fv8chw";
          executablePkgconfigDepends = oa.executablePkgconfigDepends ++ [pkgs.xorg.libXdmcp];
        });

        wordexp  = pkgs.haskell.lib.overrideCabal hsSuper.wordexp  (oa: {
          version = "0.2.2";
          sha256 = "1mbcrq89jz0dcibw66w0jdy4f4bfpx4zwjfs98rm3jjgdikwdzb4";
        });
      };
    };
  };

The above went in my configuration.nix

0

For others looking, you can use override on the haskellPackages and provide an overlay in the overrides attribute, this will create your own version of the package set containing the overridden packages.

Example, removing version constraints on beam-core package and disabling tests on beam-postgres package.

myHaskellPackages = nixpkgs.haskellPackages.override {
    overrides = hself: hsuper: {
      # Can add/override packages here
      beam-core = nixpkgs.haskell.lib.doJailbreak hsuper.beam-core;
      beam-postgres = nixpkgs.haskell.lib.dontCheck hsuper.beam-postgres;
    };
  };

Then you use that modified package set to build your project:

myHaskellPackages.callCabal2nix "my-project" ./. { }

It's possible to build a derivation for a specific version of the package with nixpkgs.haskellPackages.callHackage as long as it exists on Hackage, or use callCabal2nix on a modified local repo, or fetchFromGitHub and alike to refer to a remote repo.

More details on fixing broken Haskell packages can be found here, and tips in general about Haskell development with Nix here, you'll find there an example on how to override dependencies of a dependency.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .