about summary refs log tree commit diff
path: root/pkgs/data/misc/mailcap/default.nix
blob: 452e6f661abf5d5991251e48ff901ad3de771ae9 (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
{ lib
, stdenv
, fetchurl
, nixosTests

# updater
, git
, coreutils
, gawk
, gnused
, writeScript
, nix-update
}:

stdenv.mkDerivation rec {
  pname = "mailcap";
  version = "2.1.54";

  src = fetchurl {
    url = "https://releases.pagure.org/mailcap/mailcap-${version}.tar.xz";
    hash = "sha256-mkAyIC/A0rCFj0GxZzianP5SrCTsKC5kebkHZTGd4RM=";
  };

  installPhase = ''
    runHook preInstall

    substituteInPlace mailcap --replace "/usr/bin/" ""
    sh generate-nginx-mimetypes.sh < mime.types > nginx-mime.types

    install -D -m0644 nginx-mime.types $out/etc/nginx/mime.types
    install -D -m0644 -t $out/etc mailcap mime.types
    install -D -m0644 -t $out/share/man/man5 mailcap.5

    runHook postInstall
  '';

  passthru.updateScript = writeScript "update-mailcap" ''
    export PATH=${lib.makeBinPath [ git coreutils gawk gnused nix-update ]}:$PATH
    VERSION="$(git ls-remote --tags --sort="v:refname" https://pagure.io/mailcap.git | \
      awk '{ print $2 }' | \
      grep "refs/tags/r" | \
      sed -E -e "s,refs/tags/r(.*)$,\1," -e "s/-/./g" | \
      sort --version-sort --reverse | \
      head -n1)"
    exec nix-update --version "$VERSION" "$@"
  '';

  passthru.tests.nginx-mime = nixosTests.nginx-mime;

  meta = with lib; {
    description = "Helper application and MIME type associations for file types";
    homepage = "https://pagure.io/mailcap";
    license = licenses.mit;
    maintainers = with maintainers; [ c0bw3b ];
    platforms = platforms.all;
  };
}