about summary refs log tree commit diff
path: root/pkgs/by-name/by/byobu/package.nix
blob: bf6896f3153ae39b2cc22459d0cafac9821c40d2 (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
92
93
94
95
96
97
98
{ lib
, autoreconfHook
, bc
, fetchFromGitHub
, gettext
, makeWrapper
, perl
, python3
, screen
, stdenv
, vim
, tmux
}:

let
  pythonEnv = python3.withPackages (ps: with ps; [ snack ]);
in
stdenv.mkDerivation (finalAttrs: {
  pname = "byobu";
  version = "6.12";

  src = fetchFromGitHub {
    owner = "dustinkirkland";
    repo = "byobu";
    rev = finalAttrs.version;
    hash = "sha256-NzC9Njsnz14mfKnERGDZw8O3vux0wnfCKwjUeTBQswc=";
  };

  nativeBuildInputs = [
    autoreconfHook
    gettext
    makeWrapper
  ];

  buildInputs = [
    perl # perl is needed for `lib/byobu/include/*` scripts
    screen
    tmux
  ];

  doCheck = true;
  strictDeps = true;

  postPatch = ''
    for file in usr/bin/byobu-export.in usr/lib/byobu/menu; do
      substituteInPlace $file \
        --replace "gettext" "${gettext}/bin/gettext"
    done
  '';

  postInstall = ''
    # By some reason the po files are not being compiled
    for po in po/*.po; do
      lang=''${po#po/}
      lang=''${lang%.po}
      # Path where byobu looks for translations, as observed in the source code
      # and strace
      mkdir -p $out/share/byobu/po/$lang/LC_MESSAGES/
      msgfmt --verbose $po -o $out/share/byobu/po/$lang/LC_MESSAGES/byobu.mo
    done

    # Override the symlinks, otherwise they mess with the wrapping
    cp --remove-destination $out/bin/byobu $out/bin/byobu-screen
    cp --remove-destination $out/bin/byobu $out/bin/byobu-tmux

    for file in $out/bin/byobu*; do
      # We don't use the usual "-wrapped" suffix because arg0 within the shebang
      # scripts points to the filename and byobu matches against this to know
      # which backend to start with
      bname="$(basename $file)"
      mv "$file" "$out/bin/.$bname"
      makeWrapper "$out/bin/.$bname" "$out/bin/$bname" \
        --argv0 $bname \
        --prefix PATH ":" "$out/bin" \
        --set BYOBU_PATH ${lib.makeBinPath [ vim bc ]} \
        --set BYOBU_PYTHON "${pythonEnv}/bin/python"
    done
  '';

  meta = {
    homepage = "https://www.byobu.org/";
    description = "Text-based window manager and terminal multiplexer";
    longDescription = ''
      Byobu is a text-based window manager and terminal multiplexer. It was
      originally designed to provide elegant enhancements to the otherwise
      functional, plain, practical GNU Screen, for the Ubuntu server
      distribution. Byobu now includes an enhanced profiles, convenient
      keybindings, configuration utilities, and toggle-able system status
      notifications for both the GNU Screen window manager and the more modern
      Tmux terminal multiplexer, and works on most Linux, BSD, and Mac
      distributions.
    '';
    license = with lib.licenses; [ gpl3Plus ];
    mainProgram = "byobu";
    maintainers = with lib.maintainers; [ AndersonTorres ];
    platforms = lib.platforms.unix;
  };
})