nixpkgs/pkgs/by-name/ma/mailcap/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

58 lines
1.5 KiB
Nix

{ 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;
};
}