Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 98 lines 3.0 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 enableUnfree ? false, 6}: 7 8stdenv.mkDerivation (finalAttrs: { 9 pname = "p7zip"; 10 version = "17.06"; 11 12 src = fetchFromGitHub { 13 owner = "p7zip-project"; 14 repo = "p7zip"; 15 rev = "v${finalAttrs.version}"; 16 sha256 = 17 { 18 free = "sha256-NHlacZFal4xMYyFMshibeAw86cS1RXXyXweXKFHQAT8="; 19 unfree = "sha256-kSJHgnuUxO9DJwSOE1hffp9PfU39V+VE87I3CpeRGiY="; 20 } 21 .${if enableUnfree then "unfree" else "free"}; 22 # remove the unRAR related code from the src drv 23 # > the license requires that you agree to these use restrictions, 24 # > or you must remove the software (source and binary) from your hard disks 25 # https://fedoraproject.org/wiki/Licensing:Unrar 26 postFetch = lib.optionalString (!enableUnfree) '' 27 rm -r $out/CPP/7zip/Compress/Rar* 28 find $out -name makefile'*' -exec sed -i '/Rar/d' {} + 29 ''; 30 }; 31 32 # Default makefile is full of impurities on Darwin. The patch doesn't hurt Linux so I'm leaving it unconditional 33 postPatch = '' 34 sed -i '/CC=\/usr/d' makefile.macosx_llvm_64bits 35 # Avoid writing timestamps into compressed manpages 36 # to maintain determinism. 37 substituteInPlace install.sh --replace 'gzip' 'gzip -n' 38 chmod +x install.sh 39 40 # I think this is a typo and should be CXX? Either way let's kill it 41 sed -i '/XX=\/usr/d' makefile.macosx_llvm_64bits 42 '' 43 + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' 44 substituteInPlace makefile.machine \ 45 --replace 'CC=gcc' 'CC=${stdenv.cc.targetPrefix}gcc' \ 46 --replace 'CXX=g++' 'CXX=${stdenv.cc.targetPrefix}g++' 47 ''; 48 49 preConfigure = '' 50 buildFlags=all3 51 '' 52 + lib.optionalString stdenv.hostPlatform.isDarwin '' 53 cp makefile.macosx_llvm_64bits makefile.machine 54 ''; 55 56 enableParallelBuilding = true; 57 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing"; 58 59 makeFlags = [ 60 "DEST_BIN=${placeholder "out"}/bin" 61 "DEST_SHARE=${placeholder "lib"}/lib/p7zip" 62 "DEST_MAN=${placeholder "man"}/share/man" 63 "DEST_SHARE_DOC=${placeholder "doc"}/share/doc/p7zip" 64 ]; 65 66 outputs = [ 67 "out" 68 "lib" 69 "doc" 70 "man" 71 ]; 72 73 setupHook = ./setup-hook.sh; 74 passthru.updateScript = ./update.sh; 75 76 meta = with lib; { 77 homepage = "https://github.com/p7zip-project/p7zip"; 78 description = "New p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/)"; 79 license = 80 with licenses; 81 # p7zip code is largely lgpl2Plus 82 # CPP/7zip/Compress/LzfseDecoder.cpp is bsd3 83 [ 84 lgpl2Plus # and 85 bsd3 86 ] 87 ++ 88 # and CPP/7zip/Compress/Rar* are unfree with the unRAR license restriction 89 # the unRAR compression code is disabled by default 90 lib.optionals enableUnfree [ unfree ]; 91 maintainers = with maintainers; [ 92 raskin 93 jk 94 ]; 95 platforms = platforms.unix; 96 mainProgram = "7z"; 97 }; 98})