Skip to content

Commit 43fbd58

Browse files
Merge pull request #656 from NixOS/ghc-9.12
cabal2nix/test: support Cabal >= 3.14
2 parents 58a48b5 + 12004c4 commit 43fbd58

File tree

9 files changed

+59
-11
lines changed

9 files changed

+59
-11
lines changed

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ if type -p lorri; then
33
eval "$(lorri direnv)"
44
else
55
echo "direnv: using direnv nix support" 1>&2
6-
use nix;
6+
use nix --arg minimal true --arg withHls true;
77
fi

.github/workflows/haskell-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
strategy:
3333
matrix:
3434
include:
35+
- compiler: ghc-9.12.2
36+
compilerKind: ghc
37+
compilerVersion: 9.12.2
38+
setup-method: ghcup
39+
allow-failure: false
3540
- compiler: ghc-9.10.1
3641
compilerKind: ghc
3742
compilerVersion: 9.10.1

cabal2nix/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision History for cabal2nix
22

3+
## Unreleased
4+
5+
- Add support for Cabal `== 3.14.*` in the test suite.
6+
37
## 2.20.0
48

59
* `cabal2nix` now [prints the commands it runs when fetching sources](https://github.com/nixOS/cabal2nix/commit/5327953d299eba0b6de4e88bacf4bba9022bb5e2).

cabal2nix/cabal2nix.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ author: Peter Simons <[email protected]>
1212
-- list all contributors: git log --pretty='%an' | sort | uniq
1313
maintainer: sternenseemann <[email protected]>
1414
stability: stable
15-
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1
15+
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1 || == 9.12.2
1616
category: Distribution, Nix
1717
homepage: https://github.com/nixos/cabal2nix#readme
1818
bug-reports: https://github.com/nixos/cabal2nix/issues

cabal2nix/test/Main.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import Distribution.PackageDescription
2222
import Distribution.PackageDescription.Parsec
2323
#endif
2424
import Distribution.System
25+
#if MIN_VERSION_Cabal(3,14,0)
26+
import Distribution.Utils.Path (makeSymbolicPath)
27+
#endif
2528
import Distribution.Verbosity
2629
import Distribution.Version
2730
import Language.Nix
@@ -38,6 +41,7 @@ main = do
3841
-- depend on the system environment: https://github.com/NixOS/cabal2nix/issues/333.
3942
--
4043
-- TODO: Run this test without $HOME defined to ensure that we don't need that variable.
44+
-- TODO: make test suite independent of working directory somehow
4145
cabal2nix <- findExecutable "cabal2nix" >>= \case
4246
Nothing -> fail "cannot find 'cabal2nix' in $PATH"
4347
Just exe -> pure exe
@@ -74,7 +78,12 @@ testLibrary cabalFile = do
7478
(\ref new -> ["diff", "-u", ref, new])
7579
goldenFile
7680
nixFile
77-
(readGenericPackageDescription silent cabalFile >>= writeFileLn nixFile . prettyShow . cabal2nix)
81+
#if MIN_VERSION_Cabal(3,14,0)
82+
(readGenericPackageDescription silent Nothing (makeSymbolicPath cabalFile)
83+
#else
84+
(readGenericPackageDescription silent cabalFile
85+
#endif
86+
>>= writeFileLn nixFile . prettyShow . cabal2nix)
7887

7988
-- | TODO:
8089
--

distribution-nixpkgs/distribution-nixpkgs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license: BSD3
66
license-file: LICENSE
77
author: Peter Simons <[email protected]>
88
maintainer: sternenseemann <[email protected]>
9-
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1
9+
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1 || == 9.12.2
1010
category: Distribution, Nix
1111
homepage: https://github.com/NixOS/cabal2nix/tree/master/distribution-nixpkgs#readme
1212
bug-reports: https://github.com/NixOS/cabal2nix/issues

hackage-db/hackage-db.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license: BSD3
99
license-file: LICENSE
1010
author: Peter Simons, Alexander Altman, Ben James, Kevin Quick
1111
maintainer: sternenseemann <[email protected]>
12-
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1
12+
tested-with: GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.1 || == 9.12.2
1313
category: Distribution
1414
homepage: https://github.com/NixOS/cabal2nix/tree/master/hackage-db#readme
1515
bug-reports: https://github.com/NixOS/cabal2nix/issues

language-nix/language-nix.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license: BSD3
77
license-file: LICENSE
88
author: Peter Simons
99
maintainer: [email protected]
10-
tested-with: GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.7 || == 9.8.4 || == 9.10.1
10+
tested-with: GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.7 || == 9.8.4 || == 9.10.1 || == 9.12.2
1111
category: Distribution, Language, Nix
1212
homepage: https://github.com/NixOS/cabal2nix/tree/master/language-nix#readme
1313
bug-reports: https://github.com/NixOS/cabal2nix/issues

shell.nix

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
1-
{ pkgs ? import <nixpkgs> { }
1+
{ pkgs ?
2+
import (builtins.fetchTarball {
3+
# nixos-unstable 2025-04-23
4+
url = "https://github.com/nixos/nixpkgs/archive/96d30055a2215e5c5a545872376137a5d063e804.tar.gz";
5+
sha256 = "0xvzkpgc8qy4q252c3x399c8ikrks970c877s4i7vppnhxp08p8n";
6+
}) { }
27
, ghcVersion ? pkgs.haskellPackages.ghc.version
3-
, withHls ? true
8+
# Pass --arg minimal true to disable tools that are not strictly necessary
9+
# and may break when using non default GHC versions / other Nixpkgs revisions.
10+
, minimal ? false
11+
, withHls ? !minimal
412
}:
513

614
let
715
haskellPackages = pkgs.haskell.packages."ghc${
816
builtins.replaceStrings [ "." ] [ "" ] ghcVersion
917
}";
18+
inherit (pkgs) lib;
19+
haskellLib = pkgs.haskell.lib.compose;
20+
21+
haskell-ci-pinned = lib.pipe
22+
pkgs.haskell.packages.ghc9101.haskell-ci # compatible Cabal version by default
23+
[
24+
(haskellLib.overrideSrc {
25+
version = "0-unstable-2025-03-30";
26+
src = pkgs.fetchFromGitHub rec {
27+
name = "haskell-ci-source-${lib.substring 0 7 rev}";
28+
owner = "haskell-CI";
29+
repo = "haskell-ci";
30+
rev = "f0fd898ab14070fa46e9fd542a2b487a8146d88e";
31+
sha256 = "1pzrnpwsamy8ld6gb7vf9acr873z5q35pixbkwxvji5y9si0x352";
32+
};
33+
})
34+
# Make the build a bit less expensive
35+
haskellLib.dontCheck
36+
haskellLib.disableLibraryProfiling
37+
];
38+
1039
ghc = haskellPackages.ghcWithHoogle (hps: [
1140
hps.ansi-wl-pprint
1241
hps.hopenssl
@@ -30,12 +59,13 @@ in pkgs.mkShell {
3059
packages = [
3160
ghc
3261
pkgs.cabal-install
33-
pkgs.haskell-ci
34-
(pkgs.lib.getLib pkgs.openssl)
62+
(lib.getLib pkgs.openssl)
3563
# Needed to run `cabal2nix`:
3664
pkgs.nix-prefetch-scripts
37-
] ++ pkgs.lib.optionals withHls [
65+
] ++ lib.optionals withHls [
3866
haskellPackages.haskell-language-server
67+
] ++ lib.optionals (!minimal) [
68+
haskell-ci-pinned
3969
];
4070

4171
# Make Paths_ module of distribution-nixpkgs find its data files in the shell.

0 commit comments

Comments
 (0)