Skip to content

Commit 2fe1447

Browse files
committed
Simplify by optimizing for Nix cache reuse
1 parent b7aa138 commit 2fe1447

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

shell.nix

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,65 @@
11
# This shell.nix file is designed for use with cabal build
22
# It aims to leverage the nix cache in as much as possible
3-
# It does not aim to replace Cabal/Stack with Nix
3+
# while reducing Nix maintenance costs.
4+
# It does **not** aim to replace Cabal/Stack with Nix
45

5-
# Before making changes, ensure that the Nix expression works
6-
# for all the GHC versions supported by the project (8.6.x - 8.10.x)
76

87
{ sources ? import nix/sources.nix,
98
nixpkgs ? import sources.nixpkgs {},
109
compiler ? "default"
1110
}:
1211
with nixpkgs;
1312

14-
let haskellPackagesForProject = if compiler == "default"
15-
then haskellPackages.ghcWithPackages
16-
else haskell.packages.${compiler}.ghcWithPackages;
17-
18-
extraPackages = p: with p;
19-
if compiler == "ghc8101" then
20-
[conduit-extra
21-
conduit-parse
22-
hie-bios
23-
yaml
24-
]
25-
else if compiler == "ghc865" then [] else
26-
# compiler = ghc88
27-
[ haskell-lsp
28-
lsp-test
29-
brittany
30-
ormolu
31-
stylish-haskell
32-
];
13+
let haskellPackagesForProject = p:
14+
if compiler == "default" || compiler == "ghc883"
15+
then haskellPackages.ghcWithPackages p
16+
# for all other compilers there is no Nix cache so dont bother building deps with NIx
17+
else haskell.packages.${compiler}.ghcWithPackages [];
3318

3419
compilerWithPackages = haskellPackagesForProject(p:
3520
with p;
36-
[ aeson
21+
[
22+
Diff
23+
Glob
24+
HsYAML-aeson
25+
QuickCheck
26+
aeson
3727
alex
3828
async
3929
base16-bytestring
4030
blaze-builder
4131
blaze-markup
32+
brittany
33+
conduit-extra
34+
conduit-parse
4235
cryptohash-sha1
4336
data-default
4437
data-default-class
4538
data-default-instances-containers
4639
data-default-instances-dlist
4740
data-default-instances-old-locale
48-
Diff
4941
extra
5042
floskell
5143
fuzzy
5244
generic-deriving
5345
ghc-check
5446
gitrev
55-
Glob
5647
haddock-library
5748
happy
49+
haskell-lsp
5850
haskell-src-exts
51+
hie-bios
5952
hslogger
6053
hspec
61-
HsYAML-aeson
6254
lens
55+
lsp-test
6356
megaparsec
6457
network
6558
opentelemetry
6659
optparse-simple
67-
QuickCheck
68-
parsers
60+
ormolu
6961
parser-combinators
62+
parsers
7063
prettyprinter
7164
prettyprinter-ansi-terminal
7265
primes
@@ -77,6 +70,7 @@ let haskellPackagesForProject = if compiler == "default"
7770
shake
7871
sorted-list
7972
strict
73+
stylish-haskell
8074
tasty
8175
tasty-ant-xml
8276
tasty-expected-failure
@@ -89,8 +83,9 @@ let haskellPackagesForProject = if compiler == "default"
8983
unix-compat
9084
unordered-containers
9185
xml
86+
yaml
9287
zlib
93-
] ++ extraPackages p);
88+
]);
9489
in
9590
stdenv.mkDerivation {
9691
name = "haskell-language-server";

0 commit comments

Comments
 (0)