2022-02-10 20:34:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-12-28 21:21:41 +00:00
|
|
|
, supportedGhcVersions ? [ "92" ]
|
2022-09-22 12:36:57 +00:00
|
|
|
, dynamic ? true
|
2022-02-10 20:34:41 +00:00
|
|
|
, haskellPackages
|
|
|
|
, haskell
|
|
|
|
}:
|
2020-10-16 20:44:37 +00:00
|
|
|
#
|
|
|
|
# The recommended way to override this package is
|
|
|
|
#
|
2022-09-22 12:36:57 +00:00
|
|
|
# pkgs.haskell-language-server.override { supportedGhcVersions = [ "90" "92"]; }
|
2020-10-16 20:44:37 +00:00
|
|
|
#
|
|
|
|
# for example. Read more about this in the haskell-language-server section of the nixpkgs manual.
|
|
|
|
#
|
|
|
|
let
|
2022-02-20 05:27:41 +00:00
|
|
|
inherit (lib) concatStringsSep concatMapStringsSep take splitString pipe optionals;
|
|
|
|
inherit (haskell.lib.compose) justStaticExecutables overrideCabal enableCabalFlag disableCabalFlag;
|
2020-10-16 20:44:37 +00:00
|
|
|
getPackages = version: haskell.packages."ghc${version}";
|
|
|
|
tunedHls = hsPkgs:
|
2022-02-20 05:27:41 +00:00
|
|
|
lib.pipe hsPkgs.haskell-language-server ([
|
|
|
|
(haskell.lib.compose.overrideCabal (old: {
|
|
|
|
enableSharedExecutables = dynamic;
|
|
|
|
${if !dynamic then "postInstall" else null} = ''
|
|
|
|
${old.postInstall or ""}
|
|
|
|
|
|
|
|
remove-references-to -t ${hsPkgs.ghc} $out/bin/haskell-language-server
|
|
|
|
'';
|
|
|
|
}))
|
|
|
|
((if dynamic then enableCabalFlag else disableCabalFlag) "dynamic")
|
|
|
|
] ++ optionals (!dynamic) [
|
|
|
|
justStaticExecutables
|
|
|
|
]);
|
2020-10-16 20:44:37 +00:00
|
|
|
targets = version:
|
|
|
|
let packages = getPackages version;
|
|
|
|
in [
|
|
|
|
"haskell-language-server-${packages.ghc.version}"
|
|
|
|
];
|
|
|
|
makeSymlinks = version:
|
|
|
|
concatMapStringsSep "\n" (x:
|
|
|
|
"ln -s ${
|
|
|
|
tunedHls (getPackages version)
|
|
|
|
}/bin/haskell-language-server $out/bin/${x}") (targets version);
|
2022-12-28 21:21:41 +00:00
|
|
|
in assert supportedGhcVersions != []; stdenv.mkDerivation {
|
2020-10-16 20:44:37 +00:00
|
|
|
pname = "haskell-language-server";
|
|
|
|
version = haskellPackages.haskell-language-server.version;
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/bin
|
2022-12-28 21:21:41 +00:00
|
|
|
ln -s ${tunedHls (getPackages (builtins.head supportedGhcVersions))}/bin/haskell-language-server-wrapper $out/bin/haskell-language-server-wrapper
|
2020-10-16 20:44:37 +00:00
|
|
|
${concatMapStringsSep "\n" makeSymlinks supportedGhcVersions}
|
|
|
|
'';
|
|
|
|
meta = haskellPackages.haskell-language-server.meta // {
|
|
|
|
maintainers = [ lib.maintainers.maralorn ];
|
|
|
|
longDescription = ''
|
2022-12-28 21:21:41 +00:00
|
|
|
This package provides the executables ${
|
2020-10-16 20:44:37 +00:00
|
|
|
concatMapStringsSep ", " (x: concatStringsSep ", " (targets x))
|
|
|
|
supportedGhcVersions
|
2022-12-28 21:21:41 +00:00
|
|
|
} and haskell-language-server-wrapper.
|
2022-09-22 12:36:57 +00:00
|
|
|
You can choose for which ghc versions to install hls with pkgs.haskell-language-server.override { supportedGhcVersions = [ "90" "92" ]; }.
|
2020-10-16 20:44:37 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|