gitlab-duo: init at 8.57.1

@moduon MT-13030 MT-10900

Co-authored-by: Aleksana <alexander.huang.y@gmail.com>
This commit is contained in:
Jairo Llopis
2026-01-15 10:23:21 +00:00
co-authored by Aleksana
parent 860a8446fc
commit 02b6c956b4
3 changed files with 5205 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+84
View File
@@ -0,0 +1,84 @@
{
buildNpmPackage,
bun,
concurrently,
fetchFromGitLab,
lib,
nodejs_22,
patch-package,
stdenv,
versionCheckHook,
}:
buildNpmPackage (finalAttrs: {
pname = "gitlab-duo";
version = "8.57.1";
# DOCS https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp#node-version
nodejs = nodejs_22;
src = fetchFromGitLab {
group = "gitlab-org";
owner = "editor-extensions";
repo = "gitlab-lsp";
tag = "v${finalAttrs.version}";
hash = "sha256-IofCSh9ja3C8WEiksp0pFJ6LZOu86o4VHnwiIUHHgLI=";
};
patches = [
# HACK https://github.com/NixOS/nixpkgs/issues/408720
# Fix packages locked but without hash, or even missing
./missing-hashes.patch
];
# PATCH: Only build for the current platform, not all targets
postPatch = ''
substituteInPlace packages/cli/scripts/compile_executables.sh \
--replace-fail \
'SUPPORTED_TARGETS="bun-linux-x64 bun-linux-arm64 bun-windows-x64 bun-darwin-arm64 bun-darwin-x64"' \
"SUPPORTED_TARGETS=bun-$TARGET"
'';
npmFlags = [ "--install-links" ];
npmDepsHash = "sha256-dj4TrKMdXgUZr7/0NLT7h8jT3VjobB9KFO8tl/+47rk=";
npmBuildScript = "build:binary";
npmWorkspace = "@gitlab/duo-cli";
nativeBuildInputs = [
bun
concurrently
patch-package
];
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "true";
env.PUPPETEER_SKIP_DOWNLOAD = "true";
env.TARGET = "${stdenv.targetPlatform.node.platform}-${stdenv.targetPlatform.node.arch}";
postConfigure = ''
patchShebangs --build ./packages/cli/scripts
npmBuildScript=build:bundle runHook npmBuildHook
'';
installPhase = ''
runHook preInstall
install -Dm755 packages/cli/bin/duo-$TARGET $out/bin/duo
runHook postInstall
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru.updateScript = ./update.sh;
meta = {
broken = stdenv.hostPlatform.isDarwin;
changelog = "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/blob/main/CHANGELOG.md";
description = "CLI for GitLab AI assistant";
downloadPage = "https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp";
homepage = "https://about.gitlab.com/gitlab-duo/";
license = lib.licenses.mit;
mainProgram = "duo";
maintainers = with lib.maintainers; [ yajo ];
};
})
+55
View File
@@ -0,0 +1,55 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p git jaq prefetch-npm-deps nix-update npm-lockfile-fix
set -euo pipefail
# Get new Gitlab Duo release
nix-update --src-only "$UPDATE_NIX_ATTR_PATH"
# Clone new sources
dir="$(mktemp -d --suffix="$UPDATE_NIX_PNAME")"
git clone --depth 1 \
--branch "$(nix-instantiate --eval --raw -E "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.tag")" \
"$(nix-instantiate --eval --raw -E "with import ./. {}; $UPDATE_NIX_ATTR_PATH.src.gitRepoUrl")" \
"$dir"
pushd "$dir"
# HACK https://github.com/npm/cli/issues/4460
# Different dependencies require different versions of esbuild. Vite's lacks
# some integrity hashes. We add a dummy "extra-deps" package to the workspace
# to force recording those hashes.
esbuild_version=$(jaq -r '.packages["node_modules/vite/node_modules/esbuild"].version' ./package-lock.json)
mkdir packages/extra-deps
cat > packages/extra-deps/package.json <<EOF
{
"devDependencies": {
"only-allow": "*"
},
"optionalDependencies": {
"esbuild": "$esbuild_version"
}
}
EOF
jaq -i '.devDependencies["extra-deps"]="workspace:*"' ./package.json
# HACK https://github.com/npm/cli/issues/6787
# Commander requires a higher version than the one locked, so we remove it from the lock
commander_version=$(jaq -r '.packages["packages/cli"].devDependencies.commander' ./package-lock.json)
# Remove ^ prefix
commander_version="${commander_version/^}"
# Sync locked version and remove URL and hash, so they are fixed later
jaq -i --arg ver "$commander_version" \
'.packages["packages/cli/node_modules/commander"].version = $ver | del(.packages["packages/cli/node_modules/commander"].integrity, .packages["packages/cli/node_modules/commander"].resolved)' \
./package-lock.json
npm install --package-lock-only --ignore-scripts
npm-lockfile-fix package-lock.json
npmDepsHash="$(prefetch-npm-deps package-lock.json)"
git add -A
patch="$(git diff --cached)"
popd
# Update nix expression with new hashes
pushd "$(dirname "${BASH_SOURCE[0]}")"
echo "$patch" > missing-hashes.patch
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' -i package.nix
popd