buildVscode: init (#474458)

This commit is contained in:
Michael Daniels
2026-01-25 19:42:32 +00:00
committed by GitHub
8 changed files with 125 additions and 142 deletions
+85 -78
View File
@@ -7,11 +7,10 @@
makeDesktopItem,
unzip,
libsecret,
libXScrnSaver,
libxshmfence,
buildPackages,
at-spi2-atk,
autoPatchelfHook,
buildFHSEnv,
alsa-lib,
libgbm,
nss,
@@ -19,22 +18,21 @@
xorg,
systemdLibs,
fontconfig,
imagemagick,
libdbusmenu,
glib,
buildFHSEnv,
wayland,
libglvnd,
libkrb5,
openssl,
webkitgtk_4_1,
# Populate passthru.tests
tests,
ripgrep,
# needed to fix "Save as Root"
asar,
bash,
}:
{
# Attributes inherit from specific versions
version,
vscodeVersion ? version,
@@ -54,10 +52,17 @@
vscodeServer ? null,
sourceExecutableName ? executableName,
useVSCodeRipgrep ? false,
ripgrep,
hasVsceSign ? false,
patchVSCodePath ? true,
imagemagick,
# Populate passthru.tests
tests,
extraNativeBuildInputs ? [ ],
# Customize FHS environment
# Function that takes default buildFHSEnv arguments and returns modified arguments
customizeFHSEnv ? args: args,
}:
stdenv.mkDerivation (
@@ -77,82 +82,86 @@ stdenv.mkDerivation (
{
additionalPkgs ? pkgs: [ ],
}:
buildFHSEnv {
# also determines the name of the wrapped command
pname = executableName;
inherit version;
let
defaultArgs = {
# also determines the name of the wrapped command
pname = executableName;
inherit version;
# additional libraries which are commonly needed for extensions
targetPkgs =
pkgs:
(with pkgs; [
# ld-linux-x86-64-linux.so.2 and others
glibc
# additional libraries which are commonly needed for extensions
targetPkgs =
pkgs:
(with pkgs; [
# ld-linux-x86-64-linux.so.2 and others
glibc
# dotnet
curl
icu
libunwind
libuuid
lttng-ust
openssl
zlib
# dotnet
curl
icu
libunwind
libuuid
lttng-ust
openssl
zlib
# mono
krb5
# mono
krb5
# Needed for headless browser-in-vscode based plugins such as
# anything based on Puppeteer https://pptr.dev .
# e.g. Roo Code
glib
nspr
nss
dbus
at-spi2-atk
cups
expat
libxkbcommon
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libxcb
xorg.libXext
xorg.libXfixes
xorg.libXrandr
cairo
pango
alsa-lib
libgbm
udev
libudev0-shim
])
++ additionalPkgs pkgs;
# Needed for headless browser-in-vscode based plugins such as
# anything based on Puppeteer https://pptr.dev .
# e.g. Roo Code
glib
nspr
nss
dbus
at-spi2-atk
cups
expat
libxkbcommon
xorg.libX11
xorg.libXcomposite
xorg.libXdamage
xorg.libxcb
xorg.libXext
xorg.libXfixes
xorg.libXrandr
cairo
pango
alsa-lib
libgbm
udev
libudev0-shim
])
++ additionalPkgs pkgs;
extraBwrapArgs = [
"--bind-try /etc/nixos/ /etc/nixos/"
"--ro-bind-try /etc/xdg/ /etc/xdg/"
];
extraBwrapArgs = [
"--bind-try /etc/nixos/ /etc/nixos/"
"--ro-bind-try /etc/xdg/ /etc/xdg/"
];
# symlink shared assets, including icons and desktop entries
extraInstallCommands = ''
ln -s "${finalAttrs.finalPackage}/share" "$out/"
'';
# symlink shared assets, including icons and desktop entries
extraInstallCommands = ''
ln -s "${finalAttrs.finalPackage}/share" "$out/"
'';
runScript = "${finalAttrs.finalPackage}/bin/${executableName}";
runScript = "${finalAttrs.finalPackage}/bin/${executableName}";
# vscode likes to kill the parent so that the
# gui application isn't attached to the terminal session
dieWithParent = false;
# vscode likes to kill the parent so that the
# gui application isn't attached to the terminal session
dieWithParent = false;
passthru = {
inherit executableName;
inherit (finalAttrs.finalPackage) pname version; # for home-manager module
passthru = {
inherit executableName;
inherit (finalAttrs.finalPackage) pname version; # for home-manager module
};
meta = meta // {
description = "Wrapped variant of ${pname} which launches in a FHS compatible environment, should allow for easy usage of extensions without nix-specific modifications";
};
};
meta = meta // {
description = "Wrapped variant of ${pname} which launches in a FHS compatible environment, should allow for easy usage of extensions without nix-specific modifications";
};
};
customizedArgs = customizeFHSEnv defaultArgs;
in
buildFHSEnv customizedArgs;
in
{
@@ -225,13 +234,10 @@ stdenv.mkDerivation (
buildInputs = [
libsecret
libXScrnSaver
libxshmfence
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
alsa-lib
at-spi2-atk
libkrb5
libgbm
nss
nspr
@@ -252,6 +258,7 @@ stdenv.mkDerivation (
unzip
imagemagick
]
++ extraNativeBuildInputs
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
asar
+2 -2
View File
@@ -2,7 +2,7 @@
lib,
stdenv,
stdenvNoCC,
callPackage,
buildVscode,
fetchurl,
nixosTests,
srcOnly,
@@ -51,7 +51,7 @@ let
# This is used for VS Code - Remote SSH test
rev = "585eba7c0c34fd6b30faac7c62a42050bfbc0086";
in
callPackage ./generic.nix {
buildVscode {
pname = "vscode" + lib.optionalString isInsiders "-insiders";
executableName = "code" + lib.optionalString isInsiders "-insiders";
@@ -1,7 +1,7 @@
{
lib,
stdenv,
callPackage,
buildVscode,
fetchurl,
nixosTests,
commandLineArgs ? "",
@@ -38,7 +38,7 @@ let
sourceRoot = lib.optionalString (!stdenv.hostPlatform.isDarwin) ".";
in
callPackage ./generic.nix rec {
buildVscode rec {
inherit sourceRoot commandLineArgs useVSCodeRipgrep;
# Please backport all compatible updates to the stable release.
+23 -27
View File
@@ -1,11 +1,9 @@
{
lib,
stdenv,
callPackage,
vscode-generic,
buildVscode,
fetchurl,
jq,
buildFHSEnv,
writeShellScript,
coreutils,
commandLineArgs ? "",
@@ -19,7 +17,7 @@ let
information.sources."${hostPlatform.system}"
or (throw "antigravity: unsupported system ${hostPlatform.system}");
in
(callPackage vscode-generic {
(buildVscode {
inherit commandLineArgs useVSCodeRipgrep;
inherit (information) version vscodeVersion;
pname = "antigravity";
@@ -34,32 +32,30 @@ in
sourceRoot = if hostPlatform.isDarwin then "Antigravity.app" else "Antigravity";
# When running inside an FHS environment, try linking Google Chrome or Chromium
# to the hardcoded Playwright search path: /opt/google/chrome/chrome
buildFHSEnv =
args:
buildFHSEnv (
args
// {
extraBuildCommands = (args.extraBuildCommands or "") + ''
mkdir -p "$out/opt/google/chrome"
'';
extraBwrapArgs = (args.extraBwrapArgs or [ ]) ++ [ "--tmpfs /opt/google/chrome" ];
runScript = writeShellScript "antigravity-wrapper" ''
for candidate in google-chrome-stable google-chrome chromium-browser chromium; do
if target=$(command -v "$candidate"); then
${coreutils}/bin/ln -sf "$target" /opt/google/chrome/chrome
break
fi
done
exec ${args.runScript} "$@"
'';
}
);
tests = { };
updateScript = ./update.js;
# When running inside an FHS environment, try linking Google Chrome or Chromium
# to the hardcoded Playwright search path: /opt/google/chrome/chrome
customizeFHSEnv =
args:
args
// {
extraBwrapArgs = (args.extraBwrapArgs or [ ]) ++ [ "--tmpfs /opt/google/chrome" ];
extraBuildCommands = (args.extraBuildCommands or "") + ''
mkdir -p "$out/opt/google/chrome"
'';
runScript = writeShellScript "antigravity-wrapper" ''
for candidate in google-chrome-stable google-chrome chromium-browser chromium; do
if target=$(command -v "$candidate"); then
${coreutils}/bin/ln -sf "$target" /opt/google/chrome/chrome
break
fi
done
exec ${args.runScript} "$@"
'';
};
meta = {
mainProgram = "antigravity";
description = "Agentic development platform, evolving the IDE into the agent-first era";
+7 -13
View File
@@ -1,8 +1,7 @@
{
lib,
stdenv,
callPackage,
vscode-generic,
buildVscode,
fetchurl,
appimageTools,
undmg,
@@ -24,7 +23,7 @@ let
source = sources.${hostPlatform.system};
in
(callPackage vscode-generic rec {
buildVscode rec {
inherit useVSCodeRipgrep;
inherit (sourcesJson) version vscodeVersion;
commandLineArgs = finalCommandLineArgs;
@@ -46,6 +45,9 @@ in
else
source;
# for unpacking the DMG
extraNativeBuildInputs = lib.optionals hostPlatform.isDarwin [ undmg ];
sourceRoot =
if hostPlatform.isLinux then "${pname}-${version}-extracted/usr/share/cursor" else "Cursor.app";
@@ -66,7 +68,7 @@ in
homepage = "https://cursor.com";
changelog = "https://cursor.com/changelog";
license = lib.licenses.unfree;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
maintainers = with lib.maintainers; [
aspauldingcode
prince213
@@ -79,12 +81,4 @@ in
++ lib.platforms.darwin;
mainProgram = "cursor";
};
}).overrideAttrs
(oldAttrs: {
nativeBuildInputs =
(oldAttrs.nativeBuildInputs or [ ]) ++ lib.optionals hostPlatform.isDarwin [ undmg ];
passthru = (oldAttrs.passthru or { }) // {
inherit sources;
};
})
}
+2 -3
View File
@@ -1,8 +1,7 @@
{
lib,
stdenv,
callPackage,
vscode-generic,
buildVscode,
fetchurl,
extraCommandLineArgs ? "",
useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin,
@@ -11,7 +10,7 @@
let
sources = (lib.importJSON ./sources.json).${stdenv.hostPlatform.system};
in
(callPackage vscode-generic {
(buildVscode {
inherit useVSCodeRipgrep;
commandLineArgs = extraCommandLineArgs;
+2 -3
View File
@@ -1,8 +1,7 @@
{
lib,
stdenv,
callPackage,
vscode-generic,
buildVscode,
fetchurl,
nixosTests,
commandLineArgs ? "",
@@ -13,7 +12,7 @@ let
(lib.importJSON ./info.json)."${stdenv.hostPlatform.system}"
or (throw "windsurf: unsupported system ${stdenv.hostPlatform.system}");
in
callPackage vscode-generic {
buildVscode {
inherit commandLineArgs useVSCodeRipgrep;
inherit (info) version vscodeVersion;
+2 -14
View File
@@ -11810,6 +11810,8 @@ with pkgs;
vscode-fhs = vscode.fhs;
vscode-fhsWithPackages = vscode.fhsWithPackages;
buildVscode = callPackage ../applications/editors/vscode/generic.nix { };
vscode-with-extensions = callPackage ../applications/editors/vscode/with-extensions.nix { };
vscode-utils = callPackage ../applications/editors/vscode/extensions/vscode-utils.nix { };
@@ -11824,25 +11826,11 @@ with pkgs;
vscodium-fhs = vscodium.fhs;
vscodium-fhsWithPackages = vscodium.fhsWithPackages;
antigravity = callPackage ../by-name/an/antigravity/package.nix {
vscode-generic = ../applications/editors/vscode/generic.nix;
};
antigravity-fhs = antigravity.fhs;
antigravity-fhsWithPackages = antigravity.fhsWithPackages;
code-cursor = callPackage ../by-name/co/code-cursor/package.nix {
vscode-generic = ../applications/editors/vscode/generic.nix;
};
code-cursor-fhs = code-cursor.fhs;
code-cursor-fhsWithPackages = code-cursor.fhsWithPackages;
windsurf = callPackage ../by-name/wi/windsurf/package.nix {
vscode-generic = ../applications/editors/vscode/generic.nix;
};
kiro = callPackage ../by-name/ki/kiro/package.nix {
vscode-generic = ../applications/editors/vscode/generic.nix;
};
kiro-fhs = kiro.fhs;
kiro-fhsWithPackages = kiro.fhsWithPackages;