haskellgitlab-cicabal

Adding dependency with cabal in gitlab-ci


I have a project I normally build with nix and cabal, however I also want to publish my documentation onto gitlab pages. It's impractical to run my nix on the gitlab CI, so I've just been using cabal. Here was my .gitlab-ci.yaml:

default:
  image: haskell:9

stages:
  - pages

pages:
  stage: pages
  artifacts:
    paths:
      - public
  script:
    - cabal v2-haddock --builddir=out
    - mv ./out/build/*/ghc-*/*-*/doc/html/*/ ./public

And here's my package.yaml:

name:                lib
version:             0.1.1.0
license:             AGPL
author:              Me
copyright:           2024 Me
extra-source-files:
  - README.md

dependencies:
  - base >= 4.14 && < 5
  - containers >= 0.6.5 && < 0.7

library:
  source-dirs:
    src

This worked until I needed to use text-icu. I added text-icu to my nix and package.yaml:

 dependencies:
   - base >= 4.14 && < 5
   - containers >= 0.6.5 && < 0.7
+  - text
+  - text-icu >= 0.7 && < 0.9

And this works on my local machine just fine. But I can't use my nix on gitlab CI and gitlab's docker image doesn't have text-icu. So I get an error:

Error: cabal: Could not resolve dependencies:
[__0] trying: lib-0.1.1.0 (user goal)
[__1] unknown package: text-icu (dependency of lib)
[__1] fail (backjumping, conflict set: lib, text-icu)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: lib, text-icu

I'm really used to using nix, so I'm not sure how to fix this. I tried a couple of random things in hope they would solve the issue by chance, but they didn't and I don't have any informed ideas. How can I supply this dependency to the gitlab-ci so that cabal can access it?


Solution

  • If cabal doesn't find text-icu, it's probably because the local package index is empty. You can update it with cabal update.

    script:
    - cabal update
    - cabal haddock ...