1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
{
lib,
stdenv,
fetchurl,
python311Packages,
makeWrapper,
gawk,
bash,
getopt,
procps,
which,
jre,
nixosTests,
# generation is the attribute version suffix such as 4 in pkgs.cassandra_4
generation,
version,
sha256,
extraMeta ? { },
callPackage,
...
}:
let
libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
binPath = lib.makeBinPath [
bash
getopt
gawk
which
jre
procps
];
in
stdenv.mkDerivation rec {
pname = "cassandra";
inherit version;
src = fetchurl {
inherit sha256;
url = "mirror://apache/cassandra/${version}/apache-cassandra-${version}-bin.tar.gz";
};
pythonPath = with python311Packages; [ cassandra-driver ];
nativeBuildInputs = [ python311Packages.wrapPython ];
buildInputs = [ python311Packages.python ] ++ pythonPath;
installPhase = ''
runHook preInstall
mkdir $out
mv * $out
# Clean up documentation.
mkdir -p $out/share/doc/${pname}-${version}
mv $out/CHANGES.txt \
$out/LICENSE.txt \
$out/NEWS.txt \
$out/NOTICE.txt \
$out/share/doc/${pname}-${version}
if [[ -d $out/doc ]]; then
mv "$out/doc/"* $out/share/doc/${pname}-${version}
rmdir $out/doc
fi
for cmd in bin/cassandra \
bin/nodetool \
bin/sstablekeys \
bin/sstableloader \
bin/sstablescrub \
bin/sstableupgrade \
bin/sstableutil \
bin/sstableverify; do
# Check if file exists because some don't exist across all versions
if [ -f $out/$cmd ]; then
wrapProgram $out/bin/$(basename "$cmd") \
--suffix-each LD_LIBRARY_PATH : ${libPath} \
--prefix PATH : ${binPath} \
--set JAVA_HOME ${jre}
fi
done
for cmd in tools/bin/cassandra-stress \
tools/bin/cassandra-stressd \
tools/bin/sstabledump \
tools/bin/sstableexpiredblockers \
tools/bin/sstablelevelreset \
tools/bin/sstablemetadata \
tools/bin/sstableofflinerelevel \
tools/bin/sstablerepairedset \
tools/bin/sstablesplit \
tools/bin/token-generator; do
# Check if file exists because some don't exist across all versions
if [ -f $out/$cmd ]; then
makeWrapper $out/$cmd $out/bin/$(basename "$cmd") \
--suffix-each LD_LIBRARY_PATH : ${libPath} \
--prefix PATH : ${binPath} \
--set JAVA_HOME ${jre}
fi
done
runHook postInstall
'';
postFixup = ''
# Remove cassandra bash script wrapper.
# The wrapper searches for a suitable python version and is not necessary with Nix.
rm $out/bin/cqlsh
# Make "cqlsh.py" accessible by invoking "cqlsh"
ln -s $out/bin/cqlsh.py $out/bin/cqlsh
wrapPythonPrograms
'';
passthru = {
tests =
let
test = nixosTests."cassandra_${generation}";
in
{
nixos =
assert test.testPackage.version == version;
test;
};
updateScript = callPackage ./update-script.nix { inherit generation; };
};
meta =
with lib;
{
homepage = "https://cassandra.apache.org/";
description = "Massively scalable open source NoSQL database";
platforms = platforms.unix;
license = licenses.asl20;
sourceProvenance = with sourceTypes; [
binaryBytecode
binaryNativeCode # bundled dependency libsigar
];
maintainers = [ maintainers.roberth ];
}
// extraMeta;
}
|