@@ -8,7 +8,18 @@ stdenv.mkDerivation rec {
88 owner = "jinfeihan57";
99 repo = pname;
1010 rev = "v${version}";
11− sha256 = "sha256-19F4hPV0nKVuFZNbOcXrcA1uW6Y3HQolaHVIYXGmh18=";
11+ sha256 = {
12+ free = "sha256-DrBuf2VPdcprHI6pMSmL7psm2ofOrUf0Oj0qwMjXzkk=";
13+ unfree = "sha256-19F4hPV0nKVuFZNbOcXrcA1uW6Y3HQolaHVIYXGmh18=";
14+ }.${if enableUnfree then "unfree" else "free"};
15+ # remove the unRAR related code from the src drv
16+ # > the license requires that you agree to these use restrictions,
17+ # > or you must remove the software (source and binary) from your hard disks
18+ # https://fedoraproject.org/wiki/Licensing:Unrar
19+ extraPostFetch = lib.optionalString (!enableUnfree) ''
20+ rm -r $out/CPP/7zip/Compress/Rar*
21+ find $out -name makefile'*' -exec sed -i '/Rar/d' {} +
22+ '';
1223 };
1324
1425 # Default makefile is full of impurities on Darwin. The patch doesn't hurt Linux so I'm leaving it unconditional
@@ -25,11 +36,6 @@ stdenv.mkDerivation rec {
2536 substituteInPlace makefile.machine \
2637 --replace 'CC=gcc' 'CC=${stdenv.cc.targetPrefix}gcc' \
2738 --replace 'CXX=g++' 'CXX=${stdenv.cc.targetPrefix}g++'
28− '' + lib.optionalString (!enableUnfree) ''
29− # Remove non-free RAR source code
30− # (see DOC/License.txt, https://fedoraproject.org/wiki/Licensing:Unrar)
31− rm -r CPP/7zip/Compress/Rar*
32− find . -name makefile'*' -exec sed -i '/Rar/d' {} +
3339 '';
3440
3541 makeFlags = [ "DEST_HOME=${placeholder "out"}" ];
@@ -46,13 +52,20 @@ stdenv.mkDerivation rec {
4652
4753 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=c++11-narrowing";
4854
49− meta = {
55+ passthru.updateScript = ./update.sh;
56+
57+ meta = with lib; {
5058 homepage = "https://github.com/jinfeihan57/p7zip";
5159 description = "A new p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/)";
52− platforms = lib.platforms.unix;
53− maintainers = [ lib.maintainers.raskin ];
60+ license = with licenses;
61+ # p7zip code is largely lgpl2Plus
62+ # CPP/7zip/Compress/LzfseDecoder.cpp is bsd3
63+ [ lgpl2Plus /* and */ bsd3 ] ++
64+ # and CPP/7zip/Compress/Rar* are unfree with the unRAR license restriction
65+ # the unRAR compression code is disabled by default
66+ lib.optionals enableUnfree [ unfree ];
67+ maintainers = with maintainers; [ raskin jk ];
68+ platforms = platforms.unix;
5469 mainProgram = "7z";
55− # RAR code is under non-free UnRAR license, but we remove it
56− license = if enableUnfree then lib.licenses.unfree else lib.licenses.lgpl2Plus;
5770 };
5871}