about summary refs log tree commit diff
path: root/pkgs/applications/window-managers/i3/default.nix
blob: a4eb850f9390d919fe45f8a569a67b6f7398c00f (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
{ fetchurl, stdenv, which, pkgconfig, makeWrapper, libxcb, xcbutilkeysyms
, xcbutil, xcbutilwm, xcbutilxrm, libstartup_notification, libX11, pcre, libev
, yajl, xcb-util-cursor, coreutils, perl, pango, perlPackages, libxkbcommon
, xorgserver, xvfb_run, symlinkJoin, configFile ? null }:

let
  version = "4.13";

  i3 = stdenv.mkDerivation rec {
    name = "i3-${version}";

    src = fetchurl {
      url = "http://i3wm.org/downloads/${name}.tar.bz2";
      sha256 = "12ngz32swh9n85xy0cz1lq16aqi9ys5hq19v589q9a97wn1k3hcl";
    };

    nativeBuildInputs = [ which pkgconfig makeWrapper ];

    buildInputs = [
      libxcb xcbutilkeysyms xcbutil xcbutilwm xcbutilxrm libxkbcommon
      libstartup_notification libX11 pcre libev yajl xcb-util-cursor perl pango
      perlPackages.AnyEventI3 perlPackages.X11XCB perlPackages.IPCRun
      perlPackages.ExtUtilsPkgConfig perlPackages.TestMore perlPackages.InlineC
      xorgserver xvfb_run
    ];

    configureFlags = [ "--disable-builddir" ];

    enableParallelBuilding = true;

    postPatch = ''
      patchShebangs .
    '';

    # Tests have been failing (at least for some people in some cases)
    # and have been disabled until someone wants to fix them. Some
    # initial digging uncovers that the tests call out to `git`, which
    # they shouldn't, and then even once that's fixed have some
    # perl-related errors later on. For more, see
    # https://github.com/NixOS/nixpkgs/issues/7957
    doCheck = false; # stdenv.system == "x86_64-linux";

    checkPhase = stdenv.lib.optionalString (stdenv.system == "x86_64-linux")
    ''
      (cd testcases && xvfb-run ./complete-run.pl -p 1 --keep-xserver-output)
      ! grep -q '^not ok' testcases/latest/complete-run.log
    '';

    postInstall = ''
      wrapProgram "$out/bin/i3-save-tree" --prefix PERL5LIB ":" "$PERL5LIB"
      for program in $out/bin/i3-sensible-*; do
        sed -i 's/which/command -v/' $program
      done
    '';

    separateDebugInfo = true;

    meta = with stdenv.lib; {
      description = "A tiling window manager";
      homepage    = "http://i3wm.org";
      maintainers = with maintainers; [ garbas modulistic fpletz ];
      license     = licenses.bsd3;
      platforms   = platforms.all;

      longDescription = ''
        A tiling window manager primarily targeted at advanced users and
        developers. Based on a tree as data structure, supports tiling,
        stacking, and tabbing layouts, handled dynamically, as well as
        floating windows. Configured via plain text file. Multi-monitor.
        UTF-8 clean.
      '';
    };

  };
in if configFile == null then i3 else symlinkJoin {
  name = "i3-with-config-${version}";
  paths = [ i3 ];

  buildInputs = [ makeWrapper ];

  postBuild = ''
      wrapProgram $out/bin/i3 \
      --add-flags "-c ${configFile}"
  '';
}