diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index 4363f83ba037..7e50c0ed2cd7 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -7,6 +7,9 @@ # Populate passthru.tests , tests +# needed to fix "Save as Root" +, nodePackages, bash + # Attributes inherit from specific versions , version, src, meta, sourceRoot , executableName, longName, shortName, pname, updateScript @@ -108,6 +111,18 @@ let ) ''; + # See https://github.com/NixOS/nixpkgs/issues/49643#issuecomment-873853897 + postPatch = '' + # 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" + substituteInPlace $unpacked/sudo-prompt/index.js \ + --replace "/usr/bin/pkexec" "/run/wrappers/bin/pkexec" \ + --replace "/bin/bash" "${bash}/bin/bash" + rm -rf "$packed" + ''; + inherit meta; };