Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update boot packages with haskell.nix that can be updated fine with stack #2234

Open
tysonzero opened this issue Jul 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@tysonzero
Copy link

tysonzero commented Jul 22, 2024

As far as I'm aware certain boot packages like base are generally not possible to upgrade separately from the compiler, however other boot packages like time seem to be upgradable like any other package, at least they are with stackage.

However when I start with a working haskell.nix project and replace time >=1.12.2 with time >=1.14 I start getting weird inplace errors:

Configure flags:
--prefix=/nix/store/z8an8whzbxq7d2xa6a5n2wmr1mn8ba36-cabal-doctest-lib-cabal-doctest-1.0.9 lib:cabal-doctest --package-db=clear --package-db=/private/tmp/nix-build-cabal-doctest-lib-cabal-doctest-1.0.9.drv-0/tmp.xUtoDYSd8T/lib/ghc-9.8.2/lib/package.conf.d --exact-configuration --dependency=directory=directory-1.3.8.5-J0DB57KusDG5cPVj1hBFv --dependency=time=time-1.14-HD32l0bNh9V6LYIWszYw21 --dependency=unix=unix-2.8.5.1-4n9mxMGyMDWBXfPLb4FNJ1 --dependency=Cabal=Cabal-3.10.2.0-inplace --dependency=Cabal-syntax=Cabal-syntax-3.10.2.0-inplace --dependency=array=array-0.5.6.0-inplace --dependency=base=base-4.19.1.0-inplace --dependency=binary=binary-0.8.9.1-inplace --dependency=bytestring=bytestring-0.12.1.0-inplace --dependency=containers=containers-0.6.8-inplace --dependency=deepseq=deepseq-1.5.0.0-inplace --dependency=exceptions=exceptions-0.10.7-inplace --dependency=filepath=filepath-1.4.200.1-inplace --dependency=ghc-bignum=ghc-bignum-1.3-inplace --dependency=ghc-boot-th=ghc-boot-th-9.8.2-inplace --dependency=ghc-prim=ghc-prim-0.11.0-inplace --dependency=integer-gmp=integer-gmp-1.1-inplace --dependency=mtl=mtl-2.3.1-inplace --dependency=parsec=parsec-3.1.17.0-inplace --dependency=pretty=pretty-1.1.3.6-inplace --dependency=rts=rts-1.0.2 --dependency=stm=stm-2.5.2.1-inplace --dependency=system-cxx-std-lib=system-cxx-std-lib-1.0 --dependency=template-haskell=template-haskell-2.21.0.0-inplace --dependency=text=text-2.1.1-inplace --dependency=transformers=transformers-0.6.1.0-inplace --with-ghc=ghc --with-ghc-pkg=ghc-pkg --with-hsc2hs=hsc2hs --with-gcc=cc --with-ar=ar --with-strip=strip --with-ld=ld --disable-executable-stripping --disable-library-stripping --disable-library-profiling --disable-profiling --enable-static --enable-shared --disable-executable-dynamic --disable-coverage --enable-library-for-ghci --datadir=/nix/store/fwnfc702ls30y65rdcn2sg0ixy04kjnw-cabal-doctest-lib-cabal-doctest-1.0.9-data/share/ghc-9.8.2 
Configuring library for cabal-doctest-1.0.9..
Error:
    The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
installed package Cabal-3.10.2.0 is broken due to missing package directory-1.3.8.1-inplace, process-1.6.18.0-inplace, time-1.12.2-inplace, unix-2.8.4.0-inplace
installed package Cabal-syntax-3.10.2.0 is broken due to missing package directory-1.3.8.1-inplace, time-1.12.2-inplace, unix-2.8.4.0-inplace

I have tried a variety of default.nix tweaks including messing with overlays and setting reinstallableLibGhc = true, with my initial default.nix looking like this:

let
  rev = "6e9c388cb8353b7d773cd93b553fa939556401ce";
  haskellNix = import (
    builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/${rev}.tar.gz"
  ) {};
  pkgs = import
    haskellNix.sources.nixpkgs-2311
    haskellNix.nixpkgsArgs;
in pkgs.haskell-nix.project {
  src = pkgs.haskell-nix.haskellLib.cleanGit {
    name = "myproject";
    src = ./.;
  };
  compiler-nix-name = "ghc982";
  modules = [{
    packages.geos.components.library.libs = pkgs.lib.mkForce [pkgs.geos];
  }];
}

None of them get further than the inplace error, with some approaches failing earlier. However I am by no means a nix/nixpkgs/haskell.nix expert, so I could easily be making a mistake, in which case I'd love it if someone could tell me how to fix this, and perhaps add a section to the documentation on it, as I'm assuming many newer users would expect that a cabal file change like mine would not cause such an unforgiving error message.

Sadly I'm trying to work around a bug in the older time-1.12.2 library (haskell/time#260) so outside of forking/patching dependencies like opaleye that use the buggy functions, I am in somewhat of a rough place without being able to update a boot package, particularly since even the newest ghc versions do not seem to update their time dependency (https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history).

@hamishmack
Copy link
Collaborator

The problem seems to be that the cabal plan for building cabal-doctest has chosen to use the already inatalled Cabal and Cabal-syntax packages. This works fine for cabal where multiple versions of the package can live in the plan.json. cabal-doctest is a setup dependency and it should not matter if it uses an old time. Unfortunately haskell.nix still assumes there is only one version of each package in the plan (it picks the most recent version which is not great). Picking the new time leaves the inplace Cabal and Cabal-syntax packages broken.

The workaround for now might be to tell cabal not to choose the preinstalled packages. Try adding this to your cabal.project or to a cabalProjectLocal arg:

constraints: Cabal source, Cabal-syntax source

@tysonzero
Copy link
Author

Compared to the initial time >=1.12.2 and default.nix I gave above, what changes should I be including alongside the one you suggested?

I did time >=1.14, added the line you suggested to cabal.project, and also added allow-newer: time and I got the same error. I also tried overriding the Cabal/Cabal-syntax versions and adding reinstallableLibGhc = True, but that also made no difference to the error message.

@Ericson2314
Copy link

constraints: time source
allow-newer: time

was working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants