services-flake/nix/cassandra_test.nix
Abhishek Singh 6aeb0eafe6
cassandra: init service (#116)
* cassandra: init service

* cassandra: add cassandra/conf files

* cassandra_test: change package to cassandra_4

* update readiness_probe

* update cassandra_test

* cassandra: add doc

* cassandra_4 doesn't require python-2

---------

Co-authored-by: shivaraj-bh <sbh69840@gmail.com>
2024-03-03 16:07:36 +05:30

28 lines
995 B
Nix

{ pkgs, config, ... }: {
services.cassandra."cass1" = {
enable = true;
# support for aarch64-darwin was added in cassandra-4
# https://github.com/apache/cassandra/blob/a87055d56a33a9b17606f14535f48eb461965b82/CHANGES.txt#L192
package = pkgs.cassandra_4;
};
settings.processes.test =
let
cfg = config.services.cassandra."cass1";
in
{
command = pkgs.writeShellApplication {
runtimeInputs = [ cfg.package ];
text = ''
echo "show version;" | cqlsh
echo "create keyspace test with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};" | cqlsh
echo "CREATE TABLE test.test_table(id int PRIMARY KEY, name text);" | cqlsh
echo "insert into test.test_table (id, name) VALUES (1, 'hello');" | cqlsh
echo "select * from test.test_table;" | cqlsh | grep hello
'';
name = "cassandra-test";
};
depends_on."cass1".condition = "process_healthy";
};
}