push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
{
lib,
vscode-utils,
jq,
clang-tools,
gdbUseFixed ? true,
gdb, # The gdb default setting will be fixed to specified. Use version from `PATH` otherwise.
autoPatchelfHook,
makeWrapper,
stdenv,
lttng-ust,
libkrb5,
zlib,
}:
/*
Note that this version of the extension still has some nix specific issues
which could not be fixed merely by patching (inside a C# dll).
In particular, the debugger requires either gnome-terminal or xterm. However
instead of looking for the terminal executable in `PATH`, for any linux platform
the dll uses an hardcoded path to one of these.
So, in order for debugging to work properly, you merely need to create symlinks
to one of these terminals at the appropriate location.
The good news is the the utility library is open source and with some effort
we could build a patched version ourselves. See:
<https://github.com/Microsoft/MIEngine/blob/2885386dc7f35e0f1e44827269341e786361f28e/src/MICore/TerminalLauncher.cs#L156>
Also, the extension should eventually no longer require an external terminal. See:
<https://github.com/Microsoft/vscode-cpptools/issues/35>
Once the symbolic link temporary solution taken, everything should run smootly.
*/
let
gdbDefaultsTo = if gdbUseFixed then "${gdb}/bin/gdb" else "gdb";
isx86Linux = stdenv.hostPlatform.system == "x86_64-linux";
isDarwin = stdenv.hostPlatform.isDarwin;
supported = {
x86_64-linux = {
hash = "sha256-JES5esVW6cRlrmFAQO1yLYEZbLdQu4ILW0rjDBp5Ek4=";
arch = "linux-x64";
};
aarch64-linux = {
hash = "sha256-fZzYzR2wHbCCllhyu4fI2ekPu3fMngUmeJawhkYdWyA=";
arch = "linux-arm64";
};
aarch64-darwin = {
hash = "sha256-fPtCIOYvbO/S06io9lFAXxkB/6g00GO5+RXt5aewPME=";
arch = "darwin-arm64";
};
};
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.26.3";
};
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
];
buildInputs = [
jq
libkrb5
zlib
(lib.getLib stdenv.cc.cc)
]
++ lib.optionals stdenv.hostPlatform.isLinux [ lttng-ust ];
dontAutoPatchelf = isx86Linux || isDarwin;
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 debugAdapters/bin/OpenDebugAD7
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
patchelf --replace-needed liblttng-ust.so.0 liblttng-ust.so.1 ./debugAdapters/bin/libcoreclrtraceptprovider.so
''
+ lib.optionalString isx86Linux ''
chmod +x bin/libc.so
''
+ lib.optionalString isDarwin ''
chmod +x debugAdapters/lldb-mi/bin/lldb-mi
'';
# 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
patchelf --set-interpreter $out/share/vscode/extensions/ms-vscode.cpptools/bin/libc.so $out/share/vscode/extensions/ms-vscode.cpptools/bin/cpptools-wordexp
''
+ lib.optionalString gdbUseFixed ''
wrapProgram $out/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7 --prefix PATH : ${lib.makeBinPath [ gdb ]}
'';
meta = {
description = "C/C++ extension adds language support for C/C++ to Visual Studio Code, including features such as IntelliSense and debugging";
homepage = "https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [
jraygauthier
stargate01
];
platforms = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}

View File

@@ -0,0 +1,51 @@
#!/usr/bin/env nix-shell
#! nix-shell -p coreutils -i bash
scriptDir=$(cd "`dirname "$0"`"; pwd)
echo "scriptDir='$scriptDir'"
function get_pkg_out() {
local pkg="$1"
local suffix="${2:-}"
local nixExp="with (import <nixpkgs> {}); ${pkg}"
echo "$(nix-build -E "$nixExp" --no-out-link)${suffix}"
}
interpreter="$(get_pkg_out "stdenv.cc.libc" "/lib/ld-linux-x86-64.so.2")"
echo "interpreter='$interpreter'"
# For clangformat dep on 'libtinfo.so.5'.
ncursesLibDir="$(get_pkg_out "ncurses5.out" "/lib")"
echo "ncursesLibDir='$ncursesLibDir'"
# For clanformat dep on 'libstdc++.so.6'.
stdcppLibDir="$(get_pkg_out "stdenv.cc.cc.lib" "/lib")"
echo "stdcppLibDir='$stdcppLibDir'"
# For clangformat dep on 'libz.so.1'.
zlibLibDir="$(get_pkg_out "zlib.out" "/lib")"
echo "zlibLibDir='$zlibLibDir'"
function patchelf_mono() {
local exe="$1"
patchelf --set-interpreter "$interpreter" "$exe"
}
function patchelf_clangformat() {
local exe="$1"
patchelf --set-interpreter "$interpreter" "$exe"
local rpath="$ncursesLibDir:$stdcppLibDir:$zlibLibDir"
patchelf --set-rpath "$rpath" "$exe"
}
function print_nix_version_clangtools() {
nixClangToolsBin="$(get_pkg_out "clang-tools" "/bin")"
echo "nixClangToolsBin='$nixClangToolsBin'"
$nixClangToolsBin/clang-format --version
}
function print_nix_version_mono() {
nixMonoBin="$(get_pkg_out "mono" "/bin")"
echo "nixMonoBin='$nixMonoBin'"
$nixMonoBin/mono --version
}

View File

@@ -0,0 +1,25 @@
[
"onLanguage:cpp",
"onLanguage:c",
"onCommand:extension.pickNativeProcess",
"onCommand:extension.pickRemoteNativeProcess",
"onCommand:C_Cpp.ConfigurationEdit",
"onCommand:C_Cpp.ConfigurationSelect",
"onCommand:C_Cpp.ConfigurationProviderSelect",
"onCommand:C_Cpp.SwitchHeaderSource",
"onCommand:C_Cpp.Navigate",
"onCommand:C_Cpp.GoToDeclaration",
"onCommand:C_Cpp.PeekDeclaration",
"onCommand:C_Cpp.ToggleErrorSquiggles",
"onCommand:C_Cpp.ToggleIncludeFallback",
"onCommand:C_Cpp.ToggleDimInactiveRegions",
"onCommand:C_Cpp.ToggleSnippets",
"onCommand:C_Cpp.ShowReleaseNotes",
"onCommand:C_Cpp.ResetDatabase",
"onCommand:C_Cpp.PauseParsing",
"onCommand:C_Cpp.ResumeParsing",
"onCommand:C_Cpp.ShowParsingCommands",
"onCommand:C_Cpp.TakeSurvey",
"onDebug",
"workspaceContains:/.vscode/c_cpp_properties.json"
]

View File

@@ -0,0 +1,161 @@
#!/usr/bin/env nix-shell
#! nix-shell -p coreutils -p jq -p unzip -i bash
set -euo pipefail
#
# A little script to help maintaining this package. It will:
#
# - download the specified version of the extension to the store and print its url, packed store path and hash
# - unpack the extension, bring it to the store and print its store path and hash
# - fetch its runtimes dependencies from the 'package.json' file using the 'jq' utility, unpack those to the store
# and print its url store path and hash
# - patch elf of the binaries that got a nix replacement
# - bring the patched version to the store
# - run their '--version' and call 'ldd'
# - print the version of the runtime deps nix replacements.
#
# TODO: Print to a properly formatted nix file all the required information to fetch everything (extension + runtime deps).
# TODO: Print x86 and maybe darwin runtime dependencies.
#
scriptDir=$(cd "`dirname "$0"`"; pwd)
echo "scriptDir='$scriptDir'"
extPublisher="vscode"
extName="cpptools"
defaultExtVersion="0.16.1"
extVersion="${1:-$defaultExtVersion}"
echo
echo "------------- Downloading extension ---------------"
extZipStoreName="${extPublisher}-${extName}.zip"
extUrl="https://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/ms-vscode/extension/cpptools/${extVersion}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"
echo "extUrl='$extUrl'"
storePathWithSha=$(nix-prefetch-url --name "$extZipStoreName" --print-path "$extUrl" 2> /dev/null)
cpptoolsZipStorePath="$(echo "$storePathWithSha" | tail -n1)"
cpptoolsZipSha256="$(echo "$storePathWithSha" | head -n1)"
echo "cpptoolsZipStorePath='$cpptoolsZipStorePath'"
echo "cpptoolsZipSha256='$cpptoolsZipSha256'"
extStoreName="${extPublisher}-${extName}"
function rm_tmpdir() {
rm -rf "$tmpDir"
}
function make_trapped_tmpdir() {
tmpDir=$(mktemp -d)
trap rm_tmpdir EXIT
}
echo
echo "------------- Unpacked extension ---------------"
make_trapped_tmpdir
unzip -q -d "$tmpDir" "$cpptoolsZipStorePath"
cpptoolsStorePath="$(nix add-to-store -n "$extStoreName" "$tmpDir")"
cpptoolsSha256="$(nix --extra-experimental-features nix-command hash path --base32 --type sha512 "$cpptoolsStorePath")"
echo "cpptoolsStorePath='$cpptoolsStorePath'"
echo "cpptoolsSha256='$cpptoolsSha256'"
rm_tmpdir
storePathWithSha=$(nix-prefetch-url --print-path "file://${cpptoolsStorePath}/extension/package.json" 2> /dev/null)
extPackageJSONStorePath="$(echo "$storePathWithSha" | tail -n1)"
extPackageJSONSha256="$(echo "$storePathWithSha" | head -n1)"
echo "extPackageJSONStorePath='$extPackageJSONStorePath'"
echo "extPackageJSONSha256='$extPackageJSONSha256'"
print_runtime_dep() {
local outName="$1"
local extPackageJSONStorePath="$2"
local depDesc="$3"
local urlRaw=$(cat "$extPackageJSONStorePath" | jq -r --arg desc "$depDesc" '.runtimeDependencies[] | select(.description == $desc) | .url')
local url=$(echo $urlRaw | xargs curl -Ls -o /dev/null -w %{url_effective})
local urlRawVarStr="${outName}_urlRaw='$urlRaw'"
local urlVarStr="${outName}_url='$url'"
echo "$urlRawVarStr"
echo "$urlVarStr"
local storePathWithSha="$(nix-prefetch-url --unpack --print-path "$url" 2> /dev/null)"
local storePath="$(echo "$storePathWithSha" | tail -n1)"
local sha256="$(echo "$storePathWithSha" | head -n1)"
local sha256VarStr="${outName}_sha256='$sha256'"
local storePathVarStr="${outName}_storePath='$storePath'"
echo "$sha256VarStr"
echo "$storePathVarStr"
eval "$urlRawVarStr"
eval "$urlVarStr"
eval "$sha256VarStr"
eval "$storePathVarStr"
}
echo
echo "------------- Runtime dependencies ---------------"
print_runtime_dep "langComponentBinaries" "$extPackageJSONStorePath" "C/C++ language components (Linux / x86_64)"
print_runtime_dep "monoRuntimeBinaries" "$extPackageJSONStorePath" "Mono Runtime (Linux / x86_64)"
print_runtime_dep "clanFormatBinaries" "$extPackageJSONStorePath" "ClangFormat (Linux / x86_64)"
echo
echo "------------- Runtime deps missing elf deps ---------------"
source "$scriptDir/missing_elf_deps.sh"
echo
echo "------------- Runtime dep mono ---------------"
make_trapped_tmpdir
find "$monoRuntimeBinaries_storePath" -mindepth 1 -maxdepth 1 | xargs -d '\n' cp -rp -t "$tmpDir"
chmod -R a+rwx "$tmpDir"
patchelf_mono "$tmpDir/debugAdapters/mono.linux-x86_64"
chmod a+x "$tmpDir/debugAdapters/mono.linux-x86_64"
ldd "$tmpDir/debugAdapters/mono.linux-x86_64"
"$tmpDir/debugAdapters/mono.linux-x86_64" --version
monoRuntimeBinariesPatched_storePath="$(nix add-to-store -n "monoRuntimeBinariesPatched" "$tmpDir")"
echo "monoRuntimeBinariesPatched_storePath='$monoRuntimeBinariesPatched_storePath'"
rm_tmpdir
echo
echo "------------- Runtime dep clang ---------------"
make_trapped_tmpdir
find "$clanFormatBinaries_storePath" -mindepth 1 -maxdepth 1 | xargs -d '\n' cp -rp -t "$tmpDir"
chmod -R a+rwx "$tmpDir"
patchelf_clangformat "$tmpDir/bin/clang-format"
chmod a+x "$tmpDir/bin/clang-format"
ldd "$tmpDir/bin/clang-format"
"$tmpDir/bin/clang-format" --version
clanFormatBinariesPatched_storePath="$(nix add-to-store -n "clanFormatBinariesPatched" "$tmpDir")"
echo "clanFormatBinariesPatched_storePath='$clanFormatBinariesPatched_storePath'"
rm_tmpdir
echo
echo "------------- Nix mono ---------------"
print_nix_version_clangtools
echo
echo "------------- Nix mono ---------------"
print_nix_version_mono