2022-07-08 13:51:22 +08:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
vscode-utils,
|
|
|
|
icu,
|
|
|
|
python3,
|
|
|
|
# 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.
|
|
|
|
pythonUseFixed ? false,
|
2022-09-29 10:28:05 +08:00
|
|
|
# For updateScript
|
|
|
|
writeScript,
|
|
|
|
bash,
|
|
|
|
curl,
|
|
|
|
coreutils,
|
|
|
|
gnused,
|
2023-01-30 17:38:28 +08:00
|
|
|
jq,
|
2022-09-29 10:28:05 +08:00
|
|
|
nix,
|
2017-10-18 21:32:15 -04:00
|
|
|
}:
|
|
|
|
|
2022-09-29 10:28:05 +08:00
|
|
|
vscode-utils.buildVscodeMarketplaceExtension rec {
|
2017-10-18 21:32:15 -04:00
|
|
|
mktplcRef = {
|
|
|
|
name = "python";
|
|
|
|
publisher = "ms-python";
|
2025-03-24 17:11:42 +00:00
|
|
|
version = "2024.15.2024091301";
|
|
|
|
hash = "sha256-MB8Vq2rjO37yW3Zh+f8ek/yz0qT+ZYHn/JnF5ZA6CXQ=";
|
2017-10-18 21:32:15 -04:00
|
|
|
};
|
|
|
|
|
2022-07-08 13:51:22 +08:00
|
|
|
buildInputs = [ icu ];
|
2019-02-03 20:02:18 -05:00
|
|
|
|
2022-07-08 13:51:22 +08:00
|
|
|
nativeBuildInputs = [ python3.pkgs.wrapPython ];
|
2020-03-22 21:53:39 -04:00
|
|
|
|
2022-07-08 13:51:22 +08:00
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
|
|
debugpy
|
|
|
|
jedi-language-server
|
2019-02-03 20:02:18 -05:00
|
|
|
];
|
|
|
|
|
2017-10-18 21:32:15 -04:00
|
|
|
postPatch =
|
|
|
|
''
|
2022-07-08 13:51:22 +08:00
|
|
|
# remove bundled python deps and use libs from nixpkgs
|
2024-05-13 20:11:56 +02:00
|
|
|
rm -r python_files/lib
|
|
|
|
mkdir -p python_files/lib/python/
|
|
|
|
ln -s ${python3.pkgs.debugpy}/lib/*/site-packages/debugpy python_files/lib/python/
|
2022-07-08 13:51:22 +08:00
|
|
|
buildPythonPath "$propagatedBuildInputs"
|
2024-05-13 20:11:56 +02:00
|
|
|
for i in python_files/*.py; do
|
2022-07-08 13:51:22 +08:00
|
|
|
patchPythonScript "$i"
|
|
|
|
done
|
|
|
|
''
|
|
|
|
+ lib.optionalString pythonUseFixed ''
|
2017-10-18 21:32:15 -04:00
|
|
|
# Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`.
|
|
|
|
substituteInPlace "./package.json" \
|
2024-12-06 17:08:30 +11:00
|
|
|
--replace-fail "\"default\":\"python\"" "\"default\":\"${python3.interpreter}\""
|
2019-02-03 20:02:18 -05:00
|
|
|
'';
|
|
|
|
|
2022-09-29 10:28:05 +08:00
|
|
|
passthru.updateScript = writeScript "update" ''
|
|
|
|
#! ${bash}/bin/bash
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
export PATH=${
|
|
|
|
lib.makeBinPath [
|
|
|
|
curl
|
|
|
|
coreutils
|
|
|
|
gnused
|
2023-01-30 17:38:28 +08:00
|
|
|
jq
|
2022-09-29 10:28:05 +08:00
|
|
|
nix
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
api=$(curl -s 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' \
|
|
|
|
-H 'accept: application/json;api-version=3.0-preview.1' \
|
|
|
|
-H 'content-type: application/json' \
|
2023-01-30 17:38:28 +08:00
|
|
|
--data-raw '{"filters":[{"criteria":[{"filterType":7,"value":"${mktplcRef.publisher}.${mktplcRef.name}"}]}],"flags":16}')
|
|
|
|
# Find the latest version compatible with stable vscode version
|
|
|
|
version=$(echo $api | jq -r '.results[0].extensions[0].versions | map(select(has("properties"))) | map(select(.properties | map(select(.key == "Microsoft.VisualStudio.Code.Engine")) | .[0].value | test("\\^[0-9.]+$"))) | .[0].version')
|
2022-09-29 10:28:05 +08:00
|
|
|
|
|
|
|
if [[ $version != ${mktplcRef.version} ]]; then
|
|
|
|
tmp=$(mktemp)
|
|
|
|
curl -sLo $tmp $(echo ${(import ../mktplcExtRefToFetchArgs.nix mktplcRef).url} | sed "s|${mktplcRef.version}|$version|")
|
|
|
|
hash=$(nix hash file --type sha256 --base32 --sri $tmp)
|
2024-04-09 12:06:44 -04:00
|
|
|
sed -i -e "s|${mktplcRef.hash}|$hash|" -e "s|${mktplcRef.version}|$version|" pkgs/applications/editors/vscode/extensions/ms-python.python/default.nix
|
2022-09-29 10:28:05 +08:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2023-03-18 16:40:30 -03:00
|
|
|
meta = {
|
2022-09-29 10:28:05 +08:00
|
|
|
description = "Visual Studio Code extension with rich support for the Python language";
|
|
|
|
downloadPage = "https://marketplace.visualstudio.com/items?itemName=ms-python.python";
|
|
|
|
homepage = "https://github.com/Microsoft/vscode-python";
|
|
|
|
changelog = "https://github.com/microsoft/vscode-python/releases";
|
2023-03-18 16:40:30 -03:00
|
|
|
license = lib.licenses.mit;
|
2022-01-12 13:33:06 -05:00
|
|
|
platforms = [
|
2024-11-24 19:10:35 +01:00
|
|
|
"aarch64-linux"
|
2022-01-12 13:33:06 -05:00
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-darwin"
|
|
|
|
"x86_64-darwin"
|
2023-03-18 16:40:30 -03:00
|
|
|
];
|
|
|
|
maintainers = [
|
|
|
|
lib.maintainers.jraygauthier
|
|
|
|
lib.maintainers.jfchevrette
|
2024-05-01 05:53:48 -04:00
|
|
|
];
|
2019-02-03 20:02:18 -05:00
|
|
|
};
|
2018-04-19 10:41:12 -05:00
|
|
|
}
|