I should add a way to fix up these types of problems locally, in case you don’t care about nixpkgs and just want to get some project working locally:
I tried to create a nix file for getting the current version of stm-hamt
compiling. I came up with the following:
let
nixpkgsSrc = builtins.fetchTarball {
# The haskell-updates branch of nixpkgs as of 2020-01-10.
url = "https://github.com/NixOS/nixpkgs/archive/3741b43294b4d807fc982fa671d3c52065d1ef02.tar.gz";
sha256 = "sha256:04zg129pb1iis521f8pr5n6y9pmiv48xlzfflwm1smb65hg4wacd";
};
# This is a nixpkgs overlay.
haskellOverlay = nixpkgsSelf: nixpkgsSuper: {
haskellPackages = nixpkgsSuper.haskellPackages.override {
overrides = self: super: {
stm-hamt = nixpkgsSelf.haskell.lib.markUnbroken (super.stm-hamt.override {
primitive-extras = self.primitive-extras_0_8;
});
primitive = nixpkgsSelf.haskell.lib.dontCheck super.primitive_0_7_0_0;
primitive-unlifted = nixpkgsSelf.haskell.lib.markUnbroken super.primitive-unlifted;
};
};
};
nixpkgs = import nixpkgsSrc { overlays = [ haskellOverlay ]; };
in
nixpkgs.haskellPackages.stm-hamt
This works:
$ nix-build /path/to/above/file.nix
...
/nix/store/hvigqf64pgcf1badpzc2skjyjysfkzsm-stm-hamt-1.2.0.4
Although, in practice, it is normally just easier to use an older, known-working version of stm-hamt
:
let
nixpkgsSrc = builtins.fetchTarball {
# The haskell-updates branch of nixpkgs as of 2020-01-10.
url = "https://github.com/NixOS/nixpkgs/archive/3741b43294b4d807fc982fa671d3c52065d1ef02.tar.gz";
sha256 = "sha256:04zg129pb1iis521f8pr5n6y9pmiv48xlzfflwm1smb65hg4wacd";
};
# Normally you can get this derivation automatically. See below for details.
stm-hamt-pkg =
{ mkDerivation, async, base, criterion, deferred-folds, focus, free
, hashable, list-t, mwc-random, mwc-random-monad, primitive
, primitive-extras, QuickCheck, quickcheck-instances, rebase
, rerebase, stdenv, tasty, tasty-hunit, tasty-quickcheck
, transformers
}:
mkDerivation {
pname = "stm-hamt";
version = "1.2.0.3";
sha256 = "2389eae079a7c80013c1ac028ee4750cdfec1f192f521561f3078f80c4c4d72f";
libraryHaskellDepends = [
base deferred-folds focus hashable list-t primitive
primitive-extras transformers
];
testHaskellDepends = [
deferred-folds focus QuickCheck quickcheck-instances rerebase tasty
tasty-hunit tasty-quickcheck
];
benchmarkHaskellDepends = [
async criterion focus free list-t mwc-random mwc-random-monad
rebase
];
homepage = "https://github.com/nikita-volkov/stm-hamt";
description = "STM-specialised Hash Array Mapped Trie";
license = stdenv.lib.licenses.mit;
};
# This is a nixpkgs overlay.
haskellOverlay = nixpkgsSelf: nixpkgsSuper: {
haskellPackages = nixpkgsSuper.haskellPackages.override {
overrides = self: super: {
# This calls the stm-hamt-pkg we have defined above.
# I was able to generate this derivation with cabal2nix.
#
# $ nix-shell -p cabal2nix --run 'cabal2nix cabal://stm-hamt-1.2.0.3'
#
# However, normally you can do this automatically with the callHackage function:
#
# stm-hamt = self.callHackage "stm-hamt" "1.2.0.3" {};
#
# It appears that there is a small bug in the nixpkgs derivation for ghc-8.8
# causing this to currently not work. (If you instead used the
# `master` branch, or one of the nixpkg release branches, you shouldn't ever
# see a problem like this).
stm-hamt = self.callPackage stm-hamt-pkg {};
};
};
};
nixpkgs = import nixpkgsSrc { overlays = [ haskellOverlay ]; };
in
nixpkgs.haskellPackages.stm-hamt
This also works:
$ nix-build /path/to/above/file2.nix
...
/nix/store/pfka7xh1947bp3qzgvhxawvpp9cnwpq8-stm-hamt-1.2.0.3