mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
96 lines
3.1 KiB
Nix
96 lines
3.1 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchurl,
|
|
buildPackages,
|
|
autoconf,
|
|
automake,
|
|
zlib,
|
|
libgnurx,
|
|
updateAutotoolsGnuConfigScriptsHook,
|
|
testers,
|
|
}:
|
|
|
|
# Note: this package is used for bootstrapping fetchurl, and thus
|
|
# cannot use fetchpatch! All mutable patches (generated by GitHub or
|
|
# cgit) that are needed here should be included directly in Nixpkgs as
|
|
# files.
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "file";
|
|
version = "5.47";
|
|
|
|
src = fetchurl {
|
|
urls = [
|
|
"https://astron.com/pub/file/file-${finalAttrs.version}.tar.gz"
|
|
"https://distfiles.macports.org/file/file-${finalAttrs.version}.tar.gz"
|
|
];
|
|
hash = "sha256-RWcv7BZctMwTWKLXa11X0ih23Ll6sWlCesOFy+HVWXo=";
|
|
};
|
|
|
|
outputs = [
|
|
"out"
|
|
"dev"
|
|
"man"
|
|
];
|
|
|
|
patches = [
|
|
# Fixes `cat archive.zip | file -` just showing a generic "data" type. See:
|
|
# - https://bugs.astron.com/view.php?id=764
|
|
# - https://github.com/file/file/commit/12b76648185104ce9118d8b5fa57aa34a77ad084
|
|
# Vendored patch because using fetchpatch is impossible for a package in
|
|
# this part of the bootstrap chain.
|
|
./0001-PR-745-streamout-Don-t-flush-when-trying-to-set-nega.patch
|
|
# Fixes breakage of python3Packages.python-magic and xdg-utils
|
|
./0002-PR-725-inliniac-Revert-previous-and-always-set-offse.patch
|
|
|
|
# Splits byteswapping functions into a separate file & reuses them across the codebase
|
|
# (needed for GUID parsing fix below)
|
|
# https://github.com/file/file/commit/797a275514c80303accbd821df9692b04f6020e6
|
|
# https://github.com/file/file/commit/2866af2e51beb40afe35d2ff5e765991ac459237
|
|
./0003-Add-LE-BE-GUID.patch
|
|
|
|
# Fixes GUID parsing on big-endian
|
|
# https://github.com/file/file/commit/7a2b2a4b6e0f9de8682e6098c514155f2198cc8e
|
|
./0004-Handle-parsing-guids-in-big-endian-machines.patch
|
|
];
|
|
|
|
strictDeps = true;
|
|
enableParallelBuilding = true;
|
|
|
|
nativeBuildInputs = [
|
|
# 0003-Add-LE-BE-GUID.patch touches automake file, need to regenerate files
|
|
# autoreconfHook would cause inf rec (hook -> libtool -> file -> hook), adding the individual components we need
|
|
autoconf
|
|
automake
|
|
|
|
updateAutotoolsGnuConfigScriptsHook
|
|
];
|
|
buildInputs = [ zlib ] ++ lib.optional stdenv.hostPlatform.isMinGW libgnurx;
|
|
|
|
# 0003-Add-LE-BE-GUID.patch touches automake file, need to regenerate files
|
|
# autoreconfHook would cause inf rec (hook -> libtool -> file -> hook), manually calling autoreconf
|
|
preConfigure = ''
|
|
autoreconf
|
|
'';
|
|
|
|
# https://bugs.astron.com/view.php?id=382
|
|
doCheck = !stdenv.buildPlatform.isMusl;
|
|
|
|
# In native builds, it will use the newly-compiled file instead.
|
|
makeFlags = lib.optional (
|
|
!lib.systems.equals stdenv.hostPlatform stdenv.buildPlatform
|
|
) "FILE_COMPILE=${lib.getExe buildPackages.file}";
|
|
|
|
passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
|
|
meta = {
|
|
homepage = "https://darwinsys.com/file";
|
|
description = "Program that shows the type of files";
|
|
maintainers = with lib.maintainers; [ doronbehar ];
|
|
license = lib.licenses.bsd2;
|
|
pkgConfigModules = [ "libmagic" ];
|
|
platforms = lib.platforms.all;
|
|
mainProgram = "file";
|
|
};
|
|
})
|