diff --git a/pkgs/by-name/vi/vivliostyle/0001-allow-specifying-browser-path-via-env-var.patch b/pkgs/by-name/vi/vivliostyle/0001-allow-specifying-browser-path-via-env-var.patch new file mode 100644 index 000000000000..7bde073218b0 --- /dev/null +++ b/pkgs/by-name/vi/vivliostyle/0001-allow-specifying-browser-path-via-env-var.patch @@ -0,0 +1,20 @@ +--- + src/browser.ts | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/browser.ts b/src/browser.ts +index 8e653e2..ae57d2f 100644 +--- a/src/browser.ts ++++ b/src/browser.ts +@@ -355,6 +355,8 @@ export async function getExecutableBrowserPath({ + type, + tag, + }: ResolvedTaskConfig['browser']): Promise { ++ const envPath = process.env.VIVLIOSTYLE_BROWSER_PATH; ++ if (envPath && fs.existsSync(envPath)) return envPath; + const browsers = await importNodeModule('@puppeteer/browsers'); + const buildId = await resolveBuildId({ type, tag, browsers }); + return browsers.computeExecutablePath({ +-- +2.54.0 + diff --git a/pkgs/by-name/vi/vivliostyle/package.nix b/pkgs/by-name/vi/vivliostyle/package.nix new file mode 100644 index 000000000000..ce6cc9feee04 --- /dev/null +++ b/pkgs/by-name/vi/vivliostyle/package.nix @@ -0,0 +1,99 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchPnpmDeps, + nix-update-script, + + # build-time + makeBinaryWrapper, + nodejs, + pnpmBuildHook, + pnpmConfigHook, + pnpm_10, + + chromium, + defaultBrowser ? chromium, +}: + +let + pnpm = pnpm_10; +in + +stdenv.mkDerivation (finalAttrs: { + pname = "vivliostyle"; + version = "11.1.0"; + + src = fetchFromGitHub { + owner = "vivliostyle"; + repo = "vivliostyle-cli"; + tag = "v${finalAttrs.version}"; + hash = "sha256-rbb/av3amlLit7OjTc+S/pf1SrxEnsENQOArgnc7k3s="; + }; + + patches = [ + ./0001-allow-specifying-browser-path-via-env-var.patch + ]; + + __structuredAttrs = true; + strictDeps = true; + + pnpmDeps = fetchPnpmDeps { + inherit (finalAttrs) pname version src; + inherit pnpm; + fetcherVersion = 4; + hash = "sha256-WPTCLAEWmD1TY84281TJCzp+mcjMFM5Xwf02s7U+M4U="; + }; + + nativeBuildInputs = [ + makeBinaryWrapper + nodejs + pnpm + pnpmBuildHook + pnpmConfigHook + ]; + + pnpmBuildFlags = [ + "--mode" + "production" + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib} + mv {node_modules,dist,examples,packages,package.json} $out/lib + + runHook postInstall + ''; + + postFixup = '' + chmod +x $out/lib/dist/cli.js + patchShebangs $out/usr/lib/dist/cli.js + + makeWrapper $out/lib/dist/cli.js $out/bin/vivliostyle \ + --prefix PATH : ${lib.makeBinPath [ nodejs ]} \ + --set VIVLIOSTYLE_BROWSER_PATH ${lib.getExe defaultBrowser} + + ln -s $out/bin/vivliostyle $out/bin/vs + ''; + + passthru = { + updateScript = nix-update-script { }; + }; + + meta = { + description = "CLI tool for typesetting HTML and Markdown documents"; + longDescription = '' + Vivliostyle is a CSS typesetting ecosystem for creating beautifully + formatted documents using web technologies. + ''; + homepage = "https://github.com/vivliostyle/vivliostyle-cli"; + changelog = "https://github.com/vivliostyle/vivliostyle-cli/blob/${finalAttrs.src.rev}/CHANGELOG.md"; + mainProgram = "vivliostyle"; + license = lib.licenses.agpl3Only; + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ eljamm ]; + teams = with lib.teams; [ ngi ]; + }; +})