about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/vscode
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/vscode')
-rw-r--r--nixpkgs/pkgs/applications/editors/vscode/generic.nix102
-rw-r--r--nixpkgs/pkgs/applications/editors/vscode/vscode.nix53
-rw-r--r--nixpkgs/pkgs/applications/editors/vscode/vscodium.nix52
-rw-r--r--nixpkgs/pkgs/applications/editors/vscode/with-extensions.nix75
4 files changed, 282 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/editors/vscode/generic.nix b/nixpkgs/pkgs/applications/editors/vscode/generic.nix
new file mode 100644
index 000000000000..e42ca8a0bbf8
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/vscode/generic.nix
@@ -0,0 +1,102 @@
+{ stdenv, lib, makeDesktopItem
+, unzip, libsecret, libXScrnSaver, wrapGAppsHook
+, gtk2, atomEnv, at-spi2-atk, autoPatchelfHook
+, systemd, fontconfig
+
+# Attributes inherit from specific versions
+, version, src, meta, sourceRoot
+, executableName, longName, shortName, pname
+}:
+
+let
+  inherit (stdenv.hostPlatform) system;
+in
+  stdenv.mkDerivation rec {
+
+    inherit pname version src sourceRoot;
+
+    passthru = {
+      inherit executableName;
+    };
+
+    desktopItem = makeDesktopItem {
+      name = executableName;
+      desktopName = longName;
+      comment = "Code Editing. Redefined.";
+      genericName = "Text Editor";
+      exec = executableName;
+      icon = "@out@/share/pixmaps/code.png";
+      startupNotify = "true";
+      categories = "Utility;TextEditor;Development;IDE;";
+      mimeType = "text/plain;inode/directory;";
+      extraEntries = ''
+        StartupWMClass=${shortName}
+        Actions=new-empty-window;
+        Keywords=vscode;
+
+        [Desktop Action new-empty-window]
+        Name=New Empty Window
+        Exec=${executableName} --new-window %F
+        Icon=@out@/share/pixmaps/code.png
+      '';
+    };
+
+    urlHandlerDesktopItem = makeDesktopItem {
+      name = executableName + "-url-handler";
+      desktopName = longName + " - URL Handler";
+      comment = "Code Editing. Redefined.";
+      genericName = "Text Editor";
+      exec = executableName + " --open-url %U";
+      icon = "@out@/share/pixmaps/code.png";
+      startupNotify = "true";
+      categories = "Utility;TextEditor;Development;IDE;";
+      mimeType = "x-scheme-handler/vscode;";
+      extraEntries = ''
+        NoDisplay=true
+        Keywords=vscode;
+      '';
+    };
+
+    buildInputs = (if stdenv.isDarwin
+      then [ unzip ]
+      else [ gtk2 at-spi2-atk wrapGAppsHook ] ++ atomEnv.packages)
+        ++ [ libsecret libXScrnSaver ];
+
+    nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook;
+
+    dontBuild = true;
+    dontConfigure = true;
+
+    installPhase =
+      if system == "x86_64-darwin" then ''
+        mkdir -p $out/lib/vscode $out/bin
+        cp -r ./* $out/lib/vscode
+        ln -s $out/lib/vscode/Contents/Resources/app/bin/${executableName} $out/bin
+      '' else ''
+        mkdir -p $out/lib/vscode $out/bin
+        cp -r ./* $out/lib/vscode
+
+        substituteInPlace $out/lib/vscode/bin/${executableName} --replace '"$CLI" "$@"' '"$CLI" "--skip-getting-started" "$@"'
+
+        ln -s $out/lib/vscode/bin/${executableName} $out/bin
+
+        mkdir -p $out/share/applications
+        substitute $desktopItem/share/applications/${executableName}.desktop $out/share/applications/${executableName}.desktop \
+          --subst-var out
+        substitute $urlHandlerDesktopItem/share/applications/${executableName}-url-handler.desktop $out/share/applications/${executableName}-url-handler.desktop \
+          --subst-var out
+
+        mkdir -p $out/share/pixmaps
+        cp $out/lib/vscode/resources/app/resources/linux/code.png $out/share/pixmaps/code.png
+
+        # Override the previously determined VSCODE_PATH with the one we know to be correct
+        sed -i "/ELECTRON=/iVSCODE_PATH='$out/lib/vscode'" $out/bin/${executableName}
+        grep -q "VSCODE_PATH='$out/lib/vscode'" $out/bin/${executableName} # check if sed succeeded
+      '';
+
+    preFixup = lib.optionalString (system == "i686-linux" || system == "x86_64-linux") ''
+      gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ systemd fontconfig ]})
+    '';
+
+    inherit meta;
+  }
diff --git a/nixpkgs/pkgs/applications/editors/vscode/vscode.nix b/nixpkgs/pkgs/applications/editors/vscode/vscode.nix
new file mode 100644
index 000000000000..c8db515e47df
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/vscode/vscode.nix
@@ -0,0 +1,53 @@
+{ stdenv, lib, callPackage, fetchurl, isInsiders ? false }:
+
+let
+  inherit (stdenv.hostPlatform) system;
+
+  plat = {
+    "x86_64-linux" = "linux-x64";
+    "x86_64-darwin" = "darwin";
+  }.${system};
+
+  archive_fmt = if system == "x86_64-darwin" then "zip" else "tar.gz";
+
+  sha256 = {
+    "x86_64-linux" = "02h71b9m9w4nc8g9iy2kafg041brli4zwv7pv6i1qg6p5cf2jdfx";
+    "x86_64-darwin" = "1awq0rwiizwbjqf7crv59qr7m7rmgpfba0b4qx2bpx1mn25fmq56";
+  }.${system};
+in
+  callPackage ./generic.nix rec {
+
+    version = "1.36.0";
+    pname = "vscode";
+
+    executableName = "code" + lib.optionalString isInsiders "-insiders";
+    longName = "Visual Studio Code" + lib.optionalString isInsiders " - Insiders";
+    shortName = "Code" + lib.optionalString isInsiders " - Insiders";
+
+    src = fetchurl {
+      name = "VSCode_${version}_${plat}.${archive_fmt}";
+      url = "https://vscode-update.azurewebsites.net/${version}/${plat}/stable";
+      inherit sha256;
+    };
+
+    sourceRoot = "";
+
+    meta = with stdenv.lib; {
+      description = ''
+        Open source source code editor developed by Microsoft for Windows,
+        Linux and macOS
+      '';
+      longDescription = ''
+        Open source source code editor developed by Microsoft for Windows,
+        Linux and macOS. It includes support for debugging, embedded Git
+        control, syntax highlighting, intelligent code completion, snippets,
+        and code refactoring. It is also customizable, so users can change the
+        editor's theme, keyboard shortcuts, and preferences
+      '';
+      homepage = https://code.visualstudio.com/;
+      downloadPage = https://code.visualstudio.com/Updates;
+      license = licenses.unfree;
+      maintainers = with maintainers; [ eadwu synthetica ];
+      platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/editors/vscode/vscodium.nix b/nixpkgs/pkgs/applications/editors/vscode/vscodium.nix
new file mode 100644
index 000000000000..f651ee0653d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/vscode/vscodium.nix
@@ -0,0 +1,52 @@
+{ stdenv, callPackage, fetchurl }:
+
+let
+  inherit (stdenv.hostPlatform) system;
+
+  plat = {
+    "x86_64-linux" = "linux-x64";
+    "x86_64-darwin" = "darwin";
+  }.${system};
+
+  archive_fmt = if system == "x86_64-darwin" then "zip" else "tar.gz";
+
+  sha256 = {
+    "x86_64-linux" = "09vmq87az0f91xwyfby85pnn4mg0rlf7pyvs5bkrxv0r8jxxfpq7";
+    "x86_64-darwin" = "16yzzmlf3v9aj7dyglqjxdksabv0cc98w6kdv5rbfw865hj4bbck";
+  }.${system};
+in
+  callPackage ./generic.nix rec {
+
+    version = "1.36.0";
+    pname = "vscodium";
+
+    executableName = "codium";
+    longName = "VSCodium";
+    shortName = "Codium";
+
+    src = fetchurl {
+      url = "https://github.com/VSCodium/vscodium/releases/download/${version}/VSCodium-${plat}-${version}.${archive_fmt}";
+      inherit sha256;
+    };
+
+    sourceRoot = ".";
+
+    meta = with stdenv.lib; {
+      description = ''
+        Open source source code editor developed by Microsoft for Windows,
+        Linux and macOS (VS Code without MS branding/telemetry/licensing)
+      '';
+      longDescription = ''
+        Open source source code editor developed by Microsoft for Windows,
+        Linux and macOS. It includes support for debugging, embedded Git
+        control, syntax highlighting, intelligent code completion, snippets,
+        and code refactoring. It is also customizable, so users can change the
+        editor's theme, keyboard shortcuts, and preferences
+      '';
+      homepage = https://github.com/VSCodium/vscodium;
+      downloadPage = https://github.com/VSCodium/vscodium/releases;
+      license = licenses.mit;
+      maintainers = with maintainers; [];
+      platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/editors/vscode/with-extensions.nix b/nixpkgs/pkgs/applications/editors/vscode/with-extensions.nix
new file mode 100644
index 000000000000..074e6b8b12d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/vscode/with-extensions.nix
@@ -0,0 +1,75 @@
+{ lib, runCommand, buildEnv, vscode, makeWrapper
+, vscodeExtensions ? [] }:
+
+/*
+  `vscodeExtensions`
+   :  A set of vscode extensions to be installed alongside the editor. Here's a an
+      example:
+
+      ~~~
+      vscode-with-extensions.override {
+
+        # When the extension is already available in the default extensions set.
+        vscodeExtensions = with vscode-extensions; [
+          bbenoist.Nix
+        ]
+
+        # Concise version from the vscode market place when not available in the default set.
+        ++ vscode-utils.extensionsFromVscodeMarketplace [
+          {
+            name = "code-runner";
+            publisher = "formulahendry";
+            version = "0.6.33";
+            sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
+          }
+        ];
+      }
+      ~~~
+
+      This expression should fetch
+       -  the *nix* vscode extension from whatever source defined in the
+          default nixpkgs extensions set `vscodeExtensions`.
+
+       -  the *code-runner* vscode extension from the marketplace using the
+          following url:
+
+          ~~~
+          https://bbenoist.gallery.vsassets.io/_apis/public/gallery/publisher/bbenoist/extension/nix/1.0.1/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
+          ~~~
+
+      The original `code` executable will be wrapped so that it uses the set of pre-installed / unpacked
+      extensions as its `--extensions-dir`.
+*/
+
+let
+
+  inherit (vscode) executableName;
+  wrappedPkgVersion = lib.getVersion vscode;
+  wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
+
+  combinedExtensionsDrv = buildEnv {
+    name = "${wrappedPkgName}-extensions-${wrappedPkgVersion}";
+    paths = vscodeExtensions;
+  };
+
+in
+
+# When no extensions are requested, we simply redirect to the original
+# non-wrapped vscode executable.
+runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
+  buildInputs = [ vscode makeWrapper ];
+  dontPatchELF = true;
+  dontStrip = true;
+  meta = vscode.meta;
+} ''
+  mkdir -p "$out/bin"
+  mkdir -p "$out/share/applications"
+  mkdir -p "$out/share/pixmaps"
+
+  ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png"
+  ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
+  ln -sT "${vscode}/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop"
+  makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${lib.optionalString (vscodeExtensions != []) ''
+    --add-flags "--extensions-dir ${combinedExtensionsDrv}/share/${wrappedPkgName}/extensions"
+  ''}
+''