From 21332b8fd5031fda106cf22c14257a48e827a89f Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 18 Mar 2023 16:13:21 +0100 Subject: [PATCH 1/6] diffoscope: move unfree dependencies behind a enableUnfree flag --- pkgs/tools/misc/diffoscope/default.nix | 18 ++++++++++++------ pkgs/top-level/all-packages.nix | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pkgs/tools/misc/diffoscope/default.nix b/pkgs/tools/misc/diffoscope/default.nix index 6e9a057af07..1b9e743b426 100644 --- a/pkgs/tools/misc/diffoscope/default.nix +++ b/pkgs/tools/misc/diffoscope/default.nix @@ -3,7 +3,8 @@ , e2fsprogs, enjarify, file, findutils, fontforge-fonttools, ffmpeg, fpc, gettext, ghc, ghostscriptX, giflib, gnumeric, gnupg, gnutar , gzip, html2text, hdf5, imagemagick, jdk, libarchive, libcaca, llvm, lz4, mono, ocaml, oggvideotools, openssh, openssl, pdftk, pgpdump, poppler_utils, procyon, qemu, R , radare2, sng, sqlite, squashfsTools, tcpdump, ubootTools, odt2txt, unzip, wabt, xmlbeans, xxd, xz, zip, zstd -, enableBloat ? false +, enableBloat ? true +, enableUnfree ? false # updater only , writeScript }: @@ -54,10 +55,15 @@ python3Packages.buildPythonApplication rec { python-magic progressbar33 pypdf2 tlsh ]) ++ lib.optionals stdenv.isLinux [ python3Packages.pyxattr python3Packages.rpm acl cdrkit dtc ] - ++ lib.optionals enableBloat ([ - abootimg apksigcopier apksigner apktool cbfstool colord enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg gnumeric - hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt oggvideotools openssh pdftk poppler_utils procyon qemu R tcpdump ubootTools wabt radare2 xmlbeans - ] ++ (with python3Packages; [ androguard binwalk guestfs h5py pdfminer-six ])); + ++ lib.optionals enableBloat ( + [ + abootimg apksigcopier apksigner cbfstool colord enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg gnumeric + hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt oggvideotools openssh pdftk poppler_utils procyon qemu R tcpdump ubootTools wabt radare2 xmlbeans + ] + ++ (with python3Packages; [ androguard binwalk guestfs h5py pdfminer-six ]) + # `apktool` depend on `build-tools` which requires Android SDK acceptance, therefore, the whole thing is unfree. + ++ lib.optionals enableUnfree [ apktool ] + ); nativeCheckInputs = with python3Packages; [ pytestCheckHook ] ++ pythonPath; @@ -121,7 +127,7 @@ python3Packages.buildPythonApplication rec { ''; homepage = "https://diffoscope.org/"; license = licenses.gpl3Plus; - maintainers = with maintainers; [ dezgeg danielfullmer ]; + maintainers = with maintainers; [ dezgeg danielfullmer raitobezarius ]; platforms = platforms.unix; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1708180d2d8..fb92fb2252f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6645,12 +6645,12 @@ with pkgs; diction = callPackage ../tools/text/diction { }; - diffoscopeMinimal = callPackage ../tools/misc/diffoscope { + diffoscope = callPackage ../tools/misc/diffoscope { jdk = jdk8; }; - diffoscope = diffoscopeMinimal.override { - enableBloat = !stdenv.isDarwin; + diffoscopeMinimal = diffoscope.override { + enableBloat = false; }; diffr = callPackage ../tools/text/diffr { From 5e8671460b86c7091886d4487000a574eed9cd36 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Wed, 24 May 2023 00:38:49 +0200 Subject: [PATCH 2/6] diffoscope: fix build on Darwin Moved packages requiring x86_64-linux, x86_64-darwin into their proper arrays. --- pkgs/tools/misc/diffoscope/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/misc/diffoscope/default.nix b/pkgs/tools/misc/diffoscope/default.nix index 1b9e743b426..88c6af2bdc0 100644 --- a/pkgs/tools/misc/diffoscope/default.nix +++ b/pkgs/tools/misc/diffoscope/default.nix @@ -57,10 +57,15 @@ python3Packages.buildPythonApplication rec { ++ lib.optionals stdenv.isLinux [ python3Packages.pyxattr python3Packages.rpm acl cdrkit dtc ] ++ lib.optionals enableBloat ( [ - abootimg apksigcopier apksigner cbfstool colord enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg gnumeric - hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt oggvideotools openssh pdftk poppler_utils procyon qemu R tcpdump ubootTools wabt radare2 xmlbeans + apksigcopier apksigner enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg pdftk + hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt openssh + poppler_utils procyon qemu R tcpdump wabt radare2 xmlbeans ] - ++ (with python3Packages; [ androguard binwalk guestfs h5py pdfminer-six ]) + ++ (with python3Packages; [ androguard binwalk h5py pdfminer-six ]) + # oggvideotools is broken on Darwin, please put it back when it will be fixed? + ++ lib.optionals stdenv.isLinux [ abootimg cbfstool colord ubootTools python3Packages.guestfs oggvideotools ] + # This doesn't work on aarch64-darwin + ++ lib.optionals (stdenv.isx86_64 || stdenv.isLinux) [ gnumeric ] # `apktool` depend on `build-tools` which requires Android SDK acceptance, therefore, the whole thing is unfree. ++ lib.optionals enableUnfree [ apktool ] ); From 4e79d6857e0af00a49d5e9bf78755a2803e376f2 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Wed, 24 May 2023 01:29:12 +0200 Subject: [PATCH 3/6] oggvideotools: mark it as broken on Darwin --- pkgs/tools/misc/oggvideotools/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/tools/misc/oggvideotools/default.nix b/pkgs/tools/misc/oggvideotools/default.nix index e6b8d9a1d28..8a390ad490b 100644 --- a/pkgs/tools/misc/oggvideotools/default.nix +++ b/pkgs/tools/misc/oggvideotools/default.nix @@ -43,5 +43,9 @@ stdenv.mkDerivation rec { homepage = "http://www.streamnik.de/oggvideotools.html"; license = licenses.gpl2Only; maintainers = with maintainers; [ SuperSandro2000 ]; + # Compilation error on Darwin: + # error: invalid argument '--std=c++0x' not allowed with 'C' + # make[2]: *** [src/libresample/CMakeFiles/resample.dir/build.make:76: src/libresample/CMakeFiles/resample.dir/filterkit.c.o] Error 1 + broken = stdenv.isDarwin; }; } From 0cde352ef1e6442a825a8e7a0c1d266349bb3d5d Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Wed, 24 May 2023 17:45:02 +0200 Subject: [PATCH 4/6] python3Packages.guestfs: platforms are the ones libguestfs supports This ensures the proper propagation for `lib.meta.availableOn` to work fine. --- pkgs/development/python-modules/guestfs/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/python-modules/guestfs/default.nix b/pkgs/development/python-modules/guestfs/default.nix index 0f1d2ddf05c..68401e9ea4d 100644 --- a/pkgs/development/python-modules/guestfs/default.nix +++ b/pkgs/development/python-modules/guestfs/default.nix @@ -20,5 +20,6 @@ buildPythonPackage rec { description = "Use libguestfs from Python"; license = licenses.lgpl2Plus; maintainers = with maintainers; [ grahamc ]; + inherit (libguestfs.meta) platforms; }; } From d99434c90b51c3c1471af47cde35cce5ee6b165d Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Wed, 24 May 2023 17:45:24 +0200 Subject: [PATCH 5/6] python3Packages.pyxattr: platforms are the ones xattr supports This ensures the proper propagation for `lib.meta.availableOn` to work. --- pkgs/development/python-modules/pyxattr/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/python-modules/pyxattr/default.nix b/pkgs/development/python-modules/pyxattr/default.nix index 0fe64d2bf90..ac8a1654c9e 100644 --- a/pkgs/development/python-modules/pyxattr/default.nix +++ b/pkgs/development/python-modules/pyxattr/default.nix @@ -21,5 +21,6 @@ buildPythonPackage rec { meta = with lib; { description = "A Python extension module which gives access to the extended attributes for filesystem objects available in some operating systems"; license = licenses.lgpl21Plus; + inherit (pkgs.attr.meta) platforms; }; } From 43957dc1501d32df91a7a7180a7366c172e7b46d Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Wed, 24 May 2023 17:46:54 +0200 Subject: [PATCH 6/6] diffoscope: introduce `lib.meta.availableOn stdenv.hostPlatform` for "plugins" This makes it easier to add new plugins without having to worry whether they are supported on Darwin, aarch64-*, etc. As long as they are properly tagged through their `platforms` meta attribute (or `badPlatforms`). Broken packages needs to be separated to avoid silent breakages which we would not notice. --- pkgs/tools/misc/diffoscope/default.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/misc/diffoscope/default.nix b/pkgs/tools/misc/diffoscope/default.nix index 88c6af2bdc0..9f1b76badbb 100644 --- a/pkgs/tools/misc/diffoscope/default.nix +++ b/pkgs/tools/misc/diffoscope/default.nix @@ -44,31 +44,32 @@ python3Packages.buildPythonApplication rec { # To help figuring out what's missing from the list, run: ./pkgs/tools/misc/diffoscope/list-missing-tools.sh # # Still missing these tools: docx2txt lipo otool r2pipe - pythonPath = [ + # We filter automatically all packages for the host platform (some dependencies are not supported on Darwin, aarch64, etc.). + pythonPath = lib.filter (lib.meta.availableOn stdenv.hostPlatform) ([ binutils-unwrapped-all-targets bzip2 colordiff coreutils cpio db diffutils e2fsprogs file findutils fontforge-fonttools gettext gnutar gzip html2text libarchive lz4 openssl pgpdump sng sqlite squashfsTools unzip xxd - xz zip zstd + xz zip zstd cdrkit dtc ] ++ (with python3Packages; [ argcomplete debian defusedxml jsondiff jsbeautifier libarchive-c - python-magic progressbar33 pypdf2 tlsh + python-magic progressbar33 pypdf2 tlsh pyxattr rpm ]) - ++ lib.optionals stdenv.isLinux [ python3Packages.pyxattr python3Packages.rpm acl cdrkit dtc ] ++ lib.optionals enableBloat ( [ apksigcopier apksigner enjarify ffmpeg fpc ghc ghostscriptX giflib gnupg pdftk hdf5 imagemagick libcaca llvm jdk mono ocaml odt2txt openssh poppler_utils procyon qemu R tcpdump wabt radare2 xmlbeans + abootimg cbfstool colord ubootTools ] - ++ (with python3Packages; [ androguard binwalk h5py pdfminer-six ]) + ++ (with python3Packages; [ androguard binwalk h5py pdfminer-six guestfs ]) # oggvideotools is broken on Darwin, please put it back when it will be fixed? - ++ lib.optionals stdenv.isLinux [ abootimg cbfstool colord ubootTools python3Packages.guestfs oggvideotools ] + ++ lib.optionals stdenv.isLinux [ oggvideotools ] # This doesn't work on aarch64-darwin - ++ lib.optionals (stdenv.isx86_64 || stdenv.isLinux) [ gnumeric ] + ++ lib.optionals (stdenv.hostPlatform != "aarch64-darwin") [ gnumeric ] # `apktool` depend on `build-tools` which requires Android SDK acceptance, therefore, the whole thing is unfree. ++ lib.optionals enableUnfree [ apktool ] - ); + )); nativeCheckInputs = with python3Packages; [ pytestCheckHook ] ++ pythonPath;