mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
571c71e6f7
We are migrating packages that meet below requirements: 1. using `callPackage` 2. called path is a directory 3. overriding set is empty (`{ }`) 4. not containing path expressions other than relative path (to makenixpkgs-vet happy) 5. not referenced by nix files outside of the directory, other than`pkgs/top-level/all-packages.nix` 6. not referencing nix files outside of the directory 7. not referencing `default.nix` (since it's changed to `package.nix`) 8. `outPath` doesn't change after migration The tool is here: https://github.com/Aleksanaa/by-name-migrate.
70 lines
2.1 KiB
Nix
70 lines
2.1 KiB
Nix
{ lib, buildGoModule, fetchFromGitHub }:
|
|
|
|
buildGoModule rec {
|
|
pname = "pdfcpu";
|
|
version = "0.9.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "pdfcpu";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
hash = "sha256-PJTEaWU/erqVJakvxfB0aYRsi/tcGxYYZjCdEvThmzM=";
|
|
# Apparently upstream requires that the compiled executable will know the
|
|
# commit hash and the date of the commit. This information is also presented
|
|
# in the output of `pdfcpu version` which we use as a sanity check in the
|
|
# installCheckPhase. This was discussed upstream in:
|
|
#
|
|
# - https://github.com/pdfcpu/pdfcpu/issues/751
|
|
# - https://github.com/pdfcpu/pdfcpu/pull/752
|
|
#
|
|
# The trick used here is to write that information into files in `src`'s
|
|
# `$out`, and then read them into the `ldflags`. We also delete the `.git`
|
|
# directories in `src`'s $out afterwards, imitating what's done if
|
|
# `leaveDotGit = false;` See also:
|
|
# https://github.com/NixOS/nixpkgs/issues/8567
|
|
leaveDotGit = true;
|
|
postFetch = ''
|
|
cd "$out"
|
|
git rev-parse HEAD > $out/COMMIT
|
|
git log -1 --pretty=%cd --date=format:'%Y-%m-%dT%H:%M:%SZ' > $out/SOURCE_DATE
|
|
find "$out" -name .git -print0 | xargs -0 rm -rf
|
|
'';
|
|
};
|
|
|
|
vendorHash = "sha256-x5EXv2LkJg2LAdml+1I4MzgTvNo6Gl+6e6UHVQ+Z9rU=";
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X main.version=v${version}"
|
|
];
|
|
|
|
# ldflags based on metadata from git and source
|
|
preBuild = ''
|
|
ldflags+=" -X main.commit=$(cat COMMIT)"
|
|
ldflags+=" -X main.date=$(cat SOURCE_DATE)"
|
|
'';
|
|
|
|
|
|
# No tests
|
|
doCheck = false;
|
|
doInstallCheck = true;
|
|
installCheckPhase = ''
|
|
export HOME=$(mktemp -d)
|
|
echo checking the version print of pdfcpu
|
|
$out/bin/pdfcpu version | grep ${version}
|
|
$out/bin/pdfcpu version | grep $(cat COMMIT | cut -c1-8)
|
|
$out/bin/pdfcpu version | grep $(cat SOURCE_DATE)
|
|
'';
|
|
|
|
subPackages = [ "cmd/pdfcpu" ];
|
|
|
|
meta = with lib; {
|
|
description = "PDF processor written in Go";
|
|
homepage = "https://pdfcpu.io";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [ doronbehar ];
|
|
mainProgram = "pdfcpu";
|
|
};
|
|
}
|