biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / graphics / pdfcpu / default.nix
blob2613304b17c237dcf23205087752200769ec0f09
1 { lib, buildGoModule, fetchFromGitHub }:
3 buildGoModule rec {
4   pname = "pdfcpu";
5   version = "0.7.0";
7   src = fetchFromGitHub {
8     owner = "pdfcpu";
9     repo = pname;
10     rev = "v${version}";
11     hash = "sha256-FzlukSQSKeQY6H53UfWXwL8bXkOXRhaA92/Kgxh4oms=";
12     # Apparently upstream requires that the compiled executable will know the
13     # commit hash and the date of the commit. This information is also presented
14     # in the output of `pdfcpu version` which we use as a sanity check in the
15     # installCheckPhase. This was discussed upstream in:
16     #
17     # - https://github.com/pdfcpu/pdfcpu/issues/751
18     # - https://github.com/pdfcpu/pdfcpu/pull/752
19     #
20     # The trick used here is to write that information into files in `src`'s
21     # `$out`, and then read them into the `ldflags`. We also delete the `.git`
22     # directories in `src`'s $out afterwards, imitating what's done if
23     # `leaveDotGit = false;` See also:
24     # https://github.com/NixOS/nixpkgs/issues/8567
25     leaveDotGit = true;
26     postFetch = ''
27       cd "$out"
28       git rev-parse HEAD > $out/COMMIT
29       git log -1 --pretty=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ' > $out/SOURCE_DATE
30       find "$out" -name .git -print0 | xargs -0 rm -rf
31     '';
32   };
34   vendorHash = "sha256-jVX/CFf9dd9qD3gyGVDjbfINtPLCsgdjWFix4BCpDZ0=";
36   ldflags = [
37     "-s"
38     "-w"
39     "-X main.version=v${version}"
40   ];
42   # ldflags based on metadata from git and source
43   preBuild = ''
44     ldflags+=" -X main.commit=$(cat COMMIT)"
45     ldflags+=" -X main.date=$(cat SOURCE_DATE)"
46   '';
49   # No tests
50   doCheck = false;
51   doInstallCheck = true;
52   installCheckPhase = ''
53     export HOME=$(mktemp -d)
54     echo checking the version print of pdfcpu
55     $out/bin/pdfcpu version | grep ${version}
56     $out/bin/pdfcpu version | grep $(cat COMMIT | cut -c1-8)
57     $out/bin/pdfcpu version | grep $(cat SOURCE_DATE)
58   '';
60   subPackages = [ "cmd/pdfcpu" ];
62   meta = with lib; {
63     description = "A PDF processor written in Go";
64     homepage = "https://pdfcpu.io";
65     license = licenses.asl20;
66     maintainers = with maintainers; [ doronbehar ];
67     mainProgram = "pdfcpu";
68   };