From 119febc46489fc2b366fb5915667a6eb5d688059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Fri, 15 Jul 2022 16:29:10 +0200 Subject: [PATCH] vscode: avoid unnecessary IFD (again) Fixed in https://github.com/nix-community/home-manager/pull/2506 then unfixed in https://github.com/nix-community/home-manager/pull/2613 --- modules/programs/vscode.nix | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix index df1dd2378..dcfed07b1 100644 --- a/modules/programs/vscode.nix +++ b/modules/programs/vscode.nix @@ -180,22 +180,24 @@ in { (map dropNullFields cfg.keybindings); })) (mkIf (cfg.extensions != [ ]) (let - combinedExtensionsDrv = pkgs.buildEnv { - name = "vscode-extensions"; - paths = cfg.extensions; - }; - - extensionsFolder = "${combinedExtensionsDrv}/share/vscode/extensions"; + subDir = "share/vscode/extensions"; # Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2 - addSymlinkToExtension = k: { - "${extensionPath}/${k}".source = "${extensionsFolder}/${k}"; - }; - extensions = builtins.attrNames (builtins.readDir extensionsFolder); + toPaths = ext: + map (k: { "${extensionPath}/${k}".source = "${ext}/${subDir}/${k}"; }) + (if ext ? vscodeExtUniqueId then + [ ext.vscodeExtUniqueId ] + else + builtins.attrNames (builtins.readDir (ext + "/${subDir}"))); in if cfg.mutableExtensionsDir then - mkMerge (map addSymlinkToExtension extensions) + mkMerge (concatMap toPaths cfg.extensions) else { - "${extensionPath}".source = extensionsFolder; + "${extensionPath}".source = let + combinedExtensionsDrv = pkgs.buildEnv { + name = "vscode-extensions"; + paths = cfg.extensions; + }; + in "${combinedExtensionsDrv}/${subDir}"; })) ]; };