From 2afc2443076783e147b9e8c923ee5135cec8390d Mon Sep 17 00:00:00 2001 From: Artturin Date: Sun, 8 Oct 2023 02:35:12 +0300 Subject: [PATCH] vscode: fix using the fhs with overrideAttrs fixes ```nix ((pkgs.vscode.override { isInsiders = true; }).overrideAttrs (previousAttrs: { version = "latest"; src = (pkgs.fetchurl { name = "VSCODE_insiders.tar.gz"; url = "https://code.visualstudio.com/sha/download?build=insider&os=linux-x64"; sha256 = "sha256-XcDSCuEMnTq2D75X9sNmGkD+CfPoLRJki9cSDDOeUtc="; }); })).fhs ``` NOTE: sha256 isn't stable --- pkgs/applications/editors/vscode/generic.nix | 128 +++++++++---------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index e8ae861bf2fb..1bbeafd2d158 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -20,8 +20,69 @@ , ripgrep }: -let - unwrapped = stdenv.mkDerivation { + stdenv.mkDerivation (finalAttrs: + let + + # Vscode and variants allow for users to download and use extensions + # which often include the usage of pre-built binaries. + # This has been an on-going painpoint for many users, as + # a full extension update cycle has to be done through nixpkgs + # in order to create or update extensions. + # See: #83288 #91179 #73810 #41189 + # + # buildFHSEnv allows for users to use the existing vscode + # extension tooling without significant pain. + fhs = { additionalPkgs ? pkgs: [] }: buildFHSEnv { + # also determines the name of the wrapped command + name = executableName; + + # additional libraries which are commonly needed for extensions + targetPkgs = pkgs: (with pkgs; [ + # ld-linux-x86-64-linux.so.2 and others + glibc + + # dotnet + curl + icu + libunwind + libuuid + lttng-ust + openssl + zlib + + # mono + krb5 + ]) ++ additionalPkgs pkgs; + + extraBwrapArgs = [ + "--bind-try /etc/nixos/ /etc/nixos/" + ]; + + # symlink shared assets, including icons and desktop entries + extraInstallCommands = '' + ln -s "${finalAttrs.finalPackage}/share" "$out/" + ''; + + runScript = "${finalAttrs.finalPackage}/bin/${executableName}"; + + # vscode likes to kill the parent so that the + # gui application isn't attached to the terminal session + dieWithParent = false; + + passthru = { + inherit executableName; + inherit (finalAttrs.finalPackage) pname version; # for home-manager module + }; + + meta = meta // { + description = '' + Wrapped variant of ${pname} which launches in a FHS compatible environment. + Should allow for easy usage of extensions without nix-specific modifications. + ''; + }; + }; + in + { inherit pname version src sourceRoot dontFixup; @@ -158,65 +219,4 @@ let ''; inherit meta; - }; - - # Vscode and variants allow for users to download and use extensions - # which often include the usage of pre-built binaries. - # This has been an on-going painpoint for many users, as - # a full extension update cycle has to be done through nixpkgs - # in order to create or update extensions. - # See: #83288 #91179 #73810 #41189 - # - # buildFHSEnv allows for users to use the existing vscode - # extension tooling without significant pain. - fhs = { additionalPkgs ? pkgs: [] }: buildFHSEnv { - # also determines the name of the wrapped command - name = executableName; - - # additional libraries which are commonly needed for extensions - targetPkgs = pkgs: (with pkgs; [ - # ld-linux-x86-64-linux.so.2 and others - glibc - - # dotnet - curl - icu - libunwind - libuuid - lttng-ust - openssl - zlib - - # mono - krb5 - ]) ++ additionalPkgs pkgs; - - extraBwrapArgs = [ - "--bind-try /etc/nixos/ /etc/nixos/" - ]; - - # symlink shared assets, including icons and desktop entries - extraInstallCommands = '' - ln -s "${unwrapped}/share" "$out/" - ''; - - runScript = "${unwrapped}/bin/${executableName}"; - - # vscode likes to kill the parent so that the - # gui application isn't attached to the terminal session - dieWithParent = false; - - passthru = { - inherit executableName; - inherit (unwrapped) pname version; # for home-manager module - }; - - meta = meta // { - description = '' - Wrapped variant of ${pname} which launches in a FHS compatible environment. - Should allow for easy usage of extensions without nix-specific modifications. - ''; - }; - }; -in - unwrapped + })