1{
2 lib,
3 stdenv,
4 fetchurl,
5 updateAutotoolsGnuConfigScriptsHook,
6 perl,
7 libiconv,
8 zlib,
9 popt,
10 enableACLs ? lib.meta.availableOn stdenv.hostPlatform acl,
11 acl,
12 enableLZ4 ? true,
13 lz4,
14 enableOpenSSL ? true,
15 openssl,
16 enableXXHash ? true,
17 xxHash,
18 enableZstd ? true,
19 zstd,
20 nixosTests,
21 fakeroot,
22}:
23
24stdenv.mkDerivation rec {
25 pname = "rsync";
26 version = "3.4.1";
27
28 src = fetchurl {
29 # signed with key 9FEF 112D CE19 A0DC 7E88 2CB8 1BB2 4997 A853 5F6F
30 url = "mirror://samba/rsync/src/rsync-${version}.tar.gz";
31 hash = "sha256-KSS8s6Hti1UfwQH3QLnw/gogKxFQJ2R89phQ1l/YjFI=";
32 };
33
34 nativeBuildInputs = [
35 updateAutotoolsGnuConfigScriptsHook
36 perl
37 ];
38
39 buildInputs = [
40 libiconv
41 zlib
42 popt
43 ]
44 ++ lib.optional enableACLs acl
45 ++ lib.optional enableZstd zstd
46 ++ lib.optional enableLZ4 lz4
47 ++ lib.optional enableOpenSSL openssl
48 ++ lib.optional enableXXHash xxHash;
49
50 # fakeroot doesn't work well on darwin anymore, apparently
51 checkInputs = lib.optionals (!stdenv.isDarwin) [ fakeroot ];
52
53 configureFlags = [
54 (lib.enableFeature enableLZ4 "lz4")
55 (lib.enableFeature enableOpenSSL "openssl")
56 (lib.enableFeature enableXXHash "xxhash")
57 (lib.enableFeature enableZstd "zstd")
58 # Feature detection does a runtime check which varies according to ipv6
59 # availability, so force it on to make reproducible, see #360152.
60 (lib.enableFeature true "ipv6")
61 "--with-nobody-group=nogroup"
62
63 # disable the included zlib explicitly as it otherwise still compiles and
64 # links them even.
65 "--with-included-zlib=no"
66 ]
67 ++ lib.optionals (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isx86_64) [
68 # fix `multiversioning needs 'ifunc' which is not supported on this target` error
69 "--disable-roll-simd"
70 ];
71
72 enableParallelBuilding = true;
73
74 passthru.tests = { inherit (nixosTests) rsyncd; };
75
76 doCheck = true;
77
78 meta = with lib; {
79 description = "Fast incremental file transfer utility";
80 homepage = "https://rsync.samba.org/";
81 license = licenses.gpl3Plus;
82 mainProgram = "rsync";
83 maintainers = with lib.maintainers; [
84 kampfschlaefer
85 ivan
86 ];
87 platforms = platforms.unix;
88 };
89}