forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / applications / version-management / subversion / default.nix
blob39966c8c7386cd6e2cc1100120fbf8d592b1bd70
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
5 , perlBindings ? false
6 , javahlBindings ? false
7 , saslSupport ? false
8 , lib, stdenv, fetchurl, apr, aprutil, zlib, sqlite, openssl, lz4, utf8proc
9 , CoreServices, Security
10 , autoconf, libtool
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;
20 let
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 {
25     inherit version;
26     pname = "subversion${lib.optionalString (!bdbSupport && perlBindings && pythonBindings) "-client"}";
28     src = fetchurl {
29       url = "mirror://apache/subversion/subversion-${version}.tar.bz2";
30       inherit sha256;
31     };
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
50     CPPFLAGS = [ "-P" ];
52     env = lib.optionalAttrs stdenv.cc.isClang {
53       NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
54         "-Wno-error=implicit-function-declaration"
55         "-Wno-error=implicit-int"
56         "-Wno-int-conversion"
57       ];
58     };
60     preConfigure = lib.optionalString needsAutogen ''
61       ./autogen.sh
62     '';
64     configureFlags = [
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 [
75       "--enable-javahl"
76       "--with-jdk=${jdk}"
77     ];
79     preBuild = ''
80       makeFlagsArray=(APACHE_LIBEXECDIR=$out/modules)
81     '';
83     postInstall = ''
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
87       fi
89       if test -n "$perlBindings"; then
90           make swig-pl-lib
91           make install-swig-pl-lib
92           cd subversion/bindings/swig/perl/native
93           perl Makefile.PL PREFIX=$out
94           make install
95           cd -
96       fi
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"
107       done
108     '';
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
121     meta = with lib; {
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/";
125       mainProgram = "svn";
126       maintainers = with maintainers; [ lovek323 ];
127       platforms = platforms.linux ++ platforms.darwin;
128     };
130   } // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
131     CXX = "clang++";
132     CC = "clang";
133     CPP = "clang -E";
134     CXXCPP = "clang++ -E";
135   });
137 in {
138   subversion = common {
139     version = "1.14.4";
140     sha256 = "sha256-ROrRFucuSA8Q8SPJFLtvn4wEFxHAQe16v/G4Y0oZnjw=";
141   };