|
236 | 236 | dontInstall = true;
|
237 | 237 | };
|
238 | 238 |
|
| 239 | + mkDevShell = hpkgs: cabalProject: with pkgs; mkShell { |
| 240 | + # For theses tools packages, we use ghcDefault |
| 241 | + # This removes a rebuild with a different GHC version |
| 242 | + # Theses programs are tools, used as binary, independently of the |
| 243 | + # version of GHC. |
| 244 | + # The drawback of this approach is that our shell may pull two GHC |
| 245 | + # version in scope (the default one, and the one defined in |
| 246 | + # `hpkgs`.) |
| 247 | + # The advantage is that we won't have to rebuild theses tools (and |
| 248 | + # dependencies) with a recent GHC which may not be supported by |
| 249 | + # them. |
| 250 | + buildInputs = [ |
| 251 | + # our compiling toolchain |
| 252 | + hpkgs.ghc |
| 253 | + pkgs.cabal-install |
| 254 | + # @guibou: I'm not sure hie-bios is needed |
| 255 | + ghcDefault.hie-bios |
| 256 | + # Dependencies needed to build some parts of hackage |
| 257 | + gmp zlib ncurses |
| 258 | + # Changelog tooling |
| 259 | + (gen-hls-changelogs ghcDefault) |
| 260 | + # For the documentation |
| 261 | + pythonWithPackages |
| 262 | + # @guibou: I'm not sure this is needed. |
| 263 | + hlint |
| 264 | + ghcDefault.opentelemetry-extra |
| 265 | + capstone tracy |
| 266 | + # ormolu |
| 267 | + # stylish-haskell |
| 268 | + ]; |
| 269 | + |
| 270 | + |
| 271 | + shellHook = '' |
| 272 | + # @guibou: I'm not sure theses lines are needed |
| 273 | + export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
| 274 | + export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
| 275 | + export PATH=$PATH:$HOME/.local/bin |
| 276 | +
|
| 277 | + # Enable the shell hooks |
| 278 | + ${(pre-commit-check ghcDefault).shellHook} |
| 279 | +
|
| 280 | + # If the cabal project file is not the default one. |
| 281 | + # Print a warning and generate an alias. |
| 282 | + if [ ${cabalProject} != "cabal.project" ] |
| 283 | + then |
| 284 | + echo "Cabal won't be able to build your project without using the project file "${cabalProject}", such as:" |
| 285 | + echo " cabal --project-file=${cabalProject}" |
| 286 | + echo "An alias "cabal_project" is available. Use it like:" |
| 287 | + echo " cabal_project build" |
| 288 | +
|
| 289 | + alias cabal_project='cabal --project-file=${cabalProject}' |
| 290 | + fi |
| 291 | + ''; |
| 292 | + }; |
| 293 | + |
239 | 294 | # Create a development shell of hls project
|
240 | 295 | # See https://github.com/NixOS/nixpkgs/blob/5d4a430472cafada97888cc80672fab255231f57/pkgs/development/haskell-modules/make-package-set.nix#L319
|
241 |
| - mkDevShell = hpkgs: cabalProject: |
| 296 | + mkDevShellWithNixDeps = hpkgs: cabalProject: |
242 | 297 | with pkgs;
|
| 298 | + let simpleShell = mkDevShell hpkgs cabalProject; |
| 299 | + in |
243 | 300 | hpkgs.shellFor {
|
| 301 | + inherit (simpleShell) shellHook buildInputs; |
| 302 | + |
244 | 303 | doBenchmark = true;
|
245 | 304 | packages = p:
|
246 | 305 | with builtins;
|
247 | 306 | map (name: p.${name}) (attrNames
|
248 | 307 | # Disable dependencies should not be part of the shell.
|
249 | 308 | (removeAttrs hlsSources (hpkgs.hlsDisabledPlugins or [])));
|
250 |
| - # For theses tools packages, we use ghcDefault |
251 |
| - # This removes a rebuild with a different GHC version |
252 |
| - # Theses programs are tools, used as binary, independently of the |
253 |
| - # version of GHC. |
254 |
| - # The drawback of this approach is that our shell may pull two GHC |
255 |
| - # version in scope (the `ghcDefault` one, and the one defined in |
256 |
| - # `hpkgs`.) |
257 |
| - # The advantage is that we won't have to rebuild theses tools (and |
258 |
| - # dependencies) with a recent GHC which may not be supported by |
259 |
| - # them. |
260 |
| - buildInputs = [ gmp zlib ncurses capstone tracy (gen-hls-changelogs ghcDefault) pythonWithPackages ] |
261 |
| - ++ [ |
262 |
| - pkgs.cabal-install |
263 |
| - ghcDefault.hie-bios |
264 |
| - hlint |
265 |
| - # ormolu |
266 |
| - # stylish-haskell |
267 |
| - ghcDefault.opentelemetry-extra |
268 |
| - ]; |
269 | 309 |
|
270 | 310 | src = null;
|
271 |
| - shellHook = '' |
272 |
| - export LD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
273 |
| - export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib |
274 |
| - export PATH=$PATH:$HOME/.local/bin |
275 |
| - ${(pre-commit-check ghcDefault).shellHook} |
276 |
| -
|
277 |
| - alias cabal='cabal --project-file=${cabalProject}' |
278 |
| - ''; |
279 | 311 | };
|
280 | 312 | # Create a hls executable
|
281 | 313 | # Copied from https://github.com/NixOS/nixpkgs/blob/210784b7c8f3d926b7db73bdad085f4dc5d79418/pkgs/development/tools/haskell/haskell-language-server/withWrapper.nix#L16
|
|
299 | 331 | haskell-language-server-8107-dev = mkDevShell ghc8107 "cabal.project";
|
300 | 332 | haskell-language-server-901-dev = mkDevShell ghc901 "cabal-ghc90.project";
|
301 | 333 | haskell-language-server-921-dev = mkDevShell ghc921 "cabal-ghc921.project";
|
| 334 | + |
| 335 | + haskell-language-server-dev-nix = mkDevShellWithNixDeps ghcDefault "cabal.project"; |
| 336 | + haskell-language-server-884-dev-nix = mkDevShellWithNixDeps ghc884 "cabal.project"; |
| 337 | + haskell-language-server-8107-dev-nix = mkDevShellWithNixDeps ghc8107 "cabal.project"; |
| 338 | + haskell-language-server-901-dev-nix = mkDevShellWithNixDeps ghc901 "cabal-ghc90.project"; |
| 339 | + haskell-language-server-921-dev-nix = mkDevShellWithNixDeps ghc921 "cabal-ghc921.project"; |
302 | 340 | };
|
303 | 341 |
|
304 | 342 | packages = {
|
|
0 commit comments