From 7b9adf4dee7614a0621758819d2db601bf853bc1 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Mon, 19 Dec 2022 15:01:10 -0300 Subject: [PATCH] libarchive: refactor - Remove "override" references on all-packages.nix - use finalAttrs style to get rid of rec - refactor postPatch to use Nix code instead of shell script --- .../libraries/libarchive/default.nix | 52 ++++++++++--------- pkgs/top-level/all-packages.nix | 4 +- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/pkgs/development/libraries/libarchive/default.nix b/pkgs/development/libraries/libarchive/default.nix index c7e9f117f94c..381689f9cb65 100644 --- a/pkgs/development/libraries/libarchive/default.nix +++ b/pkgs/development/libraries/libarchive/default.nix @@ -22,44 +22,48 @@ , cmake , nix , samba +, buildPackages }: +let + autoreconfHook = buildPackages.autoreconfHook269; +in assert xarSupport -> libxml2 != null; - -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "libarchive"; version = "3.6.2"; src = fetchFromGitHub { owner = "libarchive"; repo = "libarchive"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; hash = "sha256-wQbA6vlXH8pnpY7LJLkjrRFEBpcaPR1SqxnK71UVwxg="; }; - postPatch = '' + outputs = [ "out" "lib" "dev" ]; + + postPatch = let + skipTestPaths = [ + # test won't work in nix sandbox + "libarchive/test/test_write_disk_perms.c" + # the filesystem does not necessarily have sparse capabilities + "libarchive/test/test_sparse_basic.c" + # the filesystem does not necessarily have hardlink capabilities + "libarchive/test/test_write_disk_hardlink.c" + # access-time-related tests flakey on some systems + "cpio/test/test_option_a.c" + "cpio/test/test_option_t.c" + ]; + removeTest = testPath: '' + substituteInPlace Makefile.am --replace "${testPath}" "" + rm "${testPath}" + ''; + in '' substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)" - declare -a skip_test_paths=( - # test won't work in nix sandbox - 'libarchive/test/test_write_disk_perms.c' - # can't be sure builder will have sparse-capable fs - 'libarchive/test/test_sparse_basic.c' - # can't even be sure builder will have hardlink-capable fs - 'libarchive/test/test_write_disk_hardlink.c' - # access-time-related tests flakey on some systems - 'cpio/test/test_option_a.c' - 'cpio/test/test_option_t.c' - ) - - for test_path in "''${skip_test_paths[@]}" ; do - substituteInPlace Makefile.am --replace "$test_path" "" - rm "$test_path" - done + ${lib.concatStringsSep "\n" (map removeTest skipTestPaths)} ''; - outputs = [ "out" "lib" "dev" ]; - nativeBuildInputs = [ autoreconfHook pkg-config @@ -105,7 +109,7 @@ stdenv.mkDerivation rec { includes implementations of the common tar, cpio, and zcat command-line tools that use the libarchive library. ''; - changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}"; + changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.version}"; license = licenses.bsd3; maintainers = with maintainers; [ jcumming AndersonTorres ]; platforms = platforms.all; @@ -114,4 +118,4 @@ stdenv.mkDerivation rec { passthru.tests = { inherit cmake nix samba; }; -} +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0636572aa450..c9e3f6fd4a42 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20172,9 +20172,7 @@ with pkgs; libargs = callPackage ../development/libraries/libargs { }; - libarchive = callPackage ../development/libraries/libarchive { - autoreconfHook = buildPackages.autoreconfHook269; - }; + libarchive = callPackage ../development/libraries/libarchive { }; libarchive-qt = libsForQt5.callPackage ../development/libraries/libarchive-qt { };