From c65c648c54d1c51404cd32ef7b96a3841fb4cf6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:42:20 -0400 Subject: [PATCH 1/2] vscode: use copyDesktopItems hook instead of manually copying --- pkgs/applications/editors/vscode/generic.nix | 69 ++++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index 7b320000d4dd1..d9ca7cf41eba5 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -1,5 +1,6 @@ { stdenv , lib +, copyDesktopItems , makeDesktopItem , unzip , libsecret @@ -122,38 +123,39 @@ in inherit rev vscodeServer; }; - desktopItem = makeDesktopItem { - name = executableName; - desktopName = longName; - comment = "Code Editing. Redefined."; - genericName = "Text Editor"; - exec = "${executableName} %F"; - icon = "vs${executableName}"; - startupNotify = true; - startupWMClass = shortName; - categories = [ "Utility" "TextEditor" "Development" "IDE" ]; - mimeTypes = [ "text/plain" "inode/directory" ]; - keywords = [ "vscode" ]; - actions.new-empty-window = { - name = "New Empty Window"; - exec = "${executableName} --new-window %F"; + desktopItems = [ + (makeDesktopItem { + name = executableName; + desktopName = longName; + comment = "Code Editing. Redefined."; + genericName = "Text Editor"; + exec = "${executableName} %F"; icon = "vs${executableName}"; - }; - }; - - urlHandlerDesktopItem = makeDesktopItem { - name = executableName + "-url-handler"; - desktopName = longName + " - URL Handler"; - comment = "Code Editing. Redefined."; - genericName = "Text Editor"; - exec = executableName + " --open-url %U"; - icon = "vs${executableName}"; - startupNotify = true; - categories = [ "Utility" "TextEditor" "Development" "IDE" ]; - mimeTypes = [ "x-scheme-handler/vs${executableName}" ]; - keywords = [ "vscode" ]; - noDisplay = true; - }; + startupNotify = true; + startupWMClass = shortName; + categories = [ "Utility" "TextEditor" "Development" "IDE" ]; + mimeTypes = [ "text/plain" "inode/directory" ]; + keywords = [ "vscode" ]; + actions.new-empty-window = { + name = "New Empty Window"; + exec = "${executableName} --new-window %F"; + icon = "vs${executableName}"; + }; + }) + (makeDesktopItem { + name = executableName + "-url-handler"; + desktopName = longName + " - URL Handler"; + comment = "Code Editing. Redefined."; + genericName = "Text Editor"; + exec = executableName + " --open-url %U"; + icon = "vs${executableName}"; + startupNotify = true; + categories = [ "Utility" "TextEditor" "Development" "IDE" ]; + mimeTypes = [ "x-scheme-handler/vs${executableName}" ]; + keywords = [ "vscode" ]; + noDisplay = true; + }) + ]; buildInputs = [ libsecret libXScrnSaver libxshmfence ] ++ lib.optionals (!stdenv.isDarwin) [ alsa-lib at-spi2-atk libkrb5 mesa nss nspr systemd xorg.libxkbfile ]; @@ -164,6 +166,7 @@ in ++ lib.optionals stdenv.isLinux [ autoPatchelfHook asar + copyDesktopItems # override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651 (buildPackages.wrapGAppsHook3.override { inherit (buildPackages) makeWrapper; }) ]; @@ -184,10 +187,6 @@ in ln -s "$out/lib/vscode/bin/${sourceExecutableName}" "$out/bin/${executableName}" - mkdir -p "$out/share/applications" - ln -s "$desktopItem/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop" - ln -s "$urlHandlerDesktopItem/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop" - # These are named vscode.png, vscode-insiders.png, etc to match the name in upstream *.deb packages. mkdir -p "$out/share/pixmaps" cp "$out/lib/vscode/resources/app/resources/linux/code.png" "$out/share/pixmaps/vs${executableName}.png" From dead77e1174742eb220104f6b04d36e531669b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Sat, 10 Aug 2024 13:44:19 -0400 Subject: [PATCH 2/2] vscode: remove folder and text mimetype associations See https://github.com/microsoft/vscode/pull/209510. --- pkgs/applications/editors/vscode/generic.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index d9ca7cf41eba5..f2807a1b592d1 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -134,7 +134,6 @@ in startupNotify = true; startupWMClass = shortName; categories = [ "Utility" "TextEditor" "Development" "IDE" ]; - mimeTypes = [ "text/plain" "inode/directory" ]; keywords = [ "vscode" ]; actions.new-empty-window = { name = "New Empty Window";