diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 134491932438..2dc4de9d44e8 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -100,6 +100,46 @@ self: super: { guardian ; + ####################################### + ### HASKELL-LANGUAGE-SERVER SECTION ### + ####################################### + + haskell-language-server = (lib.pipe super.haskell-language-server [ + dontCheck + (disableCabalFlag "stan") # Sorry stan is totally unmaintained and terrible to get to run. It only works on ghc 8.8 or 8.10 anyways … + # Allow hls-call-hierarchy >= 1.2 which requires only a bound adjustment + (appendPatch (fetchpatch { + name = "hls-allow-hls-call-hierarchy-1.2.patch"; + url = "https://github.com/haskell/haskell-language-server/commit/05b248dfacc307c3397b334635cb38298aee9563.patch"; + includes = [ "haskell-language-server.cabal" ]; + sha256 = "1v0zi1lv92p6xq54yw9swzaf24dxsi9lpk10sngg3ka654ikm7j5"; + })) + ]).overrideScope (lself: lsuper: { + # For most ghc versions, we overrideScope Cabal in the configuration-ghc-???.nix, + # because some packages, like ormolu, need a newer Cabal version. + # ghc-paths is special because it depends on Cabal for building + # its Setup.hs, and therefor declares a Cabal dependency, but does + # not actually use it as a build dependency. + # That means ghc-paths can just use the ghc included Cabal version, + # without causing package-db incoherence and we should do that because + # otherwise we have different versions of ghc-paths + # around with have the same abi-hash, which can lead to confusions and conflicts. + ghc-paths = lsuper.ghc-paths.override { Cabal = null; }; + }); + + hls-hlint-plugin = super.hls-hlint-plugin.override { + # For "ghc-lib" flag see https://github.com/haskell/haskell-language-server/issues/3185#issuecomment-1250264515 + hlint = enableCabalFlag "ghc-lib" super.hlint; + apply-refact = self.apply-refact_0_11_0_0; + }; + + # For -f-auto see cabal.project in haskell-language-server. + ghc-lib-parser-ex = addBuildDepend self.ghc-lib-parser (disableCabalFlag "auto" super.ghc-lib-parser-ex); + + ########################################### + ### END HASKELL-LANGUAGE-SERVER SECTION ### + ########################################### + vector = overrideCabal (old: { # Too strict bounds on doctest which isn't used, but is part of the configuration jailbreak = true; @@ -1513,56 +1553,6 @@ self: super: { }) ] super.binary-strict; - haskell-language-server = (lib.pipe super.haskell-language-server [ - dontCheck - (disableCabalFlag "stan") # Sorry stan is totally unmaintained and terrible to get to run. It only works on ghc 8.8 or 8.10 anyways … - # Allow hls-call-hierarchy >= 1.2 which requires only a bound adjustment - (appendPatch (fetchpatch { - name = "hls-allow-hls-call-hierarchy-1.2.patch"; - url = "https://github.com/haskell/haskell-language-server/commit/05b248dfacc307c3397b334635cb38298aee9563.patch"; - includes = [ "haskell-language-server.cabal" ]; - sha256 = "1v0zi1lv92p6xq54yw9swzaf24dxsi9lpk10sngg3ka654ikm7j5"; - })) - ]).overrideScope (lself: lsuper: { - # For most ghc versions, we overrideScope Cabal in the configuration-ghc-???.nix, - # because some packages, like ormolu, need a newer Cabal version. - # ghc-paths is special because it depends on Cabal for building - # its Setup.hs, and therefor declares a Cabal dependency, but does - # not actually use it as a build dependency. - # That means ghc-paths can just use the ghc included Cabal version, - # without causing package-db incoherence and we should do that because - # otherwise we have different versions of ghc-paths - # around with have the same abi-hash, which can lead to confusions and conflicts. - ghc-paths = lsuper.ghc-paths.override { Cabal = null; }; - }); - - hls-hlint-plugin = super.hls-hlint-plugin.override { - # For "ghc-lib" flag see https://github.com/haskell/haskell-language-server/issues/3185#issuecomment-1250264515 - hlint = enableCabalFlag "ghc-lib" super.hlint; - apply-refact = self.apply-refact_0_11_0_0; - }; - - # For -f-auto see cabal.project in haskell-language-server. - ghc-lib-parser-ex = addBuildDepend self.ghc-lib-parser (disableCabalFlag "auto" super.ghc-lib-parser-ex); - - # 2021-05-08: Tests fail: https://github.com/haskell/haskell-language-server/issues/1809 - hls-eval-plugin = dontCheck super.hls-eval-plugin; - - # 2021-06-20: Tests fail: https://github.com/haskell/haskell-language-server/issues/1949 - hls-refine-imports-plugin = dontCheck super.hls-refine-imports-plugin; - - # 2021-11-20: https://github.com/haskell/haskell-language-server/pull/2373 - hls-explicit-imports-plugin = dontCheck super.hls-explicit-imports-plugin; - - # 2021-11-20: https://github.com/haskell/haskell-language-server/pull/2374 - hls-module-name-plugin = dontCheck super.hls-module-name-plugin; - - # 2022-09-19: https://github.com/haskell/haskell-language-server/issues/3200 - hls-refactor-plugin = dontCheck super.hls-refactor-plugin; - - # tests require network - ghcide = dontCheck super.ghcide; - # 2020-11-15: nettle tests are pre MonadFail change # https://github.com/stbuehler/haskell-nettle/issues/10 nettle = dontCheck super.nettle; @@ -2089,16 +2079,6 @@ self: super: { # 2021-08-18: streamly-posix was released with hspec 2.8.2, but it works with older versions too. streamly-posix = doJailbreak super.streamly-posix; - # 2021-09-14: Tests are flaky. - hls-splice-plugin = dontCheck super.hls-splice-plugin; - - # 2021-09-18: https://github.com/haskell/haskell-language-server/issues/2205 - hls-stylish-haskell-plugin = doJailbreak super.hls-stylish-haskell-plugin; - - # Necesssary .txt files are not included in sdist. - # https://github.com/haskell/haskell-language-server/pull/2887 - hls-change-type-signature-plugin = dontCheck super.hls-change-type-signature-plugin; - # 2022-12-30: Restrictive upper bound on optparse-applicative retrie = doJailbreak super.retrie; diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index b03137eb2cae..cd4865757f8f 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -49,6 +49,131 @@ self: super: builtins.intersectAttrs super { # Apply NixOS-specific patches. ghc-paths = appendPatch ./patches/ghc-paths-nix.patch super.ghc-paths; + ####################################### + ### HASKELL-LANGUAGE-SERVER SECTION ### + ####################################### + + haskell-language-server = overrideCabal (drv: { + # starting with 1.6.1.1 haskell-language-server wants to be linked dynamically + # by default. Unless we reflect this in the generic builder, GHC is going to + # produce some illegal references to /build/. + enableSharedExecutables = true; + # The shell script wrapper checks that the runtime ghc and its boot packages match the ghc hls was compiled with. + # This prevents linking issues when running TH splices. + postInstall = '' + mv "$out/bin/haskell-language-server" "$out/bin/.haskell-language-server-${self.ghc.version}-unwrapped" + BOOT_PKGS=`ghc-pkg-${self.ghc.version} --global list --simple-output` + ${pkgs.buildPackages.gnused}/bin/sed \ + -e "s!@@EXE_DIR@@!$out/bin!" \ + -e "s/@@EXE_NAME@@/.haskell-language-server-${self.ghc.version}-unwrapped/" \ + -e "s/@@GHC_VERSION@@/${self.ghc.version}/" \ + -e "s/@@BOOT_PKGS@@/$BOOT_PKGS/" \ + -e "s/@@ABI_HASHES@@/$(for dep in $BOOT_PKGS; do printf "%s:" "$dep" && ghc-pkg-${self.ghc.version} field $dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ + -e "s!Consider installing ghc.* via ghcup or build HLS from source.!Visit https://haskell4nix.readthedocs.io/nixpkgs-users-guide.html#how-to-install-haskell-language-server to learn how to correctly install a matching hls for your ghc with nix.!" \ + bindist/wrapper.in > "$out/bin/haskell-language-server" + ln -s "$out/bin/haskell-language-server" "$out/bin/haskell-language-server-${self.ghc.version}" + chmod +x "$out/bin/haskell-language-server" + ''; + testToolDepends = [ self.cabal-install pkgs.git ]; + testTarget = "func-test"; # wrapper test accesses internet + preCheck = '' + export PATH=$PATH:$PWD/dist/build/haskell-language-server:$PWD/dist/build/haskell-language-server-wrapper + export HOME=$TMPDIR + ''; + }) super.haskell-language-server; + + # ghcide-bench tests need network + ghcide-bench = dontCheck super.ghcide-bench; + + # 2023-04-01: TODO: Either reenable at least some tests or remove the preCheck override + ghcide = overrideCabal (drv: { + # tests depend on executable + preCheck = ''export PATH="$PWD/dist/build/ghcide:$PATH"''; + # tests disabled because they require network + doCheck = false; + }) super.ghcide; + + hiedb = overrideCabal (drv: { + preCheck = '' + export PATH=$PWD/dist/build/hiedb:$PATH + ''; + }) super.hiedb; + + # Tests access homeless-shelter. + hie-bios = dontCheck super.hie-bios; + + # PLUGINS WITH ENABLED TESTS + # haskell-language-server plugins all use the same test harness so we give them what they want in this loop. + # Every hls plugin should either be in the test disabled list below, or up here in the list fixing it’s tests. + inherit (pkgs.lib.mapAttrs + (_: overrideCabal (drv: { + testToolDepends = (drv.testToolDepends or [ ]) ++ [ pkgs.git ]; + preCheck = '' + export HOME=$TMPDIR/home + '' + (drv.preCheck or ""); + })) + super) + hls-brittany-plugin + hls-floskell-plugin + hls-fourmolu-plugin + hls-cabal-plugin + ; + + # PLUGINS WITH DISABLED TESTS + # 2023-04-01: TODO: We should reenable all these tests to figure if they are still broken. + inherit (pkgs.lib.mapAttrs (_: dontCheck) super) + # Tests have file permissions expections that don’t work with the nix store. + hls-gadt-plugin + + # https://github.com/haskell/haskell-language-server/pull/3431 + hls-cabal-fmt-plugin + hls-code-range-plugin + hls-explicit-record-fields-plugin + + # Flaky tests + hls-explicit-fixity-plugin + hls-hlint-plugin + hls-pragmas-plugin + hls-class-plugin + hls-rename-plugin + hls-alternate-number-format-plugin + hls-qualify-imported-names-plugin + hls-haddock-comments-plugin + hls-tactics-plugin + hls-call-hierarchy-plugin + hls-selection-range-plugin + hls-ormolu-plugin + + # 2021-05-08: Tests fail: https://github.com/haskell/haskell-language-server/issues/1809 + hls-eval-plugin + + # 2021-06-20: Tests fail: https://github.com/haskell/haskell-language-server/issues/1949 + hls-refine-imports-plugin + + # 2021-11-20: https://github.com/haskell/haskell-language-server/pull/2373 + hls-explicit-imports-plugin + + # 2021-11-20: https://github.com/haskell/haskell-language-server/pull/2374 + hls-module-name-plugin + + # 2022-09-19: https://github.com/haskell/haskell-language-server/issues/3200 + hls-refactor-plugin + + # 2021-09-14: Tests are flaky. + hls-splice-plugin + + # 2021-09-18: https://github.com/haskell/haskell-language-server/issues/2205 + hls-stylish-haskell-plugin + + # Necesssary .txt files are not included in sdist. + # https://github.com/haskell/haskell-language-server/pull/2887 + hls-change-type-signature-plugin + ; + + ########################################### + ### END HASKELL-LANGUAGE-SERVER SECTION ### + ########################################### + # fix errors caused by hardening flags epanet-haskell = disableHardening ["format"] super.epanet-haskell; @@ -354,11 +479,6 @@ self: super: builtins.intersectAttrs super { # Looks like Avahi provides the missing library dnssd = super.dnssd.override { dns_sd = pkgs.avahi.override { withLibdnssdCompat = true; }; }; - # tests depend on executable - ghcide = overrideCabal (drv: { - preCheck = ''export PATH="$PWD/dist/build/ghcide:$PATH"''; - }) super.ghcide; - # Tests execute goldplate goldplate = overrideCabal (drv: { preCheck = drv.preCheck or "" + '' @@ -685,9 +805,6 @@ self: super: builtins.intersectAttrs super { ''; }) (addBuildTool pkgs.buildPackages.makeWrapper super.cut-the-crap); - # Tests access homeless-shelter. - hie-bios = dontCheck super.hie-bios; - # Compiling the readme throws errors and has no purpose in nixpkgs aeson-gadt-th = disableCabalFlag "build-readme" (doJailbreak super.aeson-gadt-th); @@ -712,34 +829,6 @@ self: super: builtins.intersectAttrs super { retrie_1_2_0_0 = addTestToolDepends [pkgs.git pkgs.mercurial] super.retrie_1_2_0_0; retrie_1_2_1_1 = addTestToolDepends [pkgs.git pkgs.mercurial] super.retrie_1_2_1_1; - haskell-language-server = overrideCabal (drv: { - # starting with 1.6.1.1 haskell-language-server wants to be linked dynamically - # by default. Unless we reflect this in the generic builder, GHC is going to - # produce some illegal references to /build/. - enableSharedExecutables = true; - # The shell script wrapper checks that the runtime ghc and its boot packages match the ghc hls was compiled with. - # This prevents linking issues when running TH splices. - postInstall = '' - mv "$out/bin/haskell-language-server" "$out/bin/.haskell-language-server-${self.ghc.version}-unwrapped" - BOOT_PKGS=`ghc-pkg-${self.ghc.version} --global list --simple-output` - ${pkgs.buildPackages.gnused}/bin/sed \ - -e "s!@@EXE_DIR@@!$out/bin!" \ - -e "s/@@EXE_NAME@@/.haskell-language-server-${self.ghc.version}-unwrapped/" \ - -e "s/@@GHC_VERSION@@/${self.ghc.version}/" \ - -e "s/@@BOOT_PKGS@@/$BOOT_PKGS/" \ - -e "s/@@ABI_HASHES@@/$(for dep in $BOOT_PKGS; do printf "%s:" "$dep" && ghc-pkg-${self.ghc.version} field $dep abi --simple-output ; done | tr '\n' ' ' | xargs)/" \ - -e "s!Consider installing ghc.* via ghcup or build HLS from source.!Visit https://haskell4nix.readthedocs.io/nixpkgs-users-guide.html#how-to-install-haskell-language-server to learn how to correctly install a matching hls for your ghc with nix.!" \ - bindist/wrapper.in > "$out/bin/haskell-language-server" - ln -s "$out/bin/haskell-language-server" "$out/bin/haskell-language-server-${self.ghc.version}" - chmod +x "$out/bin/haskell-language-server" - ''; - testToolDepends = [ self.cabal-install pkgs.git ]; - testTarget = "func-test"; # wrapper test accesses internet - preCheck = '' - export PATH=$PATH:$PWD/dist/build/haskell-language-server:$PWD/dist/build/haskell-language-server-wrapper - export HOME=$TMPDIR - ''; - }) super.haskell-language-server; # there are three very heavy test suites that need external repos, one requires network access hevm = dontCheck super.hevm; @@ -801,12 +890,6 @@ self: super: builtins.intersectAttrs super { '' + drv.postInstall or ""; }) super.hlint; - hiedb = overrideCabal (drv: { - preCheck = '' - export PATH=$PWD/dist/build/hiedb:$PATH - ''; - }) super.hiedb; - taglib = overrideCabal (drv: { librarySystemDepends = [ pkgs.zlib @@ -1101,47 +1184,4 @@ self: super: builtins.intersectAttrs super { keid-render-basic = addBuildTool pkgs.glslang super.keid-render-basic; - # ghcide-bench tests need network - ghcide-bench = dontCheck super.ghcide-bench; - -# haskell-language-server plugins all use the same test harness so we give them what we want in this loop. -} // pkgs.lib.mapAttrs - (_: overrideCabal (drv: { - testToolDepends = (drv.testToolDepends or [ ]) ++ [ pkgs.git ]; - preCheck = '' - export HOME=$TMPDIR/home - '' + (drv.preCheck or ""); - })) -{ - inherit (super) - hls-brittany-plugin - hls-eval-plugin - hls-floskell-plugin - hls-fourmolu-plugin - hls-module-name-plugin - hls-splice-plugin - hls-refactor-plugin - hls-cabal-plugin; - # Tests have file permissions expections that don’t work with the nix store. - hls-stylish-haskell-plugin = dontCheck super.hls-stylish-haskell-plugin; - hls-gadt-plugin = dontCheck super.hls-gadt-plugin; - - # https://github.com/haskell/haskell-language-server/pull/3431 - hls-cabal-fmt-plugin = dontCheck super.hls-cabal-fmt-plugin; - hls-code-range-plugin = dontCheck super.hls-code-range-plugin; - hls-explicit-record-fields-plugin = dontCheck super.hls-explicit-record-fields-plugin; - - # Flaky tests - hls-explicit-fixity-plugin = dontCheck super.hls-explicit-fixity-plugin; - hls-hlint-plugin = dontCheck super.hls-hlint-plugin; - hls-pragmas-plugin = dontCheck super.hls-pragmas-plugin; - hls-class-plugin = dontCheck super.hls-class-plugin; - hls-rename-plugin = dontCheck super.hls-rename-plugin; - hls-alternate-number-format-plugin = dontCheck super.hls-alternate-number-format-plugin; - hls-qualify-imported-names-plugin = dontCheck super.hls-qualify-imported-names-plugin; - hls-haddock-comments-plugin = dontCheck super.hls-haddock-comments-plugin; - hls-tactics-plugin = dontCheck super.hls-tactics-plugin; - hls-call-hierarchy-plugin = dontCheck super.hls-call-hierarchy-plugin; - hls-selection-range-plugin = dontCheck super.hls-selection-range-plugin; - hls-ormolu-plugin = dontCheck super.hls-ormolu-plugin; }