diff --git a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix index e937da9c44b32..bcb076135ae14 100644 --- a/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix +++ b/pkgs/applications/editors/vscode/extensions/rust-lang.rust-analyzer/default.nix @@ -72,8 +72,7 @@ let }; in vscode-utils.buildVscodeExtension { - inherit version vsix; - name = "${pname}-${version}"; + inherit version vsix pname; src = "${vsix}/${pname}.zip"; vscodeExtUniqueId = "${publisher}.${pname}"; vscodeExtPublisher = publisher; diff --git a/pkgs/applications/editors/vscode/extensions/vscode-utils.nix b/pkgs/applications/editors/vscode/extensions/vscode-utils.nix index d457b156aa97e..ddf705e27e9cd 100644 --- a/pkgs/applications/editors/vscode/extensions/vscode-utils.nix +++ b/pkgs/applications/editors/vscode/extensions/vscode-utils.nix @@ -9,34 +9,36 @@ jq, }: let - buildVscodeExtension = - a@{ - name, - src, - # Same as "Unique Identifier" on the extension's web page. - # For the moment, only serve as unique extension dir. - vscodeExtPublisher, - vscodeExtName, - vscodeExtUniqueId, - configurePhase ? '' - runHook preConfigure - runHook postConfigure - '', - buildPhase ? '' - runHook preBuild - runHook postBuild - '', - dontPatchELF ? true, - dontStrip ? true, - nativeBuildInputs ? [ ], - passthru ? { }, - ... - }: - stdenv.mkDerivation ( - (removeAttrs a [ "vscodeExtUniqueId" ]) - // { - - name = "vscode-extension-${name}"; + buildVscodeExtension = lib.extendMkDerivation { + constructDrv = stdenv.mkDerivation; + excludeDrvArgNames = [ + "vscodeExtUniqueId" + ]; + extendDrvArgs = + finalAttrs: + { + pname ? null, # Only optional for backward compatibility. + # Same as "Unique Identifier" on the extension's web page. + # For the moment, only serve as unique extension dir. + vscodeExtPublisher, + vscodeExtName, + vscodeExtUniqueId, + configurePhase ? '' + runHook preConfigure + runHook postConfigure + '', + buildPhase ? '' + runHook preBuild + runHook postBuild + '', + dontPatchELF ? true, + dontStrip ? true, + nativeBuildInputs ? [ ], + passthru ? { }, + ... + }: + { + pname = "vscode-extension-${pname}"; passthru = passthru // { inherit vscodeExtPublisher vscodeExtName vscodeExtUniqueId; @@ -53,12 +55,12 @@ let # If other directories are present but `sourceRoot` is unset, the unpacker phase fails. sourceRoot = "extension"; + # This cannot be removed, it is used by some extensions. installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}"; nativeBuildInputs = [ unzip ] ++ nativeBuildInputs; installPhase = '' - runHook preInstall mkdir -p "$out/$installPrefix" @@ -66,36 +68,38 @@ let runHook postInstall ''; - } - ); + }; + }; fetchVsixFromVscodeMarketplace = mktplcExtRef: fetchurl (import ./mktplcExtRefToFetchArgs.nix mktplcExtRef); - buildVscodeMarketplaceExtension = - a@{ - name ? "", - src ? null, - vsix ? null, - mktplcRef, - ... - }: - assert "" == name; - assert null == src; - buildVscodeExtension ( - (removeAttrs a [ - "mktplcRef" - "vsix" - ]) - // { - name = "${mktplcRef.publisher}-${mktplcRef.name}-${mktplcRef.version}"; + buildVscodeMarketplaceExtension = lib.extendMkDerivation { + constructDrv = buildVscodeExtension; + excludeDrvArgNames = [ + "mktplcRef" + "vsix" + ]; + extendDrvArgs = + finalAttrs: + { + name ? "", + src ? null, + vsix ? null, + mktplcRef, + ... + }: + assert "" == name; + assert null == src; + { + pname = "${mktplcRef.publisher}-${mktplcRef.name}"; version = mktplcRef.version; src = if (vsix != null) then vsix else fetchVsixFromVscodeMarketplace mktplcRef; vscodeExtPublisher = mktplcRef.publisher; vscodeExtName = mktplcRef.name; vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}"; - } - ); + }; + }; mktplcRefAttrList = [ "name"