git.iko.soy/typeable/nixpkgs
on master help sign in
vscod{e,ium}: Add fhs passthru
commit9bd292c9291abf6ca53980f9316d55c83d5753b4 authorJonathan Ringer <jonringer117@gmail.com> dateThu 8 Apr 2021, 00:05 (6 years ago) parent73a0b6c
1 file changed+61−4
pkgs/applications/editors/vscode/generic.nix+61−4
pkgs/applications/editors/vscode/generic.nix+61−4
@@ -1,7 +1,8 @@
11{ stdenv, lib, makeDesktopItem
22, unzip, libsecret, libXScrnSaver, libxshmfence, wrapGAppsHook
33, gtk2, atomEnv, at-spi2-atk, autoPatchelfHook
4−, systemd, fontconfig, libdbusmenu
4+, systemd, fontconfig, libdbusmenu, buildFHSUserEnvBubblewrap
5+, writeShellScriptBin
56
67# Populate passthru.tests
78, tests
@@ -13,13 +14,14 @@
1314
1415let
1516 inherit (stdenv.hostPlatform) system;
16−in
17− stdenv.mkDerivation {
17+ unwrapped = stdenv.mkDerivation {
1818
1919 inherit pname version src sourceRoot;
2020
2121 passthru = {
2222 inherit executableName tests;
23+ fhs = fhs {};
24+ fhsWithPackages = f: fhs { additionalPkgs = f; };
2325 };
2426
2527 desktopItem = makeDesktopItem {
@@ -97,4 +99,59 @@ in
9799 '';
98100
99101 inherit meta;
100− }
102+ };
103+
104+ # Vscode and variants allow for users to download and use extensions
105+ # which often include the usage of pre-built binaries.
106+ # This has been an on-going painpoint for many users, as
107+ # a full extension update cycle has to be done through nixpkgs
108+ # in order to create or update extensions.
109+ # See: #83288 #91179 #73810 #41189
110+ #
111+ # buildFHSUserEnv allows for users to use the existing vscode
112+ # extension tooling without significant pain.
113+ fhs = { additionalPkgs ? pkgs: [] }: buildFHSUserEnvBubblewrap {
114+ # also determines the name of the wrapped command
115+ name = executableName;
116+
117+ # additional libraries which are commonly needed for extensions
118+ targetPkgs = pkgs: (with pkgs; [
119+ # ld-linux-x86-64-linux.so.2 and others
120+ glibc
121+
122+ # dotnet
123+ curl
124+ icu
125+ libunwind
126+ libuuid
127+ openssl
128+ zlib
129+
130+ # mono
131+ krb5
132+ ]) ++ additionalPkgs pkgs;
133+
134+ # restore desktop item icons
135+ extraInstallCommands = ''
136+ mkdir -p $out/share/applications
137+ for item in ${unwrapped}/share/applications/*.desktop; do
138+ ln -s $item $out/share/applications/
139+ done
140+ '';
141+
142+ runScript = "${unwrapped}/bin/${executableName}";
143+
144+ # vscode likes to kill the parent so that the
145+ # gui application isn't attached to the terminal session
146+ dieWithParent = false;
147+
148+ passthru = {
149+ inherit executableName;
150+ inherit (unwrapped) pname version; # for home-manager module
151+ };
152+
153+ inherit meta;
154+ };
155+in
156+ unwrapped
157+