2019-02-04 02:02:18 +01:00
|
|
|
{ lib, stdenv, fetchurl, vscode-utils, extractNuGet
|
|
|
|
, icu, curl, openssl, lttng-ust, autoPatchelfHook
|
2020-05-28 16:49:44 +02:00
|
|
|
, python3, musl
|
2020-03-23 02:53:39 +01:00
|
|
|
, pythonUseFixed ? false # When `true`, the python default setting will be fixed to specified.
|
|
|
|
# Use version from `PATH` for default setting otherwise.
|
|
|
|
# Defaults to `false` as we expect it to be project specific most of the time.
|
|
|
|
, ctagsUseFixed ? true, ctags # When `true`, the ctags default setting will be fixed to specified.
|
|
|
|
# Use version from `PATH` for default setting otherwise.
|
|
|
|
# Defaults to `true` as usually not defined on a per projet basis.
|
2017-10-19 03:32:15 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert ctagsUseFixed -> null != ctags;
|
|
|
|
|
|
|
|
let
|
2020-03-23 02:53:39 +01:00
|
|
|
pythonDefaultsTo = if pythonUseFixed then "${python3}/bin/python" else "python";
|
2017-10-19 03:32:15 +02:00
|
|
|
ctagsDefaultsTo = if ctagsUseFixed then "${ctags}/bin/ctags" else "ctags";
|
|
|
|
|
2019-02-04 02:02:18 +01:00
|
|
|
# The arch tag comes from 'PlatformName' defined here:
|
|
|
|
# https://github.com/Microsoft/vscode-python/blob/master/src/client/activation/types.ts
|
|
|
|
arch =
|
|
|
|
if stdenv.isLinux && stdenv.isx86_64 then "linux-x64"
|
|
|
|
else if stdenv.isDarwin then "osx-x64"
|
|
|
|
else throw "Only x86_64 Linux and Darwin are supported.";
|
|
|
|
|
|
|
|
languageServerSha256 = {
|
2020-03-23 02:53:39 +01:00
|
|
|
linux-x64 = "1pmj5pb4xylx4gdx4zgmisn0si59qx51n2m1bh7clv29q6biw05n";
|
|
|
|
osx-x64 = "0ishiy1z9dghj4ryh95vy8rw0v7q4birdga2zdb4a8am31wmp94b";
|
2019-08-13 23:52:01 +02:00
|
|
|
}.${arch};
|
2019-02-04 02:02:18 +01:00
|
|
|
|
|
|
|
# version is languageServerVersion in the package.json
|
|
|
|
languageServer = extractNuGet rec {
|
|
|
|
name = "Python-Language-Server";
|
2020-03-23 02:53:39 +01:00
|
|
|
version = "0.5.30";
|
2019-02-04 02:02:18 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://pvsc.azureedge.net/python-language-server-stable/${name}-${arch}.${version}.nupkg";
|
|
|
|
sha256 = languageServerSha256;
|
|
|
|
};
|
|
|
|
};
|
2020-05-28 16:49:44 +02:00
|
|
|
in vscode-utils.buildVscodeMarketplaceExtension rec {
|
2017-10-19 03:32:15 +02:00
|
|
|
mktplcRef = {
|
|
|
|
name = "python";
|
|
|
|
publisher = "ms-python";
|
2021-05-14 00:19:51 +02:00
|
|
|
version = "2021.5.829140558";
|
2020-05-28 16:49:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
vsix = fetchurl {
|
|
|
|
name = "${mktplcRef.publisher}-${mktplcRef.name}.zip";
|
|
|
|
url = "https://github.com/microsoft/vscode-python/releases/download/${mktplcRef.version}/ms-python-release.vsix";
|
2021-05-14 00:19:51 +02:00
|
|
|
sha256 = "0y2HN4WGYUUXBfqp8Xb4oaA0hbLZmE3kDUXMBAOjvPQ=";
|
2017-10-19 03:32:15 +02:00
|
|
|
};
|
|
|
|
|
2019-02-04 02:02:18 +01:00
|
|
|
buildInputs = [
|
|
|
|
icu
|
|
|
|
curl
|
|
|
|
openssl
|
|
|
|
lttng-ust
|
2020-05-28 16:49:44 +02:00
|
|
|
musl
|
2019-02-04 02:02:18 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
autoPatchelfHook
|
2020-03-23 02:53:39 +01:00
|
|
|
python3.pkgs.wrapPython
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonPath = with python3.pkgs; [
|
|
|
|
setuptools
|
2019-02-04 02:02:18 +01:00
|
|
|
];
|
|
|
|
|
2017-10-19 03:32:15 +02:00
|
|
|
postPatch = ''
|
|
|
|
# Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`.
|
|
|
|
substituteInPlace "./package.json" \
|
|
|
|
--replace "\"default\": \"python\"" "\"default\": \"${pythonDefaultsTo}\""
|
|
|
|
|
|
|
|
# Patch `packages.json` so that nix's *ctags* is used as default value for `python.workspaceSymbols.ctagsPath`.
|
|
|
|
substituteInPlace "./package.json" \
|
|
|
|
--replace "\"default\": \"ctags\"" "\"default\": \"${ctagsDefaultsTo}\""
|
|
|
|
'';
|
|
|
|
|
2019-02-04 02:02:18 +01:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p "$out/$installPrefix/languageServer.${languageServer.version}"
|
|
|
|
cp -R --no-preserve=ownership ${languageServer}/* "$out/$installPrefix/languageServer.${languageServer.version}"
|
|
|
|
chmod -R +wx "$out/$installPrefix/languageServer.${languageServer.version}"
|
2020-03-23 02:53:39 +01:00
|
|
|
|
|
|
|
patchPythonScript "$out/$installPrefix/pythonFiles/lib/python/isort/main.py"
|
2019-02-04 02:02:18 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.mit;
|
2020-05-28 16:49:44 +02:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2019-02-04 02:02:18 +01:00
|
|
|
maintainers = [ maintainers.jraygauthier ];
|
|
|
|
};
|
2018-04-19 17:41:12 +02:00
|
|
|
}
|