|
55 | 55 | url = "https://hackage.haskell.org/package/hlint-3.3.6/hlint-3.3.6.tar.gz";
|
56 | 56 | flake = false;
|
57 | 57 | };
|
| 58 | + implicit-hie-cradle = { |
| 59 | + url = "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz"; |
| 60 | + flake = false; |
| 61 | + }; |
58 | 62 | };
|
59 | 63 | outputs =
|
60 | 64 | inputs@{ self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore, ... }:
|
|
113 | 117 | lsp-types = hsuper.callCabal2nix "lsp-types" inputs.lsp-types {};
|
114 | 118 | lsp-test = hsuper.callCabal2nix "lsp-test" inputs.lsp-test {};
|
115 | 119 |
|
116 |
| - implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" |
117 |
| - (builtins.fetchTarball { |
118 |
| - url = "https://hackage.haskell.org/package/implicit-hie-cradle-0.3.0.5/implicit-hie-cradle-0.3.0.5.tar.gz"; |
119 |
| - sha256 = "15a7g9x6cjk2b92hb2wilxx4550msxp1pmk5a2shiva821qaxnfq"; |
120 |
| - }) { }; |
| 120 | + implicit-hie-cradle = hself.callCabal2nix "implicit-hie-cradle" inputs.implicit-hie-cradle {}; |
121 | 121 |
|
122 | 122 | # https://github.com/NixOS/nixpkgs/issues/140774
|
123 | 123 | ormolu =
|
|
236 | 236 | dontInstall = true;
|
237 | 237 | };
|
238 | 238 |
|
| 239 | + mkDevShell = hpkgs: cabalProject: with pkgs; mkShell { |
| 240 | + name = "haskell-language-server-dev-ghc${hpkgs.ghc.version}"; |
| 241 | + # For theses tools packages, we use ghcDefault |
| 242 | + # This removes a rebuild with a different GHC version |
| 243 | + # Theses programs are tools, used as binary, independently of the |
| 244 | + # version of GHC. |
| 245 | + # The drawback of this approach is that our shell may pull two GHC |
| 246 | + # version in scope (the default one, and the one defined in |
| 247 | + # `hpkgs`.) |
| 248 | + # The advantage is that we won't have to rebuild theses tools (and |
| 249 | + # dependencies) with a recent GHC which may not be supported by |
| 250 | + # them. |
| 251 | + buildInputs = [ |
| 252 | + # our compiling toolchain |
| 253 | + hpkgs.ghc |
| 254 | + pkgs.cabal-install |
| 255 | + # @guibou: I'm not sure hie-bios is needed |
| 256 | + ghcDefault.hie-bios |
| 257 | + # Dependencies needed to build some parts of hackage |
| 258 | + gmp zlib ncurses |
| 259 | + # Changelog tooling |
| 260 | + (gen-hls-changelogs ghcDefault) |
| 261 | + # For the documentation |
| 262 | + pythonWithPackages |
| 263 | + # @guibou: I'm not sure this is needed. |
| 264 | + hlint |
| 265 | + ghcDefault.opentelemetry-extra |
| 266 | + capstone tracy |
| 267 | + # ormolu |
| 268 | + # stylish-haskell |
| 269 | + ]; |
| 270 | + |
| 271 | + |
| 272 | + shellHook = '' |
| 273 | + # @guibou: I'm not sure theses lines are needed |
| 274 | + export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
| 275 | + export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
| 276 | + export PATH=$PATH:$HOME/.local/bin |
| 277 | +
|
| 278 | + # Enable the shell hooks |
| 279 | + ${(pre-commit-check ghcDefault).shellHook} |
| 280 | +
|
| 281 | + # If the cabal project file is not the default one. |
| 282 | + # Print a warning and generate an alias. |
| 283 | + if [ ${cabalProject} != "cabal.project" ] |
| 284 | + then |
| 285 | + echo "Cabal won't be able to build your project without using the project file "${cabalProject}", such as:" |
| 286 | + echo " cabal --project-file=${cabalProject}" |
| 287 | + echo "An alias "cabal_project" is available. Use it like:" |
| 288 | + echo " cabal_project build" |
| 289 | +
|
| 290 | + alias cabal_project='cabal --project-file=${cabalProject}' |
| 291 | + fi |
| 292 | + ''; |
| 293 | + }; |
| 294 | + |
239 | 295 | # Create a development shell of hls project
|
240 | 296 | # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319
|
241 |
| - mkDevShell = hpkgs: |
| 297 | + mkDevShellWithNixDeps = hpkgs: cabalProject: |
242 | 298 | with pkgs;
|
| 299 | + let simpleShell = mkDevShell hpkgs cabalProject; |
| 300 | + in |
243 | 301 | hpkgs.shellFor {
|
| 302 | + name = "haskell-language-server-dev-nix-ghc${hpkgs.ghc.version}"; |
| 303 | + inherit (simpleShell) shellHook buildInputs; |
| 304 | + |
244 | 305 | doBenchmark = true;
|
245 | 306 | packages = p:
|
246 | 307 | with builtins;
|
247 | 308 | map (name: p.${name}) (attrNames
|
248 |
| - (if hpkgs.ghc.version == "9.0.1" then |
249 |
| - removeAttrs hlsSources ghc901Config.disabledPlugins |
250 |
| - else if hpkgs.ghc.version == "9.2.1" then |
251 |
| - removeAttrs hlsSources ghc921Config.disabledPlugins |
252 |
| - else |
253 |
| - hlsSources)); |
254 |
| - buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs hpkgs) pythonWithPackages ] |
255 |
| - ++ (with hpkgs; [ |
256 |
| - cabal-install |
257 |
| - hie-bios |
258 |
| - hlint |
259 |
| - # ormolu |
260 |
| - # stylish-haskell |
261 |
| - opentelemetry-extra |
262 |
| - ]); |
| 309 | + # Disable dependencies should not be part of the shell. |
| 310 | + (removeAttrs hlsSources (hpkgs.hlsDisabledPlugins or []))); |
263 | 311 |
|
264 | 312 | src = null;
|
265 |
| - shellHook = '' |
266 |
| - export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
267 |
| - export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
268 |
| - export PATH=$PATH:$HOME/.local/bin |
269 |
| - ${if hpkgs.ghc.version != "9.0.1" then (pre-commit-check hpkgs).shellHook else ""} |
270 |
| - ''; |
271 | 313 | };
|
272 | 314 | # Create a hls executable
|
273 | 315 | # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16
|
274 | 316 | mkExe = hpkgs:
|
275 | 317 | with pkgs.haskell.lib;
|
276 |
| - justStaticExecutables (overrideCabal hpkgs.haskell-language-server |
| 318 | + (enableSharedExecutables (overrideCabal hpkgs.haskell-language-server |
277 | 319 | (_: {
|
278 | 320 | postInstall = ''
|
279 |
| - remove-references-to -t ${hpkgs.ghc} $out/bin/haskell-language-server |
280 | 321 | remove-references-to -t ${hpkgs.shake.data} $out/bin/haskell-language-server
|
281 | 322 | remove-references-to -t ${hpkgs.js-jquery.data} $out/bin/haskell-language-server
|
282 | 323 | remove-references-to -t ${hpkgs.js-dgtable.data} $out/bin/haskell-language-server
|
283 | 324 | remove-references-to -t ${hpkgs.js-flot.data} $out/bin/haskell-language-server
|
284 | 325 | '';
|
285 |
| - })); |
| 326 | + }))).overrideAttrs(old: { |
| 327 | + pname = old.pname + "-ghc${hpkgs.ghc.version}"; |
| 328 | + }); |
286 | 329 | in with pkgs; rec {
|
| 330 | + # Developement shell with only compiler |
| 331 | + simpleDevShells = { |
| 332 | + haskell-language-server-dev = mkDevShell ghcDefault "cabal.project"; |
| 333 | + haskell-language-server-884-dev = mkDevShell ghc884 "cabal.project"; |
| 334 | + haskell-language-server-8107-dev = mkDevShell ghc8107 "cabal.project"; |
| 335 | + haskell-language-server-901-dev = mkDevShell ghc901 "cabal-ghc90.project"; |
| 336 | + haskell-language-server-921-dev = mkDevShell ghc921 "cabal-ghc921.project"; |
| 337 | + }; |
287 | 338 |
|
288 |
| - packages = { |
289 |
| - # dev shell |
290 |
| - haskell-language-server-dev = mkDevShell ghcDefault; |
291 |
| - haskell-language-server-884-dev = mkDevShell ghc884; |
292 |
| - haskell-language-server-8107-dev = mkDevShell ghc8107; |
293 |
| - haskell-language-server-901-dev = mkDevShell ghc901; |
294 |
| - haskell-language-server-921-dev = mkDevShell ghc921; |
| 339 | + # Developement shell, haskell packages are also provided by nix |
| 340 | + nixDevShells = { |
| 341 | + haskell-language-server-dev-nix = mkDevShellWithNixDeps ghcDefault "cabal.project"; |
| 342 | + haskell-language-server-884-dev-nix = mkDevShellWithNixDeps ghc884 "cabal.project"; |
| 343 | + haskell-language-server-8107-dev-nix = mkDevShellWithNixDeps ghc8107 "cabal.project"; |
| 344 | + haskell-language-server-901-dev-nix = mkDevShellWithNixDeps ghc901 "cabal-ghc90.project"; |
| 345 | + haskell-language-server-921-dev-nix = mkDevShellWithNixDeps ghc921 "cabal-ghc921.project"; |
| 346 | + }; |
295 | 347 |
|
296 |
| - # hls package |
| 348 | + allPackages = { |
297 | 349 | haskell-language-server = mkExe ghcDefault;
|
298 | 350 | haskell-language-server-884 = mkExe ghc884;
|
299 | 351 | haskell-language-server-8107 = mkExe ghc8107;
|
300 | 352 | haskell-language-server-901 = mkExe ghc901;
|
301 | 353 | haskell-language-server-921 = mkExe ghc921;
|
| 354 | + }; |
| 355 | + |
| 356 | + devShells = simpleDevShells // nixDevShells; |
| 357 | + |
| 358 | + packages = allPackages // { |
| 359 | + # See https://github.com/NixOS/nix/issues/5591 |
| 360 | + # nix flake cannot build a list/set of derivation in one command. |
| 361 | + # Using a linkFarmFromDrvs, I'm creating a unique entry point to |
| 362 | + # build all HLS versions. |
| 363 | + # This is used in CI to test and populate cache for packages |
| 364 | + # distributed using nix. |
| 365 | + all-haskell-language-server = linkFarmFromDrvs "all-haskell-language-server" (lib.unique (builtins.attrValues allPackages)); |
| 366 | + |
| 367 | + # Same for all shells |
| 368 | + # We try to build as much as possible, but not much shells are |
| 369 | + # working (especially on darwing), so this list is limited. |
| 370 | + all-nix-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique [nixDevShells.haskell-language-server-dev-nix])); |
302 | 371 |
|
303 |
| - # docs |
| 372 | + all-simple-dev-shells = linkFarmFromDrvs "all-dev-shells" (builtins.map (shell: shell.inputDerivation) (lib.unique (builtins.attrValues simpleDevShells))); |
304 | 373 | docs = docs;
|
305 | 374 | };
|
306 | 375 |
|
307 | 376 | defaultPackage = packages.haskell-language-server;
|
308 | 377 |
|
309 |
| - devShell = packages.haskell-language-server-dev; |
| 378 | + devShell = devShells.haskell-language-server-dev; |
310 | 379 | });
|
311 | 380 | }
|
0 commit comments