Unverified Commit c0fbc2ce authored by Michael Daniels's avatar Michael Daniels Committed by GitHub
Browse files

buildVscode: init (#474458)

parents 7b1a07ed e157104d
Loading
Loading
Loading
Loading
+89 −82
Original line number Diff line number Diff line
@@ -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,7 +82,8 @@ stdenv.mkDerivation (
      {
        additionalPkgs ? pkgs: [ ],
      }:
      buildFHSEnv {
      let
        defaultArgs = {
          # also determines the name of the wrapped command
          pname = executableName;
          inherit version;
@@ -153,6 +159,9 @@ stdenv.mkDerivation (
            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
Original line number Diff line number Diff line
@@ -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";
+2 −2
Original line number Diff line number Diff line
{
  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.
+22 −26
Original line number Diff line number Diff line
{
  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,17 +32,19 @@ 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
    // {
      extraBwrapArgs = (args.extraBwrapArgs or [ ]) ++ [ "--tmpfs /opt/google/chrome" ];
      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
@@ -54,11 +54,7 @@ in
        done
        exec ${args.runScript} "$@"
      '';
      }
    );

  tests = { };
  updateScript = ./update.js;
    };

  meta = {
    mainProgram = "antigravity";
+7 −13
Original line number Diff line number Diff line
{
  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;
    };
  })
}
Loading