diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2021-11-14 16:27:00 -0300 |
---|---|---|
committer | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-07-23 21:20:22 +0100 |
commit | d383e90ace6480d6846b6dd3cbe66d30c044bd30 (patch) | |
tree | be2826c5f126422913fe44fdfef4e79561b7a2c3 | |
parent | 2458b102be66712cfcd7dccfa46e5de0dc7920cd (diff) | |
download | nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar.gz nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar.bz2 nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar.lz nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar.xz nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.tar.zst nixpkgs-d383e90ace6480d6846b6dd3cbe66d30c044bd30.zip |
_7zz: build on macOS
-rw-r--r-- | pkgs/tools/archivers/7zz/default.nix | 47 | ||||
-rw-r--r-- | pkgs/tools/archivers/7zz/fix-build-on-darwin.patch | 24 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
3 files changed, 55 insertions, 18 deletions
diff --git a/pkgs/tools/archivers/7zz/default.nix b/pkgs/tools/archivers/7zz/default.nix index 0c8c6ed5d3a..150230f775a 100644 --- a/pkgs/tools/archivers/7zz/default.nix +++ b/pkgs/tools/archivers/7zz/default.nix @@ -2,9 +2,9 @@ , lib , fetchurl - # Only used for x86/x86_64 + # Only used for Linux's x86/x86_64 , uasm -, useUasm ? stdenv.hostPlatform.isx86 +, useUasm ? (stdenv.isLinux && stdenv.hostPlatform.isx86) # RAR code is under non-free unRAR license # see the meta.license section below for more details @@ -16,13 +16,13 @@ }: let - inherit (stdenv.hostPlatform) system; - platformSuffix = { - aarch64-linux = "_arm64"; - i686-linux = "_x86"; - x86_64-linux = "_x64"; - }.${system} or - (builtins.trace "`platformSuffix` not available for `${system}.` Making a generic `7zz` build." ""); + 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 in stdenv.mkDerivation rec { pname = "7zz"; @@ -51,27 +51,40 @@ stdenv.mkDerivation rec { ''; }; - sourceRoot = "CPP/7zip/Bundles/Alone2"; + sourceRoot = "."; + + patches = [ ./fix-build-on-darwin.patch ]; + patchFlags = [ "-p0" ]; + + NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ + "-Wno-deprecated-copy-dtor" + ]; + + inherit makefile; makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" "CXX=${stdenv.cc.targetPrefix}c++" - ] ++ - lib.optionals useUasm [ "MY_ASM=uasm" ] ++ + ] + ++ 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" ] # it's the compression code with the restriction, see DOC/License.txt - lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ]; - - makefile = "../../cmpl_gcc${platformSuffix}.mak"; + ++ lib.optionals (!enableUnfree) [ "DISABLE_RAR_COMPRESS=true" ]; nativeBuildInputs = lib.optionals useUasm [ uasm ]; enableParallelBuilding = true; + preBuild = "cd CPP/7zip/Bundles/Alone2"; + installPhase = '' runHook preInstall - install -Dm555 -t $out/bin b/g${platformSuffix}/7zz + install -Dm555 -t $out/bin b/*/7zz install -Dm444 -t $out/share/doc/${pname} ../../../../DOC/*.txt runHook postInstall @@ -96,7 +109,7 @@ stdenv.mkDerivation rec { # the unRAR compression code is disabled by default lib.optionals enableUnfree [ unfree ]; maintainers = with maintainers; [ anna328p peterhoeg jk ]; - platforms = platforms.linux; + platforms = platforms.unix; mainProgram = "7zz"; }; } diff --git a/pkgs/tools/archivers/7zz/fix-build-on-darwin.patch b/pkgs/tools/archivers/7zz/fix-build-on-darwin.patch new file mode 100644 index 00000000000..9d8ee7f9bc6 --- /dev/null +++ b/pkgs/tools/archivers/7zz/fix-build-on-darwin.patch @@ -0,0 +1,24 @@ +diff -Naur CPP/7zip/Common/FileStreams.cpp CPP/7zip/Common/FileStreams.cpp +--- CPP/7zip/Common/FileStreams.cpp ++++ CPP/7zip/Common/FileStreams.cpp +@@ -12,7 +12,7 @@ + #include <pwd.h> + + // for major()/minor(): +-#if defined(__FreeBSD__) || defined(BSD) ++#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__) + #include <sys/types.h> + #else + #include <sys/sysmacros.h> +diff -Naur CPP/7zip/UI/Common/UpdateCallback.cpp CPP/7zip/UI/Common/UpdateCallback.cpp +--- CPP/7zip/UI/Common/UpdateCallback.cpp ++++ CPP/7zip/UI/Common/UpdateCallback.cpp +@@ -9,7 +9,7 @@ + // #include <pwd.h> + + // for major()/minor(): +-#if defined(__FreeBSD__) || defined(BSD) ++#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__) + #include <sys/types.h> + #else + #include <sys/sysmacros.h> diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 325540d5baa..622d78b7ecd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -995,7 +995,7 @@ with pkgs; _6tunnel = callPackage ../tools/networking/6tunnel { }; - _7zz = callPackage ../tools/archivers/7zz { }; + _7zz = darwin.apple_sdk_11_0.callPackage ../tools/archivers/7zz { }; _9pfs = callPackage ../tools/filesystems/9pfs { }; |