nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchurl, file, zlib, libgnurx }:
2
3# Note: this package is used for bootstrapping fetchurl, and thus
4# cannot use fetchpatch! All mutable patches (generated by GitHub or
5# cgit) that are needed here should be included directly in Nixpkgs as
6# files.
7
8stdenv.mkDerivation rec {
9 pname = "file";
10 version = "5.44";
11
12 src = fetchurl {
13 urls = [
14 "https://astron.com/pub/file/${pname}-${version}.tar.gz"
15 "https://distfiles.macports.org/file/${pname}-${version}.tar.gz"
16 ];
17 sha256 = "sha256-N1HH+6jbyDHLjXzIr/IQNUWbjOUVXviwiAon0ChHXzs=";
18 };
19
20 outputs = [ "out" "dev" "man" ];
21
22 patches = [
23 # Backport fix to identification for pyzip files.
24 # Needed for strip-nondeterminism.
25 # https://salsa.debian.org/reproducible-builds/strip-nondeterminism/-/issues/20
26 ./pyzip.patch
27
28 # Backport fix for --uncompress always detecting contents as "empty"
29 (fetchurl {
30 url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-apps/file/files/file-5.44-decompress-empty.patch?h=dfc57da515a2aaf085bea68267cc727f1bfaa691";
31 hash = "sha256-fUzRQAlLWczBmR5iA1Gk66mHjP40MJcMdgCtm2+u1SQ=";
32 })
33 ];
34
35 strictDeps = true;
36 enableParallelBuilding = true;
37
38 nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
39 buildInputs = [ zlib ]
40 ++ lib.optional stdenv.hostPlatform.isWindows libgnurx;
41
42 # https://bugs.astron.com/view.php?id=382
43 doCheck = !stdenv.buildPlatform.isMusl;
44
45 makeFlags = lib.optional stdenv.hostPlatform.isWindows "FILE_COMPILE=file";
46
47 meta = with lib; {
48 homepage = "https://darwinsys.com/file";
49 description = "A program that shows the type of files";
50 maintainers = with maintainers; [ doronbehar ];
51 license = licenses.bsd2;
52 platforms = platforms.all;
53 };
54}