2022-03-30 09:31:56 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# Only used for Linux's x86/x86_64
|
2022-03-30 09:31:56 +00:00
|
|
|
, uasm
|
2022-08-12 12:06:08 +00:00
|
|
|
, useUasm ? (stdenv.isLinux && stdenv.hostPlatform.isx86)
|
2022-03-30 09:31:56 +00:00
|
|
|
|
|
|
|
# RAR code is under non-free unRAR license
|
|
|
|
# see the meta.license section below for more details
|
|
|
|
, enableUnfree ? false
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
# For tests
|
|
|
|
, testers
|
2022-03-30 09:31:56 +00:00
|
|
|
}:
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
let
|
2022-08-12 12:06:08 +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-02-10 20:34:41 +00:00
|
|
|
in
|
2023-10-09 19:29:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-12-06 16:07:01 +00:00
|
|
|
pname = "7zz";
|
2024-06-20 14:57:18 +00:00
|
|
|
version = "24.06";
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
src = fetchurl {
|
2023-10-09 19:29:22 +00:00
|
|
|
url = "https://7-zip.org/a/7z${lib.replaceStrings [ "." ] [ "" ] finalAttrs.version}-src.tar.xz";
|
2022-07-14 12:49:19 +00:00
|
|
|
hash = {
|
2024-06-20 14:57:18 +00:00
|
|
|
free = "sha256-X3uqGnJGQpW5MOaTtgWYwwrhS84e+piX7Gc+e8Pll00=";
|
|
|
|
unfree = "sha256-KqFmDHc1JbLthNbNf/BoDHhuwIk7h+TbRGVNy39ayLU=";
|
2022-03-30 09:31:56 +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-12-06 16:07:01 +00:00
|
|
|
};
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
sourceRoot = ".";
|
|
|
|
|
2023-02-22 10:55:15 +00:00
|
|
|
patches = [
|
|
|
|
./fix-cross-mingw-build.patch
|
|
|
|
];
|
2022-08-12 12:06:08 +00:00
|
|
|
|
2023-02-22 10:55:15 +00:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isMinGW ''
|
|
|
|
substituteInPlace CPP/7zip/7zip_gcc.mak C/7zip_gcc_c.mak \
|
|
|
|
--replace windres.exe ${stdenv.cc.targetPrefix}windres
|
|
|
|
'';
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.isDarwin [
|
2022-08-12 12:06:08 +00:00
|
|
|
"-Wno-deprecated-copy-dtor"
|
2023-02-22 10:55:15 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isMinGW [
|
|
|
|
"-Wno-conversion"
|
|
|
|
"-Wno-unused-macros"
|
2023-10-09 19:29:22 +00:00
|
|
|
] ++ lib.optionals stdenv.cc.isClang [
|
|
|
|
"-Wno-declaration-after-statement"
|
|
|
|
(lib.optionals (lib.versionAtLeast (lib.getVersion stdenv.cc.cc) "13") [
|
|
|
|
"-Wno-reserved-identifier"
|
|
|
|
"-Wno-unused-but-set-variable"
|
|
|
|
])
|
|
|
|
(lib.optionals (lib.versionAtLeast (lib.getVersion stdenv.cc.cc) "16") [
|
|
|
|
"-Wno-unsafe-buffer-usage"
|
|
|
|
"-Wno-cast-function-type-strict"
|
|
|
|
])
|
2023-03-04 12:14:45 +00:00
|
|
|
]);
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
inherit makefile;
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
makeFlags =
|
2022-04-27 09:35:20 +00:00
|
|
|
[
|
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"CXX=${stdenv.cc.targetPrefix}c++"
|
2022-08-12 12:06:08 +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-30 09:31:56 +00:00
|
|
|
# it's the compression code with the restriction, see DOC/License.txt
|
2023-02-22 10:55:15 +00:00
|
|
|
++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ]
|
|
|
|
++ lib.optionals (stdenv.hostPlatform.isMinGW) [ "IS_MINGW=1" "MSYSTEM=1" ];
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
nativeBuildInputs = lib.optionals useUasm [ uasm ];
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
enableParallelBuilding = true;
|
2021-03-23 19:22:30 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
preBuild = "cd CPP/7zip/Bundles/Alone2";
|
|
|
|
|
2021-03-23 19:22:30 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2023-02-22 10:55:15 +00:00
|
|
|
install -Dm555 -t $out/bin b/*/7zz${stdenv.hostPlatform.extensions.executable}
|
2023-10-09 19:29:22 +00:00
|
|
|
install -Dm444 -t $out/share/doc/${finalAttrs.pname} ../../../../DOC/*.txt
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2021-03-23 19:22:30 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
passthru = {
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
tests.version = testers.testVersion {
|
2024-06-05 15:53:02 +00:00
|
|
|
package = finalAttrs.finalPackage;
|
2022-04-27 09:35:20 +00:00
|
|
|
command = "7zz --help";
|
|
|
|
};
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
meta = {
|
2021-12-06 16:07:01 +00:00
|
|
|
description = "Command line archiver utility";
|
2022-02-10 20:34:41 +00:00
|
|
|
homepage = "https://7-zip.org";
|
2024-06-05 15:53:02 +00:00
|
|
|
license = with lib.licenses;
|
2022-03-30 09:31:56 +00:00
|
|
|
# 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 ];
|
2024-06-05 15:53:02 +00:00
|
|
|
maintainers = with lib.maintainers; [ anna328p eclairevoyant jk peterhoeg ];
|
|
|
|
platforms = with lib.platforms; unix ++ windows;
|
2022-03-30 09:31:56 +00:00
|
|
|
mainProgram = "7zz";
|
2021-03-23 19:22:30 +00:00
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
})
|