2021-01-15 22:18:51 +00:00
|
|
|
{ stdenv, fetchFromGitHub, fetchpatch, lib, enableUnfree ? false }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "p7zip";
|
2021-04-08 16:26:57 +00:00
|
|
|
version = "17.04";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-07-14 22:03:04 +00:00
|
|
|
owner = "jinfeihan57";
|
2020-06-18 07:06:33 +00:00
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-03-30 09:31:56 +00:00
|
|
|
sha256 = {
|
|
|
|
free = "sha256-DrBuf2VPdcprHI6pMSmL7psm2ofOrUf0Oj0qwMjXzkk=";
|
|
|
|
unfree = "sha256-19F4hPV0nKVuFZNbOcXrcA1uW6Y3HQolaHVIYXGmh18=";
|
|
|
|
}.${if enableUnfree then "unfree" else "free"};
|
|
|
|
# remove the unRAR related code from the src drv
|
|
|
|
# > the license requires that you agree to these use restrictions,
|
|
|
|
# > or you must remove the software (source and binary) from your hard disks
|
|
|
|
# https://fedoraproject.org/wiki/Licensing:Unrar
|
|
|
|
extraPostFetch = lib.optionalString (!enableUnfree) ''
|
|
|
|
rm -r $out/CPP/7zip/Compress/Rar*
|
|
|
|
find $out -name makefile'*' -exec sed -i '/Rar/d' {} +
|
|
|
|
'';
|
2021-01-15 22:18:51 +00:00
|
|
|
};
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Default makefile is full of impurities on Darwin. The patch doesn't hurt Linux so I'm leaving it unconditional
|
|
|
|
postPatch = ''
|
|
|
|
sed -i '/CC=\/usr/d' makefile.macosx_llvm_64bits
|
2021-10-09 14:59:57 +00:00
|
|
|
# Avoid writing timestamps into compressed manpages
|
|
|
|
# to maintain determinism.
|
|
|
|
substituteInPlace install.sh --replace 'gzip' 'gzip -n'
|
2020-08-20 17:08:02 +00:00
|
|
|
chmod +x install.sh
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# I think this is a typo and should be CXX? Either way let's kill it
|
|
|
|
sed -i '/XX=\/usr/d' makefile.macosx_llvm_64bits
|
2021-01-15 22:18:51 +00:00
|
|
|
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace makefile.machine \
|
|
|
|
--replace 'CC=gcc' 'CC=${stdenv.cc.targetPrefix}gcc' \
|
|
|
|
--replace 'CXX=g++' 'CXX=${stdenv.cc.targetPrefix}g++'
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
makeFlags = [ "DEST_HOME=${placeholder "out"}" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
2021-01-15 22:18:51 +00:00
|
|
|
buildFlags=all3
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
cp makefile.macosx_llvm_64bits makefile.machine
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
|
|
|
meta = with lib; {
|
2021-07-14 22:03:04 +00:00
|
|
|
homepage = "https://github.com/jinfeihan57/p7zip";
|
2020-06-18 07:06:33 +00:00
|
|
|
description = "A new p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/)";
|
2022-03-30 09:31:56 +00:00
|
|
|
license = with licenses;
|
|
|
|
# p7zip code is largely lgpl2Plus
|
|
|
|
# CPP/7zip/Compress/LzfseDecoder.cpp is bsd3
|
|
|
|
[ lgpl2Plus /* and */ bsd3 ] ++
|
|
|
|
# and CPP/7zip/Compress/Rar* are unfree with the unRAR license restriction
|
|
|
|
# the unRAR compression code is disabled by default
|
|
|
|
lib.optionals enableUnfree [ unfree ];
|
|
|
|
maintainers = with maintainers; [ raskin jk ];
|
|
|
|
platforms = platforms.unix;
|
2021-05-03 20:48:10 +00:00
|
|
|
mainProgram = "7z";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|