summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/li/libpaper/package.nix
blob: 71c6f5326aebc02d29c6d5f198b7b99c3365f790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  lib,
  stdenv,
  fetchurl,
  autoreconfHook,
}:

stdenv.mkDerivation (finalAttrs: {
  version = "2.2.8";
  pname = "libpaper";

  src = fetchurl {
    url = "https://github.com/rrthomas/libpaper/releases/download/v${finalAttrs.version}/libpaper-${finalAttrs.version}.tar.gz";
    hash = "sha256-HjMFcWkBkYdOykFex2iJ3RG6uYh6IwLWo2Zc0IHE13s=";
  };

  nativeBuildInputs = [ autoreconfHook ];

  # The configure script of libpaper is buggy: it uses AC_SUBST on a headerfile
  # to compile sysconfdir into the library. Autoconf however defines sysconfdir
  # as "${prefix}/etc", which is not expanded by AC_SUBST so libpaper will look
  # for config files in (literally, without expansion) '${prefix}/etc'. Manually
  # setting sysconfdir fixes this issue.
  preConfigure = ''
    configureFlagsArray+=(
      "--sysconfdir=$out/etc"
    )
  '';

  # Set the default paper to letter (this is what libpaper uses as default as well,
  # if you call getdefaultpapername()).
  # The user can still override this with the PAPERCONF environment variable.
  postInstall = ''
    mkdir -p $out/etc
    echo letter > $out/etc/papersize
  '';

  meta = {
    changelog = "https://github.com/rrthomas/libpaper/releases/tag/v${finalAttrs.version}";
    description = "Library for handling paper characteristics";
    homepage = "https://github.com/rrthomas/libpaper";
    license = with lib.licenses; [
      gpl2Only
      gpl3Plus
      mit
      publicDomain
    ];
    platforms = lib.platforms.unix;
  };
})