diff --git a/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/add-pandoc-to-path.patch b/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/add-pandoc-to-path.patch new file mode 100644 index 000000000000..5c048e5edf8b --- /dev/null +++ b/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/add-pandoc-to-path.patch @@ -0,0 +1,13 @@ +diff --git a/src/extension.ts b/src/extension.ts +index 49637fa..c48c655 100644 +--- a/src/extension.ts ++++ b/src/extension.ts +@@ -375,7 +375,7 @@ function renderDoc( + execFile( + command, + args, +- { cwd: filePath }, ++ { cwd: filePath, env: { ...process.env, PATH: process.env.PATH ? `${process.env.PATH}${path.delimiter}@pandocBin@` : "@pandocBin@" } }, + function (error, stdout, stderr) { + if (stdout !== null) { + pandocOutputChannel.append(stdout.toString() + "\n"); diff --git a/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/default.nix b/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/default.nix index b0e039616db7..decb180da80c 100644 --- a/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/default.nix +++ b/pkgs/applications/editors/vscode/extensions/chrischinchilla.vscode-pandoc/default.nix @@ -1,30 +1,70 @@ { lib, + stdenvNoCC, + fetchFromGitHub, + fetchNpmDeps, + nix-update-script, + nodejs, + npmHooks, + replaceVars, + vsce, vscode-utils, - jq, - moreutils, pandoc, }: -vscode-utils.buildVscodeMarketplaceExtension { - mktplcRef = { - name = "vscode-pandoc"; - publisher = "chrischinchilla"; - version = "0.7.3"; - hash = "sha256-TGkNYA96mzFtUoM+XPKXJ/AM+hbiLc6Lvk5YDxFUwcI="; +let + version = "0.7.3"; + src = stdenvNoCC.mkDerivation (finalAttrs: { + sourceName = "chrischinchilla-vscode-pandoc"; + name = "${finalAttrs.sourceName}-${finalAttrs.version}.vsix"; + pname = "${finalAttrs.sourceName}-vsix"; + inherit version; + src = fetchFromGitHub { + owner = "ChrisChinchilla"; + repo = "vscode-pandoc"; + tag = "v${finalAttrs.version}"; + hash = "sha256-tn3qQzbwjUnbuZtwCs4kXiGcrR/pTDECoHIirG/0WrU="; + }; + patches = [ + (replaceVars ./add-pandoc-to-path.patch { + pandocBin = lib.makeBinPath [ pandoc ]; + }) + ]; + npmDeps = fetchNpmDeps { + inherit (finalAttrs) src; + hash = "sha256-1j+bDx2CiViEgLfanyx0dwLRgY1aYV9rQDWP3nDl1Bw="; + }; + nativeBuildInputs = [ + nodejs + npmHooks.npmConfigHook + vsce + ]; + strictDeps = true; + __structuredAttrs = true; + dontConfigure = true; + buildPhase = '' + runHook preBuild + vsce package --no-dependencies --out $out + runHook postBuild + ''; + dontInstall = true; + }); +in +vscode-utils.buildVscodeExtension (finalAttrs: { + pname = "chrischinchilla-vscode-pandoc"; + inherit version src; + vscodeExtPublisher = "chrischinchilla"; + vscodeExtName = "vscode-pandoc"; + vscodeExtUniqueId = "${finalAttrs.vscodeExtPublisher}.${finalAttrs.vscodeExtName}"; + buildInputs = [ pandoc ]; # The Nix path scanner can't see into the VSIX. + passthru.updateScript = nix-update-script { + attrPath = "vscode-extensions.chrischinchilla.vscode-pandoc.src"; }; - nativeBuildInputs = [ - jq - moreutils - ]; - postInstall = '' - jq '.contributes.configuration.properties."pandoc.executable".default = "${lib.getExe pandoc}"' $out/$installPrefix/package.json | sponge $out/$installPrefix/package.json - ''; meta = { description = "Converts Markdown files to pdf, docx, or html files using pandoc"; homepage = "https://github.com/ChrisChinchilla/vscode-pandoc#readme"; - downloadPage = "https://marketplace.visualstudio.com/items?itemName=yzane.markdown-pdf"; + downloadPage = "https://marketplace.visualstudio.com/items?itemName=chrischinchilla.vscode-pandoc"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ pandapip1 ]; }; -} +})