summaryrefslogtreecommitdiff
path: root/pkgs/applications/editors/vscode/extensions/ms-python.python/default.nix
blob: 329a96835187bcc7617c447823e4341b86eae5f7 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
  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,
  # For updateScript
  vscode-extensions-update-script,
}:

vscode-utils.buildVscodeMarketplaceExtension rec {
  mktplcRef = {
    name = "python";
    publisher = "ms-python";
    version = "2025.4.0";
    hash = "sha256-/yQbmZTnkks1gvMItEApRzfk8Lczjq+JC5rnyJxr6fo=";
  };

  buildInputs = [ icu ];

  nativeBuildInputs = [ python3.pkgs.wrapPython ];

  propagatedBuildInputs = with python3.pkgs; [
    debugpy
    jedi-language-server
  ];

  postPatch =
    ''
      # remove bundled python deps and use libs from nixpkgs
      rm -r python_files/lib
      mkdir -p python_files/lib/python/
      ln -s ${python3.pkgs.debugpy}/lib/*/site-packages/debugpy python_files/lib/python/
      buildPythonPath "$propagatedBuildInputs"
      for i in python_files/*.py; do
        patchPythonScript "$i"
      done
    ''
    + lib.optionalString pythonUseFixed ''
      # Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`.
      substituteInPlace "./package.json" \
        --replace-fail "\"default\":\"python\"" "\"default\":\"${python3.interpreter}\""
    '';

  passthru.updateScript = vscode-extensions-update-script { };

  meta = {
    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";
    license = lib.licenses.mit;
    platforms = [
      "aarch64-linux"
      "x86_64-linux"
      "aarch64-darwin"
      "x86_64-darwin"
    ];
    maintainers = [
      lib.maintainers.jraygauthier
      lib.maintainers.jfchevrette
    ];
  };
}