Skip to content

Commit 52a5472

Browse files
authored
Backport flake.nix changes to 1.8 (#3060)
Cherry picked commits related to the Nix flake from master to create a more suitable environment for downstream projects and mergifybot to work on. It also updates the flake.lock for newer versions of GHC. This in turn required a patch for clash-cores, similar to the one in the clash-cores repository.
1 parent 1328c34 commit 52a5472

File tree

9 files changed

+186
-97
lines changed

9 files changed

+186
-97
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Or [use Nix](https://nixos.org/nix/download.html) to get a shell with the `clash
116116
nix develop .
117117

118118
# Start a dev shell with a specific GHC version
119-
nix develop .#ghc961
119+
nix develop .#ghc9101
120120
```
121121

122122
You will need a modern version of nix with support for the new-style `nix`

clash-cores/clash-cores.cabal

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ flag haddock
3636
default: False
3737
manual: True
3838

39-
flag nix
40-
description:
41-
Are we building this package from nix
42-
default: False
43-
manual: True
44-
4539
-- TODO: Remove this workaround. See:
4640
--
4741
-- https://github.com/clash-lang/clash-compiler/pull/2665#issuecomment-1939044550
@@ -83,22 +77,6 @@ common basic-config
8377
if flag(haddock)
8478
ghc-options:
8579
-fdefer-type-errors
86-
elif flag(nix)
87-
-- It's absolutely grimy, but if we don't specify the `-package` flags here
88-
-- then when nix eventually calls `./Setup register` on the package it will
89-
-- still pass the `-fplugin` options to GHC and fail to create the package
90-
-- registation file needed to finish the `installPhase`.
91-
--
92-
-- These flags are something we NEVER want to manually specify in a normal
93-
-- build, since correctly configuring this kind of thing should be solely
94-
-- left to cabal as a build tool.
95-
ghc-options:
96-
-package ghc-typelits-extra
97-
-fplugin GHC.TypeLits.Extra.Solver
98-
-package ghc-typelits-knownnat
99-
-fplugin GHC.TypeLits.Normalise
100-
-package ghc-typelits-natnormalise
101-
-fplugin GHC.TypeLits.KnownNat.Solver
10280
else
10381
ghc-options:
10482
-fplugin GHC.TypeLits.Extra.Solver

flake.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
# The versions of GHC that we want to be able to build / develop against
3737
# within the nix environment. Since nix is lazy, only derivations for
3838
# versions of GHC which are used are actually evaluated.
39-
ghcVersions = [ "ghc902" "ghc962" ];
39+
ghcVersions = [ "ghc964" "ghc982" "ghc9101" ];
4040

4141
# We pick a single version of GHC to use by default within nix. This is
4242
# probably cleaner than always having N copies of each package / app and
4343
# being forced to refer to them by their GHC version.
44-
defaultGhcVersion = "ghc962";
44+
defaultGhcVersion = "ghc9101";
4545

4646
# Overlays are not per-system, so let's only compute them once.
4747
# For each version of GHC we produce a `pkgs.clashPackages-ghcVER`, e.g.

nix/overlay-ghc902.nix

Lines changed: 0 additions & 33 deletions
This file was deleted.

nix/overlay-ghc910.nix

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{ pkgs }:
2+
final: prev:
3+
let
4+
inherit (pkgs.haskell.lib) dontCheck doJailbreak markUnbroken;
5+
in
6+
{
7+
# Use an older version than the default in nixpkgs. Since rewrite-inspector
8+
# is basically abandonware it catches fire with brick 1.0+.
9+
brick = doJailbreak prev.brick_0_70_1;
10+
11+
# brick 0.70.1 requires vty < 6.0.
12+
vty = doJailbreak (prev.callHackage "vty" "5.39" { });
13+
14+
# Relies on older versions of some libraries.
15+
hint = doJailbreak prev.hint;
16+
17+
# Marked as broken in nixpkgs, since it specifies much older dependencies
18+
# than the defaults in nixpkgs.
19+
rewrite-inspector = doJailbreak (markUnbroken prev.rewrite-inspector);
20+
21+
# Requires some old versions of libraries, but still works.
22+
derive-storable-plugin = doJailbreak prev.derive-storable-plugin;
23+
24+
# Marken as broken, but compiles anyway.
25+
hedgehog-fakedata = doJailbreak (markUnbroken prev.hedgehog-fakedata);
26+
27+
# Fails on GHC 9.10 with:
28+
# library/Text/Regex/PCRE/Heavy.hs:123: failure in expression `head $ scan [re|\s*entry (\d+) (\w+)\s*&?|] (" entry 1 hello &entry 2 hi" :: String)'
29+
# expected: (" entry 1 hello &",["1","hello"])
30+
# but got: <interactive>:55:1: warning: [GHC-63394] [-Wx-partial]
31+
# ^
32+
# In the use of ‘head’
33+
# (imported from Prelude.Compat, but defined in GHC.Internal.List):
34+
# "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
35+
# (" entry 1 hello &",["1","hello"])
36+
37+
pcre-heavy = dontCheck prev.pcre-heavy;
38+
39+
# Relies on older versions of text.
40+
string-random = doJailbreak prev.string-random;
41+
42+
# We need the newest version from nixpkgs for these packages.
43+
singletons-base = prev.singletons-base_3_4;
44+
45+
microstache = prev.microstache_1_0_3;
46+
47+
th-desugar = prev.th-desugar_1_17;
48+
49+
# We need a new tasty-flaky. The one from Hackage doesn't build for some weird
50+
# reason..
51+
tasty-flaky = prev.callCabal2nix "tasty-flaky" (pkgs.fetchFromGitHub {
52+
owner = "LaurentRDC";
53+
repo = "tasty-flaky";
54+
rev = "fc31a9d622c1eb60030a50152258a9bef785e365";
55+
sha256 = "sha256-irLM3aVMxpBgsM72ArulMXcoLY2glalVkG//Lrj2JBI=";
56+
}) {};
57+
58+
tasty = prev.tasty_1_5;
59+
60+
singletons-th = prev.singletons-th_3_4;
61+
62+
# nixpkgs doesn't include revision 1, changing dependency on template-haskell.
63+
string-interpolate = pkgs.haskell.lib.compose.overrideCabal (drv: {
64+
revision = "1";
65+
editedCabalFile = "sha256-oh0tR+LDFcVzQnm4kSrmhAU+P7wdai536d72Cvhzipg=";
66+
}) (prev.callHackageDirect {
67+
pkg = "string-interpolate";
68+
ver = "0.3.4.0";
69+
sha256 = "sha256-KA8P6cc6N7pZ9/ay3edcEGx4vpKtp+EY7tn8U1NrbG8=";
70+
} { });
71+
}
Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{ pkgs }:
22
final: prev:
33
let
4-
inherit (pkgs.haskell.lib) doJailbreak dontCheck markUnbroken;
4+
inherit (pkgs.haskell.lib) doJailbreak markUnbroken dontCheck;
55
in
66
{
77
# Use an older version than the default in nixpkgs. Since rewrite-inspector
88
# is basically abandonware it catches fire with brick 1.0+.
99
brick = doJailbreak prev.brick_0_70_1;
1010

11+
# brick 0.70.1 requires vty < 6.0.
12+
vty = prev.callHackage "vty" "5.39" { };
13+
14+
# Marked as broken in nixpkgs, since it needs a newer hashable than the
15+
# .cabal file currently uploaded to hackage.
16+
concurrent-supply = doJailbreak (markUnbroken prev.concurrent-supply);
1117

1218
# Use a branch with changes to support GHC 9.6.1.
1319
hint =
@@ -25,28 +31,18 @@ in
2531
# than the defaults in nixpkgs.
2632
rewrite-inspector = doJailbreak (markUnbroken prev.rewrite-inspector);
2733

28-
# We want a version that matches with singletons-th, but the tests in here
29-
# are also a bit flaky since GHC 9.6 isn't officially supported.
30-
singletons-base = dontCheck prev.singletons-base_3_2;
31-
32-
# Use a newer version than the default in nixpkgs.
33-
singletons-th = prev.singletons-th_3_2;
34-
3534
# Needs a newer text than the .cabal file currently uploaded to hackage.
3635
string-qq = doJailbreak prev.string-qq;
3736

38-
# Needs a newer version than the default in nixpkgs.
39-
th-desugar = prev.th-desugar_1_15;
40-
4137
# Needs a newer base than the .cabal file currently uploaded to hackage.
4238
vector-binary-instances = doJailbreak prev.vector-binary-instances;
4339

44-
# Use an older version than the default in nixpkgs.
45-
th-abstraction = prev.th-abstraction_0_5_0_0;
46-
4740
# type-errors 0.2.0.2 is bounded on doctest >=0.16.0.1 && <0.22
4841
doctest = prev.callHackage "doctest" "0.21.1" { };
4942

43+
# Marken as broken, but compiles anyway.
44+
hedgehog-fakedata = doJailbreak (markUnbroken prev.hedgehog-fakedata);
45+
5046
# We need a new tasty-flaky. The one from Hackage doesn't build for some weird
5147
# reason..
5248
tasty-flaky = prev.callCabal2nix "tasty-flaky" (pkgs.fetchFromGitHub {
@@ -55,4 +51,15 @@ in
5551
rev = "fc31a9d622c1eb60030a50152258a9bef785e365";
5652
sha256 = "sha256-irLM3aVMxpBgsM72ArulMXcoLY2glalVkG//Lrj2JBI=";
5753
}) {};
54+
55+
# This version of tasty isn't available in the nix ghc96 package set
56+
tasty = prev.callHackageDirect {
57+
pkg = "tasty";
58+
ver = "1.5.3";
59+
sha256 = "sha256-Ogd8J4aHNeL+xmcRWuJeGBNaePyLs5yo1IoMzvWrVPY=";
60+
} {};
61+
62+
# The tests (not the package itself!) require a tasty <1.5, which won't work as we pull in
63+
# tasty 1.5.3. Solution: don't test!
64+
time-compat = dontCheck prev.time-compat;
5865
}

nix/overlay-ghc98.nix

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{ pkgs }:
2+
final: prev:
3+
let
4+
inherit (pkgs.haskell.lib) doJailbreak markUnbroken dontCheck;
5+
in
6+
{
7+
# Use an older version than the default in nixpkgs. Since rewrite-inspector
8+
# is basically abandonware it catches fire with brick 1.0+.
9+
brick = doJailbreak prev.brick_0_70_1;
10+
11+
# brick 0.70.1 requires vty < 6.0.
12+
vty = doJailbreak (prev.callHackage "vty" "5.39" { });
13+
14+
# Marked as broken in nixpkgs, since it specifies much older dependencies
15+
# than the defaults in nixpkgs.
16+
rewrite-inspector = doJailbreak (markUnbroken prev.rewrite-inspector);
17+
18+
# Requires some old versions of libraries, but still works.
19+
derive-storable-plugin = doJailbreak prev.derive-storable-plugin;
20+
21+
# Marken as broken, but compiles anyway.
22+
hedgehog-fakedata = doJailbreak (markUnbroken prev.hedgehog-fakedata);
23+
24+
# We need a new tasty-flaky. The one from Hackage doesn't build for some weird
25+
# reason..
26+
tasty-flaky = prev.callCabal2nix "tasty-flaky" (pkgs.fetchFromGitHub {
27+
owner = "LaurentRDC";
28+
repo = "tasty-flaky";
29+
rev = "fc31a9d622c1eb60030a50152258a9bef785e365";
30+
sha256 = "sha256-irLM3aVMxpBgsM72ArulMXcoLY2glalVkG//Lrj2JBI=";
31+
}) {};
32+
33+
# This version of tasty isn't available in the nix ghc98 package set
34+
tasty = prev.callHackageDirect {
35+
pkg = "tasty";
36+
ver = "1.5.3";
37+
sha256 = "sha256-Ogd8J4aHNeL+xmcRWuJeGBNaePyLs5yo1IoMzvWrVPY=";
38+
} {};
39+
40+
# The tests (not the package itself!) require a tasty <1.5, which won't work as we pull in
41+
# tasty 1.5.3. Solution: don't test!
42+
time-compat = dontCheck prev.time-compat;
43+
}

0 commit comments

Comments
 (0)