summary refs log tree commit diff
path: root/pkgs/tools/X11/xdg-utils/default.nix
blob: 6f1335593621f5346ea5f4a610871c288069171c (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
{ stdenv, fetchzip, fetchFromGitHub, file, libxslt, docbook_xml_dtd_412, docbook_xsl, xmlto
, w3m, which, gnugrep, gnused, coreutils
, mimiSupport ? false, gawk ? null }:

assert mimiSupport -> gawk != null;

let
  # A much better xdg-open
  mimisrc = fetchFromGitHub {
    owner = "march-linux";
    repo = "mimi";
    rev = "d85ea8256ed627e93b387cd42e4ab39bfab9504c";
    sha256 = "1h9mb3glfvc6pa2f9g07xgmf8lrwxiyjxvl906xlysy4klybxvhg";
  };
in

stdenv.mkDerivation rec {
  name = "xdg-utils-1.1.0-rc3p46";

  src = fetchzip {
    name = "${name}.tar.gz";
    url = "http://cgit.freedesktop.org/xdg/xdg-utils/snapshot/03577f987730.tar.gz";
    sha256 = "1fs0kxalmpqv6x0rv4xg65w8r26sk464xisrbwp4p6a033y5x34l";
  };

  # just needed when built from git
  buildInputs = [ libxslt docbook_xml_dtd_412 docbook_xsl xmlto w3m ];

  postInstall = stdenv.lib.optionalString mimiSupport ''
    cp ${mimisrc}/xdg-open $out/bin/xdg-open
  ''
  + ''
    for tool in "${coreutils}/bin/cut" "${gnused}/bin/sed" \
      "${gnugrep}"/bin/{e,}grep "${file}/bin/file" \
      ${stdenv.lib.optionalString mimiSupport
        '' "${gawk}/bin/awk" "${coreutils}/bin/sort" ''} ;
    do
      sed "s# $(basename "$tool") # $tool #g" -i "$out"/bin/*
    done

    sed 's# which # type -P #g' -i "$out"/bin/*
  '';

  meta = with stdenv.lib; {
    homepage = http://portland.freedesktop.org/wiki/;
    description = "A set of command line tools that assist applications with a variety of desktop integration tasks";
    license = if mimiSupport then licenses.gpl2 else licenses.free;
    maintainers = [ maintainers.eelco ];
    platforms = platforms.all;
  };
}