fdb820602b
To reproduce:
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: nix-x86_64-darwin
language: nix
rule:
any:
- pattern: "\"x86_64-darwin\""
kind: list_expression > string_expression
- pattern:
context: "{ \"x86_64-darwin\" = $EXPR; }"
selector: binding
- pattern:
context: "{ x86_64-darwin = $EXPR; }"
selector: binding
fix:
template: ""
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-first-x86_64-darwin
language: json
rule:
kind: object > pair:nth-child(1)
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandEnd: { regex: "," }
' pkgs
$ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
-- scan --update-all --inline-rules '
id: json-x86_64-darwin
language: json
rule:
kind: object > pair
has:
pattern: "\"x86_64-darwin\""
field: key
fix:
template: ""
expandStart: { regex: "," }
' pkgs
$ git restore pkgs/by-name/om/omnix/package.nix
$ git diff --name-only -z \
| nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
-c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
$ treefmt
82 lines
2.3 KiB
Nix
82 lines
2.3 KiB
Nix
{
|
|
stdenv,
|
|
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-extension-update-script,
|
|
}:
|
|
|
|
let
|
|
supported = {
|
|
x86_64-linux = {
|
|
hash = "sha256-HQfmDV6rJX6l1pGybe8//2QrTSwE+rlEJOi4/iW69lY=";
|
|
arch = "linux-x64";
|
|
};
|
|
aarch64-linux = {
|
|
hash = "sha256-v7fatW/LMJ8CeSRrE/5b7dLqOrhNhwzUySUxtAMuBUE=";
|
|
arch = "linux-arm64";
|
|
};
|
|
aarch64-darwin = {
|
|
hash = "sha256-XntiQmvagiSWcfVIp13CDq2RTZ4NhKOzf4QmecZjMIs=";
|
|
arch = "darwin-arm64";
|
|
};
|
|
};
|
|
|
|
base =
|
|
supported.${stdenv.hostPlatform.system}
|
|
or (throw "unsupported platform ${stdenv.hostPlatform.system}");
|
|
|
|
in
|
|
vscode-utils.buildVscodeMarketplaceExtension {
|
|
mktplcRef = base // {
|
|
name = "python";
|
|
publisher = "ms-python";
|
|
version = "2026.4.0";
|
|
};
|
|
|
|
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-extension-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 = builtins.attrNames supported;
|
|
maintainers = [
|
|
lib.maintainers.jraygauthier
|
|
];
|
|
};
|
|
}
|