1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 rustPlatform,
6 makeWrapper,
7 chromium,
8 withChromium ? (lib.meta.availableOn stdenv.hostPlatform chromium),
9 nix-update-script,
10}:
11
12rustPlatform.buildRustPackage (finalAttrs: {
13 pname = "html2pdf";
14 version = "0.8.2";
15
16 src = fetchFromGitHub {
17 owner = "ilaborie";
18 repo = "html2pdf";
19 tag = "v${finalAttrs.version}";
20 hash = "sha256-Z1fb7pDjawMIhJgl4ao2VoV6zpfcGy/48Dt7JtIxgJo=";
21 };
22
23 cargoHash = "sha256-T5A2b7Qcg8dQKndaD8P5RAutBZeINOqIBUHR2VDOeo0=";
24
25 # Avoiding "rustfmt not found" error in auto_generate_cdp.
26 # ref: https://github.com/mdrokz/auto_generate_cdp/pull/8
27 env.DO_NOT_FORMAT = "true";
28
29 nativeBuildInputs = [
30 makeWrapper
31 ];
32
33 postInstall = lib.optionalString withChromium (
34 let
35 runtimeInputs = [
36 chromium
37 ];
38 in
39 ''
40 wrapProgram "$out/bin/html2pdf" --prefix PATH : '${lib.makeBinPath runtimeInputs}'
41 ''
42 );
43
44 passthru.updateScript = nix-update-script { };
45
46 meta = {
47 description = "CLI tool to convert local HTML files to PDF";
48 homepage = "https://github.com/ilaborie/html2pdf";
49 changelog = "https://github.com/ilaborie/html2pdf/blob/v${finalAttrs.version}/CHANGELOG.md";
50 license = with lib.licenses; [
51 mit
52 asl20
53 ];
54 maintainers = with lib.maintainers; [
55 kachick
56 ];
57 mainProgram = "html2pdf";
58 };
59})