From 93844f99b35c6befe5077cceedd5cd90c63718bb Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 26 Jul 2020 11:25:44 +0100 Subject: [PATCH 1/4] Fix compat. with ghc8101 and add more packages - Removing packages that fail to build with ghc8101 (haskell-lsp due to statistics) - Adding more prebuilt packages to further leverage the Nix cache --- shell.nix | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/shell.nix b/shell.nix index 510a4df83c..1c434e72ab 100644 --- a/shell.nix +++ b/shell.nix @@ -8,30 +8,65 @@ let haskellPackagesForProject = if compiler == "default" then haskellPackages.ghcWithPackages else haskell.packages.${compiler}.ghcWithPackages; + # these packages fail to build with ghc8101 + extraPackages = p: if compiler == "ghc8101" + then [] + else [p.haskell-lsp p.lsp-test]; + compilerWithPackages = haskellPackagesForProject(p: with p; [ aeson + alex async + base16-bytestring + blaze-builder + blaze-markup + conduit-extra + conduit-parse + cryptohash-sha1 + data-default + data-default-class + data-default-instances-containers + data-default-instances-dlist + data-default-instances-old-locale + Diff extra + floskell + fuzzy + generic-deriving gitrev - haskell-lsp + Glob + happy + haskell-src-exts + hslogger + hspec lens network optparse-simple - prettyprinter QuickCheck + parsers + parser-combinators + prettyprinter + prettyprinter-ansi-terminal + primes + psqueues regex-tdfa rope-utf16-splay safe-exceptions shake + sorted-list tasty tasty-golden tasty-hunit tasty-rerun temporary text + typed-process unordered-containers - ]); + xml + yaml + zlib + ] ++ extraPackages p); in stdenv.mkDerivation { name = "haskell-language-server"; From b7aa138f15f6b58b9db014d670d7bd73a1c8d473 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 26 Jul 2020 15:14:40 +0100 Subject: [PATCH 2/4] Fix compat. with ghc865, add more packages and rationale --- shell.nix | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/shell.nix b/shell.nix index 1c434e72ab..417a714b87 100644 --- a/shell.nix +++ b/shell.nix @@ -1,3 +1,10 @@ +# This shell.nix file is designed for use with cabal build +# It aims to leverage the nix cache in as much as possible +# It does not aim to replace Cabal/Stack with Nix + +# Before making changes, ensure that the Nix expression works +# for all the GHC versions supported by the project (8.6.x - 8.10.x) + { sources ? import nix/sources.nix, nixpkgs ? import sources.nixpkgs {}, compiler ? "default" @@ -8,10 +15,21 @@ let haskellPackagesForProject = if compiler == "default" then haskellPackages.ghcWithPackages else haskell.packages.${compiler}.ghcWithPackages; - # these packages fail to build with ghc8101 - extraPackages = p: if compiler == "ghc8101" - then [] - else [p.haskell-lsp p.lsp-test]; + extraPackages = p: with p; + if compiler == "ghc8101" then + [conduit-extra + conduit-parse + hie-bios + yaml + ] + else if compiler == "ghc865" then [] else + # compiler = ghc88 + [ haskell-lsp + lsp-test + brittany + ormolu + stylish-haskell + ]; compilerWithPackages = haskellPackagesForProject(p: with p; @@ -21,8 +39,6 @@ let haskellPackagesForProject = if compiler == "default" base16-bytestring blaze-builder blaze-markup - conduit-extra - conduit-parse cryptohash-sha1 data-default data-default-class @@ -34,14 +50,19 @@ let haskellPackagesForProject = if compiler == "default" floskell fuzzy generic-deriving + ghc-check gitrev Glob + haddock-library happy haskell-src-exts hslogger hspec + HsYAML-aeson lens + megaparsec network + opentelemetry optparse-simple QuickCheck parsers @@ -55,16 +76,19 @@ let haskellPackagesForProject = if compiler == "default" safe-exceptions shake sorted-list + strict tasty + tasty-ant-xml + tasty-expected-failure tasty-golden tasty-hunit tasty-rerun temporary text typed-process + unix-compat unordered-containers xml - yaml zlib ] ++ extraPackages p); in From 2fe144771052e60f6945039f411075c84a2d9d34 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 26 Jul 2020 15:27:19 +0100 Subject: [PATCH 3/4] Simplify by optimizing for Nix cache reuse --- shell.nix | 53 ++++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/shell.nix b/shell.nix index 417a714b87..1888767ea2 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,8 @@ # This shell.nix file is designed for use with cabal build # It aims to leverage the nix cache in as much as possible -# It does not aim to replace Cabal/Stack with Nix +# while reducing Nix maintenance costs. +# It does **not** aim to replace Cabal/Stack with Nix -# Before making changes, ensure that the Nix expression works -# for all the GHC versions supported by the project (8.6.x - 8.10.x) { sources ? import nix/sources.nix, nixpkgs ? import sources.nixpkgs {}, @@ -11,62 +10,56 @@ }: with nixpkgs; -let haskellPackagesForProject = if compiler == "default" - then haskellPackages.ghcWithPackages - else haskell.packages.${compiler}.ghcWithPackages; - - extraPackages = p: with p; - if compiler == "ghc8101" then - [conduit-extra - conduit-parse - hie-bios - yaml - ] - else if compiler == "ghc865" then [] else - # compiler = ghc88 - [ haskell-lsp - lsp-test - brittany - ormolu - stylish-haskell - ]; +let haskellPackagesForProject = p: + if compiler == "default" || compiler == "ghc883" + then haskellPackages.ghcWithPackages p + # for all other compilers there is no Nix cache so dont bother building deps with NIx + else haskell.packages.${compiler}.ghcWithPackages []; compilerWithPackages = haskellPackagesForProject(p: with p; - [ aeson + [ + Diff + Glob + HsYAML-aeson + QuickCheck + aeson alex async base16-bytestring blaze-builder blaze-markup + brittany + conduit-extra + conduit-parse cryptohash-sha1 data-default data-default-class data-default-instances-containers data-default-instances-dlist data-default-instances-old-locale - Diff extra floskell fuzzy generic-deriving ghc-check gitrev - Glob haddock-library happy + haskell-lsp haskell-src-exts + hie-bios hslogger hspec - HsYAML-aeson lens + lsp-test megaparsec network opentelemetry optparse-simple - QuickCheck - parsers + ormolu parser-combinators + parsers prettyprinter prettyprinter-ansi-terminal primes @@ -77,6 +70,7 @@ let haskellPackagesForProject = if compiler == "default" shake sorted-list strict + stylish-haskell tasty tasty-ant-xml tasty-expected-failure @@ -89,8 +83,9 @@ let haskellPackagesForProject = if compiler == "default" unix-compat unordered-containers xml + yaml zlib - ] ++ extraPackages p); + ]); in stdenv.mkDerivation { name = "haskell-language-server"; From d286ae810d70518bd0ef914947f3a6d258b8eab3 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 26 Jul 2020 15:35:50 +0100 Subject: [PATCH 4/4] avoid hard-coding the default compiler --- shell.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index 1888767ea2..819e7ff9d8 100644 --- a/shell.nix +++ b/shell.nix @@ -10,8 +10,9 @@ }: with nixpkgs; -let haskellPackagesForProject = p: - if compiler == "default" || compiler == "ghc883" +let defaultCompiler = "ghc" + lib.replaceStrings ["."] [""] haskellPackages.ghc.version; + haskellPackagesForProject = p: + if compiler == "default" || compiler == defaultCompiler then haskellPackages.ghcWithPackages p # for all other compilers there is no Nix cache so dont bother building deps with NIx else haskell.packages.${compiler}.ghcWithPackages [];