lol
1{ lib
2, stdenv
3, callPackage
4, fetchFromGitHub
5, cmake
6, cppunit
7, pkg-config
8, curl
9, fuse
10, libkrb5
11, libuuid
12, libxcrypt
13, libxml2
14, openssl
15, readline
16, systemd
17, voms
18, zlib
19, enableTests ? true
20 # If not null, the builder will
21 # move "$out/etc" to "$out/etc.orig" and symlink "$out/etc" to externalEtc.
22, externalEtc ? "/etc"
23}:
24
25stdenv.mkDerivation rec {
26 pname = "xrootd";
27 version = "5.5.1";
28
29 src = fetchFromGitHub {
30 owner = "xrootd";
31 repo = "xrootd";
32 rev = "v${version}";
33 fetchSubmodules = true;
34 hash = "sha256-PaLT3+5FucPnWLStWxtBBqTKs8hvogKMrZteSNY+xXI=";
35 };
36
37 outputs = [ "bin" "out" "dev" "man" ];
38
39 passthru.tests = lib.optionalAttrs enableTests {
40 test-runner = callPackage ./test-runner.nix { };
41 };
42
43 nativeBuildInputs = [
44 cmake
45 pkg-config
46 ];
47
48 buildInputs = [
49 curl
50 libkrb5
51 libuuid
52 libxcrypt
53 libxml2
54 openssl
55 readline
56 zlib
57 ]
58 ++ lib.optionals stdenv.isLinux [
59 fuse
60 systemd
61 voms
62 ]
63 ++ lib.optionals enableTests [
64 cppunit
65 ];
66
67 preConfigure = ''
68 patchShebangs genversion.sh
69 '';
70
71 # https://github.com/xrootd/xrootd/blob/master/packaging/rhel/xrootd.spec.in#L665-L675=
72 postInstall = ''
73 mkdir -p "$out/lib/tmpfiles.d"
74 install -m 644 -T ../packaging/rhel/xrootd.tmpfiles "$out/lib/tmpfiles.d/xrootd.conf"
75 mkdir -p "$out/etc/xrootd"
76 install -m 644 -t "$out/etc/xrootd" ../packaging/common/*.cfg
77 install -m 644 -t "$out/etc/xrootd" ../packaging/common/client.conf
78 mkdir -p "$out/etc/xrootd/client.plugins.d"
79 install -m 644 -t "$out/etc/xrootd/client.plugins.d" ../packaging/common/client-plugin.conf.example
80 mkdir -p "$out/etc/logrotate.d"
81 install -m 644 -T ../packaging/common/xrootd.logrotate "$out/etc/logrotate.d/xrootd"
82 '' + lib.optionalString stdenv.isLinux ''
83 mkdir -p "$out/lib/systemd/system"
84 install -m 644 -t "$out/lib/systemd/system" ../packaging/common/*.service ../packaging/common/*.socket
85 '';
86
87 cmakeFlags = lib.optionals enableTests [
88 "-DENABLE_TESTS=TRUE"
89 ];
90
91 postFixup = lib.optionalString (externalEtc != null) ''
92 mv "$out"/etc{,.orig}
93 ln -s ${lib.escapeShellArg externalEtc} "$out/etc"
94 '';
95
96 meta = with lib; {
97 description = "High performance, scalable fault tolerant data access";
98 homepage = "https://xrootd.slac.stanford.edu";
99 license = licenses.lgpl3Plus;
100 platforms = platforms.all;
101 maintainers = with maintainers; [ ShamrockLee ];
102 };
103}