1 { bdbSupport ? true # build support for Berkeley DB repositories
2 , httpServer ? false # build Apache DAV module
3 , httpSupport ? true # client must support http
4 , pythonBindings ? false
6 , javahlBindings ? false
8 , lib, stdenv, fetchurl, apr, aprutil, zlib, sqlite, openssl, lz4, utf8proc
9 , CoreServices, Security
11 , apacheHttpd ? null, expat, swig ? null, jdk ? null, python3 ? null, py3c ? null, perl ? null
12 , sasl ? null, serf ? null
15 assert bdbSupport -> aprutil.bdbSupport;
16 assert httpServer -> apacheHttpd != null;
17 assert pythonBindings -> swig != null && python3 != null && py3c != null;
18 assert javahlBindings -> jdk != null && perl != null;
21 # Update libtool for macOS 11 support
22 needsAutogen = stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11";
24 common = { version, sha256, extraPatches ? [ ] }: stdenv.mkDerivation (rec {
26 pname = "subversion${lib.optionalString (!bdbSupport && perlBindings && pythonBindings) "-client"}";
29 url = "mirror://apache/subversion/subversion-${version}.tar.bz2";
33 # Can't do separate $lib and $bin, as libs reference bins
34 outputs = [ "out" "dev" "man" ];
36 nativeBuildInputs = lib.optionals needsAutogen [ autoconf libtool python3 ];
38 buildInputs = [ zlib apr aprutil sqlite openssl lz4 utf8proc ]
39 ++ lib.optional httpSupport serf
40 ++ lib.optionals pythonBindings [ python3 py3c ]
41 ++ lib.optional perlBindings perl
42 ++ lib.optional saslSupport sasl
43 ++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices Security ];
45 patches = [ ./apr-1.patch ] ++ extraPatches;
47 # We are hitting the following issue even with APR 1.6.x
48 # -> https://issues.apache.org/jira/browse/SVN-4813
49 # "-P" CPPFLAG is needed to build Python bindings and subversionClient
52 env = lib.optionalAttrs stdenv.cc.isClang {
53 NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
54 "-Wno-error=implicit-function-declaration"
55 "-Wno-error=implicit-int"
60 preConfigure = lib.optionalString needsAutogen ''
65 (lib.withFeature bdbSupport "berkeley-db")
66 (lib.withFeatureAs httpServer "apxs" "${apacheHttpd.dev}/bin/apxs")
67 (lib.withFeatureAs (pythonBindings || perlBindings) "swig" swig)
68 (lib.withFeatureAs saslSupport "sasl" sasl)
69 (lib.withFeatureAs httpSupport "serf" serf)
70 "--with-zlib=${zlib.dev}"
71 "--with-sqlite=${sqlite.dev}"
72 "--with-apr=${apr.dev}"
73 "--with-apr-util=${aprutil.dev}"
74 ] ++ lib.optionals javahlBindings [
80 makeFlagsArray=(APACHE_LIBEXECDIR=$out/modules)
84 if test -n "$pythonBindings"; then
85 make swig-py swig_pydir=$(toPythonPath $out)/libsvn swig_pydir_extra=$(toPythonPath $out)/svn
86 make install-swig-py swig_pydir=$(toPythonPath $out)/libsvn swig_pydir_extra=$(toPythonPath $out)/svn
89 if test -n "$perlBindings"; then
91 make install-swig-pl-lib
92 cd subversion/bindings/swig/perl/native
93 perl Makefile.PL PREFIX=$out
98 mkdir -p $out/share/bash-completion/completions
99 cp tools/client-side/bash_completion $out/share/bash-completion/completions/subversion
101 for f in $out/lib/*.la $out/lib/python*/site-packages/*/*.la; do
102 substituteInPlace $f \
103 --replace "${expat.dev}/lib" "${expat.out}/lib" \
104 --replace "${zlib.dev}/lib" "${zlib.out}/lib" \
105 --replace "${sqlite.dev}/lib" "${sqlite.out}/lib" \
106 --replace "${openssl.dev}/lib" "${lib.getLib openssl}/lib"
110 inherit perlBindings pythonBindings;
112 enableParallelBuilding = true;
113 # Missing install dependencies:
114 # libtool: error: error: relink 'libsvn_ra_serf-1.la' with the above command before installing it
115 # make: *** [build-outputs.mk:1316: install-serf-lib] Error 1
116 enableParallelInstalling = false;
118 nativeCheckInputs = [ python3 ];
119 doCheck = false; # fails 10 out of ~2300 tests
122 description = "Version control system intended to be a compelling replacement for CVS in the open source community";
123 license = licenses.asl20;
124 homepage = "https://subversion.apache.org/";
126 maintainers = with maintainers; [ lovek323 ];
127 platforms = platforms.linux ++ platforms.darwin;
130 } // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
134 CXXCPP = "clang++ -E";
138 subversion = common {
140 sha256 = "sha256-ROrRFucuSA8Q8SPJFLtvn4wEFxHAQe16v/G4Y0oZnjw=";