I’ve been struggling a bit trying to convert my working nix-shell
config for a simple haskell project into a nix develop
shell with flakes. For some reason, the flake shell with haskell-flake uses different package versions from haskell.developPackage
and the cabal install
fails to find matching versions. Could someone please point me where the issue could be?
What package versions does haskell-flake use? Is there a way to control it?
Working default.nix
The following default.nix
works with nix-shell
. I.e. I enter the shell and cabal build
compiles the package.
{ pkgs ? import <nixpkgs> { } }:
let
haskell = pkgs.haskell.packages.ghc96;
in
haskell.developPackage { root = ./.; }
I have 24.11 in my nixpkgs (using home manager on Archlinux):
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixos-24.11
unstable https://nixos.org/channels/nixos-unstable
Failing flake.nix
The following flake.nix
that I is based on the README of haskell-flake.
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake = {
url = "github:srid/haskell-flake";
};
nixpkgs = {
url = "nixpkgs/nixos-24.11";
};
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
];
imports = [
inputs.haskell-flake.flakeModule
];
perSystem = { self', system, lib, config, pkgs, ... }: {
haskellProjects.default = {
basePackages = pkgs.haskell.packages.ghc96;
# Packages to add on top of `basePackages`, e.g. from Hackage
packages = {
# wreq.source = "0.5.4.3"; # Hackage version
};
# my-haskell-package development shell configuration
devShell = {
hlsCheck.enable = true;
tools = hp: with hp; {
inherit
cabal-install
ghcid
# haskell-language-server
;
};
};
# What should haskell-flake add to flake outputs?
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
devShells.default = pkgs.mkShell {
name = "dev";
inputsFrom = [
# ...
config.haskellProjects.default.outputs.devShell
];
nativeBuildInputs = with pkgs; [
# other development tools.
];
};
};
};
}
When I enter nix develop
and run cabal build
, it fails to find an appropriate version of wreq (kalina is the name of my package):
$ cabal build Warning: The package list for 'hackage.haskell.org' is 803 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: kalina-0.1.0.0 (user goal)
[__1] trying: wreq-0.5.3.3 (dependency of kalina)
[__2] trying: unordered-containers-0.2.19.1 (dependency of wreq)
[__3] next goal: template-haskell (dependency of wreq)
[__3] rejecting: template-haskell-2.20.0.0/installed-2.20.0.0 (conflict: unordered-containers => template-haskell<2.20)
[__3] rejecting: template-haskell; 2.19.0.0, 2.18.0.0, 2.17.0.0, 2.16.0.0, 2.15.0.0, 2.14.0.0, 2.13.0.0, 2.12.0.0, 2.11.1.0, 2.11.0.0, 2.10.0.0, 2.9.0.0, 2.8.0.0, 2.7.0.0, 2.6.0.0, 2.5.0.0, 2.4.0.1, 2.4.0.0, 2.3.0.1, 2.3.0.0, 2.2.0.0 (constraint from non-reinstallable package requires installed instance)
[__3] fail (backjumping, conflict set: template-haskell, unordered-containers, wreq)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: base, hashable, scientific, attoparsec, wreq, aeson, unordered-containers, case-insensitive, template-haskell, lens-aeson, http-types, psqueues, kalina
Try running with --minimize-conflict-set to improve the error message.
Setting packages.wreq.source
has no effect
When I uncomment the following line in my flake.nix
above, the error does not change. I.e. it complains that wreq-0.5.3.3 is not right.
packages = {
wreq.source = "0.5.4.3"; # Hackage version
};