From b76ea56dd35254d53d4703d39a0b4e1cd89e55e1 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 14:51:17 +0100 Subject: [PATCH 01/17] nix: ghc92: ignore broken plugins --- configuration-ghc-921.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configuration-ghc-921.nix b/configuration-ghc-921.nix index 81a189ba70..3fc81a7c3a 100644 --- a/configuration-ghc-921.nix +++ b/configuration-ghc-921.nix @@ -5,6 +5,11 @@ let disabledPlugins = [ "hls-brittany-plugin" "hls-stylish-haskell-plugin" + "hls-hlint-plugin" + "hls-haddock-comments-plugin" + "hls-alternate-number-format-plugin" + "hls-eval-plugin" + "hls-tactics-plugin" ]; hpkgsOverride = hself: hsuper: @@ -22,11 +27,12 @@ let hself.callCabal2nixWithOptions "haskell-language-server" ./. (pkgs.lib.concatStringsSep " " [ "-f-brittany" - "-f-stylishhaskell" + "-f-stylishHaskell" "-f-hlint" "-f-haddockComments" "-f-alternateNumberFormat" "-f-eval" + "-f-tactics" ]) { }; # YOLO From 408bfc46ed223b6f45525dd2afa7ae5374637a72 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 15:07:26 +0100 Subject: [PATCH 02/17] nix: use current ghc for tools in the shell Theses tools are pulled in the shell, but we don't need them to match the GHC version used for development. Said otherwise, as long as we use a working `cabal-install` to build with GHC 9.2, we don't care if that cabal-install was built with GHC 8.10. This gives more chance for theses tools to work and be in the binary cache of nixpkgs. --- flake.nix | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 92a4324aa4..1191e681f0 100644 --- a/flake.nix +++ b/flake.nix @@ -251,22 +251,32 @@ removeAttrs hlsSources ghc921Config.disabledPlugins else hlsSources)); - buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs hpkgs) pythonWithPackages ] - ++ (with hpkgs; [ - cabal-install - hie-bios + # For theses tools packages, we use ghcDefault + # This removes a rebuild with a different GHC version + # Theses programs are tools, used as binary, independently of the + # version of GHC. + # The drawback of this approach is that our shell may pull two GHC + # version in scope (the `ghcDefault` one, and the one defined in + # `hpkgs`.) + # The advantage is that we won't have to rebuild theses tools (and + # dependencies) with a recent GHC which may not be supported by + # them. + buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs ghcDefault) pythonWithPackages ] + ++ [ + pkgs.cabal-install + ghcDefault.hie-bios hlint # ormolu # stylish-haskell - opentelemetry-extra - ]); + ghcDefault.opentelemetry-extra + ]; src = null; shellHook = '' export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib export PATH=$PATH:$HOME/.local/bin - ${if hpkgs.ghc.version != "9.0.1" then (pre-commit-check hpkgs).shellHook else ""} + ${(pre-commit-check ghcDefault).shellHook} ''; }; # Create a hls executable From 6cd5891d8a0dd50f11580421203462b5b91b1fc9 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 15:14:32 +0100 Subject: [PATCH 03/17] nix: disable shake-bench for ghc921 --- configuration-ghc-921.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configuration-ghc-921.nix b/configuration-ghc-921.nix index 3fc81a7c3a..36aab51066 100644 --- a/configuration-ghc-921.nix +++ b/configuration-ghc-921.nix @@ -10,6 +10,10 @@ let "hls-alternate-number-format-plugin" "hls-eval-plugin" "hls-tactics-plugin" + # That one is not technically a plugin, but by putting it in this list, we + # get it removed from the top level list of requirement and it is not pull + # in the nix shell. + "shake-bench" ]; hpkgsOverride = hself: hsuper: From 7fed1fd9a87df975e55dc170bb3fe817548f1cc6 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 15:24:58 +0100 Subject: [PATCH 04/17] nix: fix ghc 9.2 shell --- configuration-ghc-921.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configuration-ghc-921.nix b/configuration-ghc-921.nix index 36aab51066..db9f28a2c7 100644 --- a/configuration-ghc-921.nix +++ b/configuration-ghc-921.nix @@ -24,7 +24,10 @@ let ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint {}; constraints-extras = hself.callCabal2nix "constraints-extras" inputs.constraints-extras {}; retrie = hself.callCabal2nix "retrie" inputs.retrie {}; + + # Hlint is still broken hlint = doJailbreak (hself.callCabal2nix "hlint" inputs.hlint {}); + hiedb = hself.hiedb_0_4_1_0; # Re-generate HLS drv excluding some plugins haskell-language-server = From ac96112258e77ae35f263cb87f3cb0180449ea2a Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 15:44:57 +0100 Subject: [PATCH 05/17] nix: explicit cabal project in devShell Using alias, we get the "correct" behavior when typing `cabal build` in the nix-shell, it points to the current cabal-project file. --- flake.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 1191e681f0..8bdf84a644 100644 --- a/flake.nix +++ b/flake.nix @@ -238,7 +238,7 @@ # Create a development shell of hls project # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319 - mkDevShell = hpkgs: + mkDevShell = hpkgs: cabalProject: with pkgs; hpkgs.shellFor { doBenchmark = true; @@ -277,6 +277,8 @@ export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib export PATH=$PATH:$HOME/.local/bin ${(pre-commit-check ghcDefault).shellHook} + + alias cabal='cabal --project-file=${cabalProject}' ''; }; # Create a hls executable @@ -295,15 +297,15 @@ })); in with pkgs; rec { - packages = { - # dev shell - haskell-language-server-dev = mkDevShell ghcDefault; - haskell-language-server-884-dev = mkDevShell ghc884; - haskell-language-server-8107-dev = mkDevShell ghc8107; - haskell-language-server-901-dev = mkDevShell ghc901; - haskell-language-server-921-dev = mkDevShell ghc921; + devShells = { + haskell-language-server-dev = mkDevShell ghcDefault "cabal.project"; + haskell-language-server-884-dev = mkDevShell ghc884 "cabal.project"; + haskell-language-server-8107-dev = mkDevShell ghc8107 "cabal.project"; + haskell-language-server-901-dev = mkDevShell ghc901 "cabal-ghc90.project"; + haskell-language-server-921-dev = mkDevShell ghc921 "cabal-ghc921.project"; + }; - # hls package + packages = { haskell-language-server = mkExe ghcDefault; haskell-language-server-884 = mkExe ghc884; haskell-language-server-8107 = mkExe ghc8107; @@ -316,6 +318,6 @@ defaultPackage = packages.haskell-language-server; - devShell = packages.haskell-language-server-dev; + devShell = devShells.haskell-language-server-dev; }); } From 55bdbe9d72da70908c4cdb0ec6607f31839e5086 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 16:31:36 +0100 Subject: [PATCH 06/17] nix: remove special case for different ghc versions --- configuration-ghc-901.nix | 2 ++ configuration-ghc-921.nix | 2 ++ flake.nix | 8 ++------ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configuration-ghc-901.nix b/configuration-ghc-901.nix index 62d83c9cc0..789a5d2e19 100644 --- a/configuration-ghc-901.nix +++ b/configuration-ghc-901.nix @@ -10,6 +10,8 @@ let hpkgsOverride = hself: hsuper: with pkgs.haskell.lib; { + hlsDisabledPlugins = disabledPlugins; + fourmolu = hself.fourmolu_0_4_0_0; primitive-extras = hself.primitive-extras_0_10_1_2; diff --git a/configuration-ghc-921.nix b/configuration-ghc-921.nix index db9f28a2c7..9d9db422b1 100644 --- a/configuration-ghc-921.nix +++ b/configuration-ghc-921.nix @@ -19,6 +19,8 @@ let hpkgsOverride = hself: hsuper: with pkgs.haskell.lib; { + hlsDisabledPlugins = disabledPlugins; + fourmolu = hself.callCabal2nix "fourmolu" inputs.fourmolu {}; primitive-extras = hself.primitive-extras_0_10_1_2; ghc-exactprint = hself.callCabal2nix "ghc-exactprint" inputs.ghc-exactprint {}; diff --git a/flake.nix b/flake.nix index 8bdf84a644..0db9f77718 100644 --- a/flake.nix +++ b/flake.nix @@ -245,12 +245,8 @@ packages = p: with builtins; map (name: p.${name}) (attrNames - (if hpkgs.ghc.version == "9.0.1" then - removeAttrs hlsSources ghc901Config.disabledPlugins - else if hpkgs.ghc.version == "9.2.1" then - removeAttrs hlsSources ghc921Config.disabledPlugins - else - hlsSources)); + # Disable dependencies should not be part of the shell. + (removeAttrs hlsSources (hpkgs.hlsDisabledPlugins or []))); # For theses tools packages, we use ghcDefault # This removes a rebuild with a different GHC version # Theses programs are tools, used as binary, independently of the From 7343de6f0c58248a21ae098f7fcc89fc42a76cd4 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 29 Jan 2022 16:38:52 +0100 Subject: [PATCH 07/17] nix: move implicit-hie-cradle as a flake input --- flake.lock | 13 +++++++++++++ flake.nix | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 63fe7a6be4..8a2edb2643 100644 --- a/flake.lock +++ b/flake.lock @@ -110,6 +110,18 @@ "url": "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz" } }, + "implicit-hie-cradle": { + "flake": false, + "locked": { + "narHash": "sha256-2NmucBBI7Qi1UGXWG27XFZRCeqeRiwVFWmJKZnp6R5U=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz" + } + }, "lsp": { "flake": false, "locked": { @@ -216,6 +228,7 @@ "ghc-exactprint": "ghc-exactprint", "gitignore": "gitignore", "hlint": "hlint", + "implicit-hie-cradle": "implicit-hie-cradle", "lsp": "lsp", "lsp-test": "lsp-test", "lsp-types": "lsp-types", diff --git a/flake.nix b/flake.nix index 0db9f77718..070af9b9bd 100644 --- a/flake.nix +++ b/flake.nix @@ -55,6 +55,10 @@ url = "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz"; flake = false; }; + implicit-hie-cradle = { + url = "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz"; + flake = false; + }; }; outputs = inputs@{ self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore, ... }: @@ -113,11 +117,7 @@ lsp-types = hsuper.callCabal2nix "lsp-types" inputs.lsp-types {}; lsp-test = hsuper.callCabal2nix "lsp-test" inputs.lsp-test {}; - implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" - (builtins.fetchTarball { - url = "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz"; - sha256 = "15a7g9x6cjk2b92hb2wilxx4550msxp1pmk5a2shiva821qaxnfq"; - }) { }; + implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; # https://github.com/NixOS/nixpkgs/issues/140774 ormolu = From 73d99ec8d51bae64d0a027e1dc699584fef3c8fe Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 31 Jan 2022 22:06:30 +0100 Subject: [PATCH 08/17] nix: restore dev shell This commit restores a working behavior for `nix-shell` or `nix develop`, for all supported GHC versions. When entering a `nix-shell`, or `nix develop .#haskell-language-server-ghcXxX-dev` you will get an environment with all the dependencies needed to run `cabal build`. Haskell dependencies will be built by cabal instead of nix. This may be more robust compared to a shell where dependencies are built by nix: - It won't try to build any dependency with nix. This mean that it won't benefit from nix caching, but on the other hand, it will perfectly match the cabal plan. - The nix shell may fail to start if an (possibly unneeded) dependency was failing to build. Entering nix-shell also generates an alias command `cabal_project` which runs cabal with the correct project file if needed (e.g. for GHC 9.0 and 9.2). Users are notified with a message when entering the shell. The old behavior (i.e. where dependencies are built with nix) is still available with `nix develop .#haskell-language-server-xxx-dev-nix` (i.e. suffix the name of the shell with `-nix`). --- flake.nix | 94 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index 070af9b9bd..073fe02667 100644 --- a/flake.nix +++ b/flake.nix @@ -236,46 +236,78 @@ dontInstall = true; }; + mkDevShell = hpkgs: cabalProject: with pkgs; mkShell { + # For theses tools packages, we use ghcDefault + # This removes a rebuild with a different GHC version + # Theses programs are tools, used as binary, independently of the + # version of GHC. + # The drawback of this approach is that our shell may pull two GHC + # version in scope (the default one, and the one defined in + # `hpkgs`.) + # The advantage is that we won't have to rebuild theses tools (and + # dependencies) with a recent GHC which may not be supported by + # them. + buildInputs = [ + # our compiling toolchain + hpkgs.ghc + pkgs.cabal-install + # @guibou: I'm not sure hie-bios is needed + ghcDefault.hie-bios + # Dependencies needed to build some parts of hackage + gmp zlib ncurses + # Changelog tooling + (gen-hls-changelogs ghcDefault) + # For the documentation + pythonWithPackages + # @guibou: I'm not sure this is needed. + hlint + ghcDefault.opentelemetry-extra + capstone tracy + # ormolu + # stylish-haskell + ]; + + + shellHook = '' + # @guibou: I'm not sure theses lines are needed + export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib + export PATH=$PATH:$HOME/.local/bin + + # Enable the shell hooks + ${(pre-commit-check ghcDefault).shellHook} + + # If the cabal project file is not the default one. + # Print a warning and generate an alias. + if [ ${cabalProject} != "cabal.project" ] + then + echo "Cabal won't be able to build your project without using the project file "${cabalProject}", such as:" + echo " cabal --project-file=${cabalProject}" + echo "An alias "cabal_project" is available. Use it like:" + echo " cabal_project build" + + alias cabal_project='cabal --project-file=${cabalProject}' + fi + ''; + }; + # Create a development shell of hls project # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319 - mkDevShell = hpkgs: cabalProject: + mkDevShellWithNixDeps = hpkgs: cabalProject: with pkgs; + let simpleShell = mkDevShell hpkgs cabalProject; + in hpkgs.shellFor { + inherit (simpleShell) shellHook buildInputs; + doBenchmark = true; packages = p: with builtins; map (name: p.${name}) (attrNames # Disable dependencies should not be part of the shell. (removeAttrs hlsSources (hpkgs.hlsDisabledPlugins or []))); - # For theses tools packages, we use ghcDefault - # This removes a rebuild with a different GHC version - # Theses programs are tools, used as binary, independently of the - # version of GHC. - # The drawback of this approach is that our shell may pull two GHC - # version in scope (the `ghcDefault` one, and the one defined in - # `hpkgs`.) - # The advantage is that we won't have to rebuild theses tools (and - # dependencies) with a recent GHC which may not be supported by - # them. - buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs ghcDefault) pythonWithPackages ] - ++ [ - pkgs.cabal-install - ghcDefault.hie-bios - hlint - # ormolu - # stylish-haskell - ghcDefault.opentelemetry-extra - ]; src = null; - shellHook = '' - export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib - export PATH=$PATH:$HOME/.local/bin - ${(pre-commit-check ghcDefault).shellHook} - - alias cabal='cabal --project-file=${cabalProject}' - ''; }; # Create a hls executable # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16 @@ -299,6 +331,12 @@ haskell-language-server-8107-dev = mkDevShell ghc8107 "cabal.project"; haskell-language-server-901-dev = mkDevShell ghc901 "cabal-ghc90.project"; haskell-language-server-921-dev = mkDevShell ghc921 "cabal-ghc921.project"; + + haskell-language-server-dev-nix = mkDevShellWithNixDeps ghcDefault "cabal.project"; + haskell-language-server-884-dev-nix = mkDevShellWithNixDeps ghc884 "cabal.project"; + haskell-language-server-8107-dev-nix = mkDevShellWithNixDeps ghc8107 "cabal.project"; + haskell-language-server-901-dev-nix = mkDevShellWithNixDeps ghc901 "cabal-ghc90.project"; + haskell-language-server-921-dev-nix = mkDevShellWithNixDeps ghc921 "cabal-ghc921.project"; }; packages = { From 7b6015288cca4cb26f4c34355fe5d5f7c7532614 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 7 Feb 2022 16:35:11 +0100 Subject: [PATCH 09/17] nix: New entries which build all target at once All HLS version can be built with `nix build .#all-haskell-language-server`, and all development shells with `nix build .#all-dev-shells`. I had to workaround a limitation in `nix build` which is not able to build multiples targets, instead I used linkFarmFromDrvs. All packages and shells are now named with a unique package name containing the GHC version. --- flake.nix | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 073fe02667..52828a1751 100644 --- a/flake.nix +++ b/flake.nix @@ -237,6 +237,7 @@ }; mkDevShell = hpkgs: cabalProject: with pkgs; mkShell { + name = "haskell-language-server-dev-ghc${hpkgs.ghc.version}"; # For theses tools packages, we use ghcDefault # This removes a rebuild with a different GHC version # Theses programs are tools, used as binary, independently of the @@ -298,6 +299,7 @@ let simpleShell = mkDevShell hpkgs cabalProject; in hpkgs.shellFor { + name = "haskell-language-server-dev-nix-ghc${hpkgs.ghc.version}"; inherit (simpleShell) shellHook buildInputs; doBenchmark = true; @@ -313,7 +315,7 @@ # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16 mkExe = hpkgs: with pkgs.haskell.lib; - justStaticExecutables (overrideCabal hpkgs.haskell-language-server + (justStaticExecutables (overrideCabal hpkgs.haskell-language-server (_: { postInstall = '' remove-references-to -t ${hpkgs.ghc} $out/bin/haskell-language-server @@ -322,7 +324,9 @@ remove-references-to -t ${hpkgs.js-dgtable.data} $out/bin/haskell-language-server remove-references-to -t ${hpkgs.js-flot.data} $out/bin/haskell-language-server ''; - })); + }))).overrideAttrs(old: { + pname = old.pname + "-ghc${hpkgs.ghc.version}"; + }); in with pkgs; rec { devShells = { @@ -339,14 +343,26 @@ haskell-language-server-921-dev-nix = mkDevShellWithNixDeps ghc921 "cabal-ghc921.project"; }; - packages = { + allPackages = { haskell-language-server = mkExe ghcDefault; haskell-language-server-884 = mkExe ghc884; haskell-language-server-8107 = mkExe ghc8107; haskell-language-server-901 = mkExe ghc901; haskell-language-server-921 = mkExe ghc921; + }; + + packages = allPackages // { + # See https://github.com/NixOS/nix/issues/5591 + # nix flake cannot build a list/set of derivation in one command. + # Using a linkFarmFromDrvs, I'm creating a unique entry point to + # build all HLS versions. + # This is used in CI to test and populate cache for packages + # distributed using nix. + all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages)); + + # Same for all shells + all-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues devShells))); - # docs docs = docs; }; From fe53c28e0e3df56ab8e438226fd95efe11f3e31d Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 7 Feb 2022 17:29:56 +0100 Subject: [PATCH 10/17] nix: Build all devShells and all binaries in CI --- .github/workflows/nix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 1cdf937d09..2c2dd3d604 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -103,15 +103,15 @@ jobs: authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - name: Build development shell run: nix develop --print-build-logs --profile dev - - name: Build development shell (GHC 9.0.1) - run: nix develop --print-build-logs .#haskell-language-server-901-dev --profile dev + - name: Build all development shell + run: nix develop --print-build-logs .#all-dev-shells --profile dev - name: Push development shell if: ${{ env.HAS_TOKEN == 'true' }} run: cachix push haskell-language-server dev - name: Build binaries run: nix build --print-build-logs - - name: Build binaries (GHC 9.0.1) - run: nix build --print-build-logs .#haskell-language-server-901 + - name: Build all binaries + run: nix build --print-build-logs all-haskell-language-server - name: Push binaries if: ${{ env.HAS_TOKEN == 'true' }} run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server From 34c3911795dbfef45faa07a0b197359f569e5bcf Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 7 Feb 2022 18:15:00 +0100 Subject: [PATCH 11/17] nix: build HLS with dynamic linking Related to #2668. This fixs the build, however, because now HLS is dynamicly linked, it pulls GHC as a dependency. The uncompressed closure size is now `~6GiB`. --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 52828a1751..fe3a7f3e53 100644 --- a/flake.nix +++ b/flake.nix @@ -315,10 +315,9 @@ # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16 mkExe = hpkgs: with pkgs.haskell.lib; - (justStaticExecutables (overrideCabal hpkgs.haskell-language-server + (enableSharedExecutables (overrideCabal hpkgs.haskell-language-server (_: { postInstall = '' - remove-references-to -t ${hpkgs.ghc} $out/bin/haskell-language-server remove-references-to -t ${hpkgs.shake.data} $out/bin/haskell-language-server remove-references-to -t ${hpkgs.js-jquery.data} $out/bin/haskell-language-server remove-references-to -t ${hpkgs.js-dgtable.data} $out/bin/haskell-language-server From a4164ac64bb5748c74aa07084d7e7a522a64ea57 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 7 Feb 2022 23:28:21 +0100 Subject: [PATCH 12/17] nix; fix CI command --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 2c2dd3d604..a4005318fd 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -111,7 +111,7 @@ jobs: - name: Build binaries run: nix build --print-build-logs - name: Build all binaries - run: nix build --print-build-logs all-haskell-language-server + run: nix build --print-build-logs .#all-haskell-language-server - name: Push binaries if: ${{ env.HAS_TOKEN == 'true' }} run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server From 00aa810870a2c4fba00845441026a951dbc098d2 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sat, 12 Feb 2022 14:54:55 +0100 Subject: [PATCH 13/17] nix: only build dev shell with nix packages for current GHC version --- .github/workflows/nix.yml | 8 ++++++-- flake.nix | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index a4005318fd..acede908c9 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -103,8 +103,12 @@ jobs: authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - name: Build development shell run: nix develop --print-build-logs --profile dev - - name: Build all development shell - run: nix develop --print-build-logs .#all-dev-shells --profile dev + - name: Build all development shell (without nix dependencies) + run: nix develop --print-build-logs .#all-simple-dev-shells --profile dev + # We only build nix dev shell for current GHC version because some are + # failing with different GHC version on darwin. + - name: Build development shell with nix dependencies for current GHC version + run: nix develop --print-build-logs .#haskell-language-server-dev --profile dev - name: Push development shell if: ${{ env.HAS_TOKEN == 'true' }} run: cachix push haskell-language-server dev diff --git a/flake.nix b/flake.nix index fe3a7f3e53..2787b76ea5 100644 --- a/flake.nix +++ b/flake.nix @@ -327,14 +327,17 @@ pname = old.pname + "-ghc${hpkgs.ghc.version}"; }); in with pkgs; rec { - - devShells = { + # Developement shell with only compiler + simpleDevShells = { haskell-language-server-dev = mkDevShell ghcDefault "cabal.project"; haskell-language-server-884-dev = mkDevShell ghc884 "cabal.project"; haskell-language-server-8107-dev = mkDevShell ghc8107 "cabal.project"; haskell-language-server-901-dev = mkDevShell ghc901 "cabal-ghc90.project"; haskell-language-server-921-dev = mkDevShell ghc921 "cabal-ghc921.project"; + }; + # Developement shell, haskell packages are also provided by nix + nixDevShells = { haskell-language-server-dev-nix = mkDevShellWithNixDeps ghcDefault "cabal.project"; haskell-language-server-884-dev-nix = mkDevShellWithNixDeps ghc884 "cabal.project"; haskell-language-server-8107-dev-nix = mkDevShellWithNixDeps ghc8107 "cabal.project"; @@ -350,6 +353,8 @@ haskell-language-server-921 = mkExe ghc921; }; + devShells = simpleDevShells // nixDevShells; + packages = allPackages // { # See https://github.com/NixOS/nix/issues/5591 # nix flake cannot build a list/set of derivation in one command. @@ -362,6 +367,7 @@ # Same for all shells all-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues devShells))); + all-simple-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); docs = docs; }; From 021c5c0e1ccf9c54d4d0f65c521b598d6dd96bb5 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Tue, 15 Feb 2022 23:20:34 +0100 Subject: [PATCH 14/17] Another tentative to fix the build --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2787b76ea5..914739a89a 100644 --- a/flake.nix +++ b/flake.nix @@ -365,7 +365,7 @@ all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages)); # Same for all shells - all-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues devShells))); + all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues [nixDevShells.haskell-language-server-dev-nix]))); all-simple-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); docs = docs; From 499fd42f0fd880aeb8c6fdb2a369ad29f9eb98fd Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Tue, 15 Feb 2022 23:22:18 +0100 Subject: [PATCH 15/17] fix: Eval and alternate number format works with ghc 9.2 --- configuration-ghc-921.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configuration-ghc-921.nix b/configuration-ghc-921.nix index 9d9db422b1..fbb3bee780 100644 --- a/configuration-ghc-921.nix +++ b/configuration-ghc-921.nix @@ -7,8 +7,6 @@ let "hls-stylish-haskell-plugin" "hls-hlint-plugin" "hls-haddock-comments-plugin" - "hls-alternate-number-format-plugin" - "hls-eval-plugin" "hls-tactics-plugin" # That one is not technically a plugin, but by putting it in this list, we # get it removed from the top level list of requirement and it is not pull @@ -39,8 +37,6 @@ let "-f-stylishHaskell" "-f-hlint" "-f-haddockComments" - "-f-alternateNumberFormat" - "-f-eval" "-f-tactics" ]) { }; From 2a643d9f222a80764e4e14c665204ed3c7f3b06e Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Tue, 15 Feb 2022 23:29:49 +0100 Subject: [PATCH 16/17] fix CI build --- .github/workflows/nix.yml | 2 +- flake.nix | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index acede908c9..e71e6a60be 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -108,7 +108,7 @@ jobs: # We only build nix dev shell for current GHC version because some are # failing with different GHC version on darwin. - name: Build development shell with nix dependencies for current GHC version - run: nix develop --print-build-logs .#haskell-language-server-dev --profile dev + run: nix develop --print-build-logs .#all-nix-dev-shells --profile dev - name: Push development shell if: ${{ env.HAS_TOKEN == 'true' }} run: cachix push haskell-language-server dev diff --git a/flake.nix b/flake.nix index 914739a89a..2acec94ee4 100644 --- a/flake.nix +++ b/flake.nix @@ -365,6 +365,8 @@ all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages)); # Same for all shells + # We try to build as much as possible, but not much shells are + # working (especially on darwing), so this list is limited. all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues [nixDevShells.haskell-language-server-dev-nix]))); all-simple-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); From 0540fcf81eeb4346fd46b1121cfe66f71fcaa381 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Tue, 15 Feb 2022 23:42:27 +0100 Subject: [PATCH 17/17] ANother tentative fix --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2acec94ee4..2743d1b95e 100644 --- a/flake.nix +++ b/flake.nix @@ -367,7 +367,7 @@ # Same for all shells # We try to build as much as possible, but not much shells are # working (especially on darwing), so this list is limited. - all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues [nixDevShells.haskell-language-server-dev-nix]))); + all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique [nixDevShells.haskell-language-server-dev-nix])); all-simple-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); docs = docs;