diff --git a/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix b/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix index c1f5ad3615e1..55ed38a10130 100644 --- a/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix +++ b/pkgs/applications/editors/vscode/extensions/ms-vscode.cpptools/default.nix @@ -38,24 +38,27 @@ let gdbDefaultsTo = if gdbUseFixed then "${gdb}/bin/gdb" else "gdb"; + isx86Linux = stdenv.hostPlatform.system == "x86_64-linux"; supported = { x86_64-linux = { - hash = "sha256-arTBt3UWA5zoo0dL044Sx/NT1LUS76XfGIS96NOMvJk="; + hash = "sha256-jibImnpRtshbHu21JeS4VxL1jETm3Ein8S/M73UXc2w="; arch = "linux-x64"; }; aarch64-linux = { - hash = "sha256-oVuDxx117bVd/jDqn9KivTwR5T2X5UZMHk/nZ/e/IOg="; + hash = "sha256-7UagRO7qHyT1JIvvTSx9+USYrnDRXJ2wnXPLaBHRc3k="; arch = "linux-arm64"; }; }; - base = supported.${stdenv.system} or (throw "unsupported platform ${stdenv.system}"); + base = + supported.${stdenv.hostPlatform.system} + or (throw "unsupported platform ${stdenv.hostPlatform.system}"); in vscode-utils.buildVscodeMarketplaceExtension { mktplcRef = base // { name = "cpptools"; publisher = "ms-vscode"; - version = "1.20.5"; + version = "1.21.4"; }; nativeBuildInputs = [ @@ -71,35 +74,40 @@ vscode-utils.buildVscodeMarketplaceExtension { stdenv.cc.cc.lib ]; - dontAutoPatchelf = true; + dontAutoPatchelf = isx86Linux; - postPatch = '' - mv ./package.json ./package_orig.json - - # 1. Add activation events so that the extension is functional. This listing is empty when unpacking the extension but is filled at runtime. - # 2. Patch `package.json` so that nix's *gdb* is used as default value for `miDebuggerPath`. - cat ./package_orig.json | \ - jq --slurpfile actEvts ${./package-activation-events.json} '(.activationEvents) = $actEvts[0]' | \ - jq '(.contributes.debuggers[].configurationAttributes | .attach , .launch | .properties.miDebuggerPath | select(. != null) | select(.default == "/usr/bin/gdb") | .default) = "${gdbDefaultsTo}"' > \ - ./package.json - - # Prevent download/install of extensions - touch "./install.lock" - - # Clang-format from nix package. - rm -rf ./LLVM - mkdir "./LLVM/" - find "${clang-tools}" -mindepth 1 -maxdepth 1 | xargs ln -s -t "./LLVM" - - # Patching binaries - chmod +x bin/cpptools bin/cpptools-srv bin/cpptools-wordexp bin/libc.so debugAdapters/bin/OpenDebugAD7 - patchelf --replace-needed liblttng-ust.so.0 liblttng-ust.so.1 ./debugAdapters/bin/libcoreclrtraceptprovider.so - ''; - - postFixup = + postPatch = '' - autoPatchelf $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters + mv ./package.json ./package_orig.json + # 1. Add activation events so that the extension is functional. This listing is empty when unpacking the extension but is filled at runtime. + # 2. Patch `package.json` so that nix's *gdb* is used as default value for `miDebuggerPath`. + cat ./package_orig.json | \ + jq --slurpfile actEvts ${./package-activation-events.json} '(.activationEvents) = $actEvts[0]' | \ + jq '(.contributes.debuggers[].configurationAttributes | .attach , .launch | .properties.miDebuggerPath | select(. != null) | select(.default == "/usr/bin/gdb") | .default) = "${gdbDefaultsTo}"' > \ + ./package.json + + # Prevent download/install of extensions + touch "./install.lock" + + # Clang-format from nix package. + rm -rf ./LLVM + mkdir "./LLVM/" + find "${clang-tools}" -mindepth 1 -maxdepth 1 | xargs ln -s -t "./LLVM" + + # Patching binaries + chmod +x bin/cpptools bin/cpptools-srv bin/cpptools-wordexp debugAdapters/bin/OpenDebugAD7 + patchelf --replace-needed liblttng-ust.so.0 liblttng-ust.so.1 ./debugAdapters/bin/libcoreclrtraceptprovider.so + '' + + lib.optionalString isx86Linux '' + chmod +x bin/libc.so + ''; + + # On aarch64 the binaries are statically linked + # but on x86 they are not. + postFixup = + lib.optionalString isx86Linux '' + autoPatchelf $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters # cpptools* are distributed by the extension and need to be run through the distributed musl interpretter patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-srv