at master 86 lines 2.5 kB view raw
1{ 2 stdenv, 3 lib, 4 vscode-utils, 5 icu, 6 python3, 7 # When `true`, the python default setting will be fixed to specified. 8 # Use version from `PATH` for default setting otherwise. 9 # Defaults to `false` as we expect it to be project specific most of the time. 10 pythonUseFixed ? false, 11 # For updateScript 12 vscode-extension-update-script, 13}: 14 15let 16 supported = { 17 x86_64-linux = { 18 hash = "sha256-AlqZTioxiL0XPRMpWMWw8fIWoDAmU1ybCaDhlaXv6lc="; 19 arch = "linux-x64"; 20 }; 21 x86_64-darwin = { 22 hash = "sha256-IWj79vUJJXt88kDiCIHVY95aKsHB84vH3iv6GgLOFQo="; 23 arch = "darwin-x64"; 24 }; 25 aarch64-linux = { 26 hash = "sha256-kTSHvqS50UZ/yTMqJITyFIUZgHn1dMSwX1R3oxmTnYk="; 27 arch = "linux-arm64"; 28 }; 29 aarch64-darwin = { 30 hash = "sha256-LWA8LqCQrmd83icDYCmUgytPJbCV3ecNobSpWV2R3MA="; 31 arch = "darwin-arm64"; 32 }; 33 }; 34 35 base = 36 supported.${stdenv.hostPlatform.system} 37 or (throw "unsupported platform ${stdenv.hostPlatform.system}"); 38 39in 40vscode-utils.buildVscodeMarketplaceExtension rec { 41 mktplcRef = base // { 42 name = "python"; 43 publisher = "ms-python"; 44 version = "2025.12.0"; 45 }; 46 47 buildInputs = [ icu ]; 48 49 nativeBuildInputs = [ python3.pkgs.wrapPython ]; 50 51 propagatedBuildInputs = with python3.pkgs; [ 52 debugpy 53 jedi-language-server 54 ]; 55 56 postPatch = '' 57 # remove bundled python deps and use libs from nixpkgs 58 rm -r python_files/lib 59 mkdir -p python_files/lib/python/ 60 ln -s ${python3.pkgs.debugpy}/lib/*/site-packages/debugpy python_files/lib/python/ 61 buildPythonPath "$propagatedBuildInputs" 62 for i in python_files/*.py; do 63 patchPythonScript "$i" 64 done 65 '' 66 + lib.optionalString pythonUseFixed '' 67 # Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`. 68 substituteInPlace "./package.json" \ 69 --replace-fail "\"default\":\"python\"" "\"default\":\"${python3.interpreter}\"" 70 ''; 71 72 passthru.updateScript = vscode-extension-update-script { }; 73 74 meta = { 75 description = "Visual Studio Code extension with rich support for the Python language"; 76 downloadPage = "https://marketplace.visualstudio.com/items?itemName=ms-python.python"; 77 homepage = "https://github.com/Microsoft/vscode-python"; 78 changelog = "https://github.com/microsoft/vscode-python/releases"; 79 license = lib.licenses.mit; 80 platforms = builtins.attrNames supported; 81 maintainers = [ 82 lib.maintainers.jraygauthier 83 lib.maintainers.jfchevrette 84 ]; 85 }; 86}