about summary refs log tree commit diff
path: root/pkgs/applications/editors/poke/default.nix
blob: 36d35bc44dc1a020de3ff506a45a88ae484afcac (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{ lib
, stdenv
, fetchurl
, help2man
, pkg-config
, texinfo
, boehmgc
, readline
, nbdSupport ? !stdenv.isDarwin, libnbd
, textStylingSupport ? true, gettext
, dejagnu

  # update script only
, writeScript
}:

let
  isCross = stdenv.hostPlatform != stdenv.buildPlatform;
in
stdenv.mkDerivation (finalAttrs: {
  pname = "poke";
  version = "4.0";

  src = fetchurl {
    url = "mirror://gnu/poke/poke-${finalAttrs.version}.tar.gz";
    hash = "sha256-ArqyLLH6YVOhtqknyLs81Y1QhUPBRIQqbX7nTxmXOnc=";
  };

  outputs = [ "out" "dev" "info" "lib" ]
    # help2man can't cross compile because it runs `poke --help` to
    # generate the man page
    ++ lib.optional (!isCross) "man";

  postPatch = ''
    patchShebangs .
  '';

  strictDeps = true;

  nativeBuildInputs = [
    pkg-config
    texinfo
  ] ++ lib.optionals (!isCross) [
    help2man
  ];

  buildInputs = [ boehmgc readline ]
    ++ lib.optional nbdSupport libnbd
    ++ lib.optional textStylingSupport gettext
    ++ lib.optional finalAttrs.finalPackage.doCheck dejagnu;

  configureFlags = [
    # libpoke depends on $datadir/poke, so we specify the datadir in
    # $lib, and later move anything else it doesn't depend on to $out
    "--datadir=${placeholder "lib"}/share"
  ];

  enableParallelBuilding = true;

  doCheck = true;
  nativeCheckInputs = [ dejagnu ];

  postInstall = ''
    moveToOutput share/emacs "$out"
    moveToOutput share/vim "$out"
  '';

  passthru = {
    updateScript = writeScript "update-poke" ''
      #!/usr/bin/env nix-shell
      #!nix-shell -i bash -p curl pcre common-updater-scripts

      set -eu -o pipefail

      # Expect the text in format of '<a href="...">poke 2.0</a>'
      new_version="$(curl -s https://www.jemarch.net/poke |
          pcregrep -o1 '>poke ([0-9.]+)</a>')"
      update-source-version poke "$new_version"
    '';
  };

  meta = {
    description = "Interactive, extensible editor for binary data";
    homepage = "http://www.jemarch.net/poke";
    changelog = "https://git.savannah.gnu.org/cgit/poke.git/plain/ChangeLog?h=releases/poke-${finalAttrs.version}";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [ AndersonTorres kira-bruneau ];
    platforms = lib.platforms.unix;
    broken = stdenv.isDarwin && stdenv.isAarch64;
  };
})