2022-03-18 04:47:19 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
|
2021-11-14 19:27:00 +00:00
|
|
|
# Only used for Linux's x86/x86_64
|
2022-03-18 04:47:19 +00:00
|
|
|
, uasm
|
2021-11-14 19:27:00 +00:00
|
|
|
, useUasm ? (stdenv.isLinux && stdenv.hostPlatform.isx86)
|
2022-03-18 04:47:19 +00:00
|
|
|
|
|
|
|
# RAR code is under non-free unRAR license
|
|
|
|
# see the meta.license section below for more details
|
|
|
|
, enableUnfree ? false
|
2022-04-18 23:39:09 +00:00
|
|
|
|
|
|
|
# For tests
|
|
|
|
, _7zz
|
2022-04-20 14:40:48 +00:00
|
|
|
, testers
|
2022-03-18 04:47:19 +00:00
|
|
|
}:
|
2022-01-29 18:54:41 +00:00
|
|
|
|
|
|
|
let
|
2021-11-14 19:27:00 +00:00
|
|
|
makefile = {
|
|
|
|
aarch64-darwin = "../../cmpl_mac_arm64.mak";
|
|
|
|
x86_64-darwin = "../../cmpl_mac_x64.mak";
|
|
|
|
aarch64-linux = "../../cmpl_gcc_arm64.mak";
|
|
|
|
i686-linux = "../../cmpl_gcc_x86.mak";
|
|
|
|
x86_64-linux = "../../cmpl_gcc_x64.mak";
|
|
|
|
}.${stdenv.hostPlatform.system} or "../../cmpl_gcc.mak"; # generic build
|
2022-01-29 18:54:41 +00:00
|
|
|
in
|
2021-11-12 02:57:14 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "7zz";
|
2022-07-23 11:25:57 +00:00
|
|
|
version = "22.01";
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2021-11-12 02:57:14 +00:00
|
|
|
src = fetchurl {
|
2022-03-18 04:47:19 +00:00
|
|
|
url = "https://7-zip.org/a/7z${lib.replaceStrings [ "." ] [ "" ] version}-src.tar.xz";
|
2022-06-26 19:27:29 +00:00
|
|
|
hash = {
|
2022-07-23 11:25:57 +00:00
|
|
|
free = "sha256-mp3cFXOEiVptkUdD1+X8XxwoJhBGs+Ns5qk3HBByfLg=";
|
|
|
|
unfree = "sha256-OTCYcwxwBCOSr4CJF+dllF3CQ33ueq48/MSWbrkg+8U=";
|
2022-03-18 04:47:19 +00:00
|
|
|
}.${if enableUnfree then "unfree" else "free"};
|
|
|
|
downloadToTemp = (!enableUnfree);
|
|
|
|
# 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
|
|
|
|
postFetch = lib.optionalString (!enableUnfree) ''
|
|
|
|
mkdir tmp
|
|
|
|
tar xf $downloadedFile -C ./tmp
|
|
|
|
rm -r ./tmp/CPP/7zip/Compress/Rar*
|
|
|
|
tar cfJ $out -C ./tmp . \
|
|
|
|
--sort=name \
|
|
|
|
--mtime="@$SOURCE_DATE_EPOCH" \
|
|
|
|
--owner=0 --group=0 --numeric-owner \
|
|
|
|
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime
|
|
|
|
'';
|
2021-11-12 02:57:14 +00:00
|
|
|
};
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2021-11-14 19:27:00 +00:00
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
|
|
patches = [ ./fix-build-on-darwin.patch ];
|
|
|
|
patchFlags = [ "-p0" ];
|
|
|
|
|
2023-02-21 08:35:54 +00:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isMinGW ''
|
|
|
|
find . \( -iname '*.cpp' -o -iname '*.h' -o -iname '*.c' -o -iname '*.rc' \) -print0 \
|
|
|
|
| xargs -0 sed -i '
|
|
|
|
s/<Windows.h>/<windows.h>/
|
|
|
|
s/<WinIoCtl.h>/<winioctl.h>/
|
|
|
|
s/<ShlObj.h>/<shlobj.h>/
|
|
|
|
s/<CommCtrl.h>/<commctrl.h>/
|
|
|
|
s/<Shlwapi.h>/<shlwapi.h>/
|
|
|
|
s/<ShObjIdl.h>/<shobjidl.h>/
|
|
|
|
s/<Psapi.h>/<psapi.h>/
|
|
|
|
s/<WindowsX.h>/<windowsx.h>/
|
|
|
|
s/<WinBase.h>/<winbase.h>/
|
|
|
|
s/<TlHelp32.h>/<tlhelp32.h>/
|
|
|
|
s/<PrSht.h>/<prsht.h>/
|
|
|
|
s/<OleCtl.h>/<olectl.h>/
|
|
|
|
s/<NTSecAPI.h>/<ntsecapi.h>/
|
|
|
|
s/<MAPI.h>/<mapi.h>/
|
|
|
|
s/<InitGuid.h>/<initguid.h>/
|
|
|
|
s/<HtmlHelp.h>/<htmlhelp.h>/
|
|
|
|
s/<WinVer.h>/<winver.h>/
|
|
|
|
/#include/ s|\\|/|g
|
|
|
|
'
|
|
|
|
find . -iname '*mak*' -print0 \
|
|
|
|
| xargs -0 sed -i '
|
|
|
|
s/-lUser32/-luser32/g
|
|
|
|
s/-lOle32/-lole32/g
|
|
|
|
s/-lGdi32/-lgdi32/g
|
|
|
|
s/-lComctl32/-lcomctl32/g
|
|
|
|
s/-lComdlg32/-lcomdlg32/g
|
|
|
|
'
|
|
|
|
substituteInPlace CPP/7zip/7zip_gcc.mak C/7zip_gcc_c.mak \
|
|
|
|
--replace windres.exe ${stdenv.cc.targetPrefix}windres
|
|
|
|
'';
|
|
|
|
|
2021-11-14 19:27:00 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
|
|
|
|
"-Wno-deprecated-copy-dtor"
|
2023-02-21 08:35:54 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isMinGW [
|
|
|
|
"-Wno-conversion"
|
|
|
|
"-Wno-unused-macros"
|
2021-11-14 19:27:00 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
inherit makefile;
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2022-03-18 04:47:19 +00:00
|
|
|
makeFlags =
|
2022-04-18 21:55:43 +00:00
|
|
|
[
|
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"CXX=${stdenv.cc.targetPrefix}c++"
|
2021-11-14 19:27:00 +00:00
|
|
|
]
|
|
|
|
++ lib.optionals useUasm [ "MY_ASM=uasm" ]
|
|
|
|
# We need at minimum 10.13 here because of utimensat, however since
|
|
|
|
# we need a bump anyway, let's set the same minimum version as the one in
|
|
|
|
# aarch64-darwin so we don't need additional changes for it
|
|
|
|
++ lib.optionals stdenv.isDarwin [ "MACOSX_DEPLOYMENT_TARGET=10.16" ]
|
2022-03-18 04:47:19 +00:00
|
|
|
# it's the compression code with the restriction, see DOC/License.txt
|
2023-02-21 08:35:54 +00:00
|
|
|
++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ]
|
|
|
|
++ lib.optionals (stdenv.hostPlatform.isMinGW) [ "IS_MINGW=1" "MSYSTEM=1" ];
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2022-03-18 04:47:19 +00:00
|
|
|
nativeBuildInputs = lib.optionals useUasm [ uasm ];
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2021-11-12 02:57:14 +00:00
|
|
|
enableParallelBuilding = true;
|
2021-03-12 12:44:32 +00:00
|
|
|
|
2021-11-14 19:27:00 +00:00
|
|
|
preBuild = "cd CPP/7zip/Bundles/Alone2";
|
|
|
|
|
2021-03-12 12:44:32 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-11-12 02:57:14 +00:00
|
|
|
|
2023-02-21 08:35:54 +00:00
|
|
|
install -Dm555 -t $out/bin b/*/7zz${stdenv.hostPlatform.extensions.executable}
|
2021-11-12 02:57:14 +00:00
|
|
|
install -Dm444 -t $out/share/doc/${pname} ../../../../DOC/*.txt
|
|
|
|
|
2021-03-12 12:44:32 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2022-04-18 23:39:09 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = ./update.sh;
|
2022-04-20 14:40:48 +00:00
|
|
|
tests.version = testers.testVersion {
|
2022-04-18 23:39:09 +00:00
|
|
|
package = _7zz;
|
|
|
|
command = "7zz --help";
|
|
|
|
};
|
|
|
|
};
|
2022-03-18 04:47:19 +00:00
|
|
|
|
2021-11-12 02:57:14 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Command line archiver utility";
|
2022-01-29 18:54:41 +00:00
|
|
|
homepage = "https://7-zip.org";
|
2022-03-18 04:47:19 +00:00
|
|
|
license = with licenses;
|
|
|
|
# 7zip 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; [ anna328p peterhoeg jk ];
|
2023-02-21 08:35:54 +00:00
|
|
|
platforms = platforms.unix ++ platforms.windows;
|
2022-03-18 04:47:19 +00:00
|
|
|
mainProgram = "7zz";
|
2021-03-12 12:44:32 +00:00
|
|
|
};
|
|
|
|
}
|