Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv 2, fetchurl 3, buildPackages 4, pkg-config 5, glib 6, gpm 7, file 8, e2fsprogs 9, libICE 10, perl 11, zip 12, unzip 13, gettext 14, slang 15, libssh2 16, openssl 17, coreutils 18, autoSignDarwinBinariesHook 19, x11Support ? true, libX11 20 21# updater only 22, writeScript 23}: 24 25stdenv.mkDerivation rec { 26 pname = "mc"; 27 version = "4.8.29"; 28 29 src = fetchurl { 30 url = "https://www.midnight-commander.org/downloads/${pname}-${version}.tar.xz"; 31 sha256 = "sha256-AdijuU9YGAzKW/FyV7UHjR/W/SeptcDpcOx2dUlUCtQ="; 32 }; 33 34 nativeBuildInputs = [ pkg-config unzip ] 35 # The preFixup hook rewrites the binary, which invaliates the code 36 # signature. Add the fixup hook to sign the output. 37 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 38 autoSignDarwinBinariesHook 39 ]; 40 41 buildInputs = [ 42 file 43 gettext 44 glib 45 libICE 46 libssh2 47 openssl 48 slang 49 zip 50 ] ++ lib.optionals x11Support [ libX11 ] 51 ++ lib.optionals (!stdenv.isDarwin) [ e2fsprogs gpm ]; 52 53 enableParallelBuilding = true; 54 55 configureFlags = [ 56 # used for vfs helpers at run time: 57 "PERL=${perl}/bin/perl" 58 # used for .hlp generation at build time: 59 "PERL_FOR_BUILD=${buildPackages.perl}/bin/perl" 60 61 # configure arguments have a bunch of build-only dependencies. 62 # Avoid their retention in final closure. 63 "--disable-configure-args" 64 ]; 65 66 postPatch = '' 67 substituteInPlace src/filemanager/ext.c \ 68 --replace /bin/rm ${coreutils}/bin/rm 69 ''; 70 71 postFixup = lib.optionalString ((!stdenv.isDarwin) && x11Support) '' 72 # libX11.so is loaded dynamically so autopatch doesn't detect it 73 patchelf \ 74 --add-needed ${libX11}/lib/libX11.so \ 75 $out/bin/mc 76 ''; 77 78 passthru.updateScript = writeScript "update-mc" '' 79 #!/usr/bin/env nix-shell 80 #!nix-shell -i bash -p curl pcre common-updater-scripts 81 82 set -eu -o pipefail 83 84 # Expect the text in format of "Current version is: 4.8.27; ...". 85 new_version="$(curl -s https://midnight-commander.org/ | pcregrep -o1 'Current version is: (([0-9]+\.?)+);')" 86 update-source-version mc "$new_version" 87 ''; 88 89 meta = with lib; { 90 description = "File Manager and User Shell for the GNU Project, known as Midnight Commander"; 91 downloadPage = "https://www.midnight-commander.org/downloads/"; 92 homepage = "https://www.midnight-commander.org"; 93 license = licenses.gpl2Plus; 94 maintainers = with maintainers; [ sander ]; 95 platforms = with platforms; linux ++ darwin; 96 }; 97}