Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 89 additions & 82 deletions pkgs/applications/editors/vscode/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,32 @@
makeDesktopItem,
unzip,
libsecret,
libXScrnSaver,
libxshmfence,
buildPackages,
at-spi2-atk,
autoPatchelfHook,
buildFHSEnv,
alsa-lib,
libgbm,
nss,
nspr,
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,
Expand All @@ -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 (
Expand All @@ -77,82 +82,86 @@ stdenv.mkDerivation (
{
additionalPkgs ? pkgs: [ ],
}:
buildFHSEnv {
# 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

# dotnet
curl
icu
libunwind
libuuid
lttng-ust
openssl
zlib

# 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;

extraBwrapArgs = [
"--bind-try /etc/nixos/ /etc/nixos/"
"--ro-bind-try /etc/xdg/ /etc/xdg/"
];
let
defaultArgs = {
# also determines the name of the wrapped command
pname = executableName;
inherit version;

# symlink shared assets, including icons and desktop entries
extraInstallCommands = ''
ln -s "${finalAttrs.finalPackage}/share" "$out/"
'';
# additional libraries which are commonly needed for extensions
targetPkgs =
pkgs:
(with pkgs; [
# ld-linux-x86-64-linux.so.2 and others
glibc

runScript = "${finalAttrs.finalPackage}/bin/${executableName}";
# dotnet
curl
icu
libunwind
libuuid
lttng-ust
openssl
zlib

# vscode likes to kill the parent so that the
# gui application isn't attached to the terminal session
dieWithParent = false;
# mono
krb5

passthru = {
inherit executableName;
inherit (finalAttrs.finalPackage) pname version; # for home-manager module
};
# 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/"
];

# symlink shared assets, including icons and desktop entries
extraInstallCommands = ''
ln -s "${finalAttrs.finalPackage}/share" "$out/"
'';

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;

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
{

Expand Down Expand Up @@ -225,13 +234,10 @@ stdenv.mkDerivation (

buildInputs = [
libsecret
libXScrnSaver
libxshmfence
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
alsa-lib
at-spi2-atk
libkrb5
libgbm
nss
nspr
Expand All @@ -252,6 +258,7 @@ stdenv.mkDerivation (
unzip
imagemagick
]
++ extraNativeBuildInputs
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
asar
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/vscode/vscode.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib,
stdenv,
stdenvNoCC,
callPackage,
buildVscode,
fetchurl,
nixosTests,
srcOnly,
Expand Down Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/editors/vscode/vscodium.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
lib,
stdenv,
callPackage,
buildVscode,
fetchurl,
nixosTests,
commandLineArgs ? "",
Expand Down Expand Up @@ -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.
Expand Down
48 changes: 22 additions & 26 deletions pkgs/by-name/an/antigravity/package.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
lib,
stdenv,
callPackage,
vscode-generic,
buildVscode,
fetchurl,
jq,
buildFHSEnv,
writeShellScript,
coreutils,
commandLineArgs ? "",
Expand All @@ -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";
Expand All @@ -34,31 +32,29 @@ in

sourceRoot = if hostPlatform.isDarwin then "Antigravity.app" else "Antigravity";

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
buildFHSEnv =
customizeFHSEnv =
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;
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";
Expand Down
Loading
Loading