From 92fe27da603271baf3495a8496a9d917c639329d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 16 Apr 2022 08:34:58 +0200 Subject: [PATCH 1/2] vscode: move asar to nativeBuildInputs --- pkgs/applications/editors/vscode/generic.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index d704497b4f0c..c5576304e721 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -66,9 +66,9 @@ let buildInputs = [ libsecret libXScrnSaver libxshmfence ] ++ lib.optionals (!stdenv.isDarwin) ([ at-spi2-atk ] ++ atomEnv.packages); - runtimeDependencies = lib.optional (stdenv.isLinux) [ (lib.getLib systemd) fontconfig.lib libdbusmenu ]; + runtimeDependencies = lib.optional stdenv.isLinux [ (lib.getLib systemd) fontconfig.lib libdbusmenu ]; - nativeBuildInputs = [unzip] ++ lib.optionals (!stdenv.isDarwin) [ autoPatchelfHook wrapGAppsHook ]; + nativeBuildInputs = [ unzip ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook nodePackages.asar wrapGAppsHook ]; dontBuild = true; dontConfigure = true; @@ -114,7 +114,7 @@ let # this is a fix for "save as root" functionality packed="resources/app/node_modules.asar" unpacked="resources/app/node_modules" - ${nodePackages.asar}/bin/asar extract "$packed" "$unpacked" + asar extract "$packed" "$unpacked" substituteInPlace $unpacked/@vscode/sudo-prompt/index.js \ --replace "/usr/bin/pkexec" "/run/wrappers/bin/pkexec" \ --replace "/bin/bash" "${bash}/bin/bash" From 2ca1c986175e864bb67a955a4189f7acf51f8b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Sat, 16 Apr 2022 08:35:14 +0200 Subject: [PATCH 2/2] vscode: fix auto encoding detection crashing editor window Closes #152939 --- pkgs/applications/editors/vscode/generic.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index c5576304e721..9a4f1b92d41f 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -120,6 +120,12 @@ let --replace "/bin/bash" "${bash}/bin/bash" rm -rf "$packed" + # without this symlink loading JsChardet, the library that is used for auto encoding detection when files.autoGuessEncoding is true, + # fails to load with: electron/js2c/renderer_init: Error: Cannot find module 'jschardet' + # and the window immediately closes which renders VSCode unusable + # see https://github.com/NixOS/nixpkgs/issues/152939 for full log + ln -rs "$unpacked" "$packed" + # this fixes bundled ripgrep chmod +x resources/app/node_modules/@vscode/ripgrep/bin/rg '';