cassandra: use Nix scope checking

This commit is contained in:
Robert Hensing 2021-04-29 08:39:35 +02:00
parent 19ba3d97d2
commit 726669ace8
2 changed files with 22 additions and 10 deletions

View File

@ -1,8 +1,20 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
inherit (lib)
concatStringsSep
flip
literalExample
optionalAttrs
optionals
recursiveUpdate
mkEnableOption
mkIf
mkOption
types
versionAtLeast
;
cfg = config.services.cassandra; cfg = config.services.cassandra;
defaultUser = "cassandra"; defaultUser = "cassandra";
@ -18,14 +30,14 @@ let
data_file_directories = [ "${cfg.homeDir}/data" ]; data_file_directories = [ "${cfg.homeDir}/data" ];
commitlog_directory = "${cfg.homeDir}/commitlog"; commitlog_directory = "${cfg.homeDir}/commitlog";
saved_caches_directory = "${cfg.homeDir}/saved_caches"; saved_caches_directory = "${cfg.homeDir}/saved_caches";
} // lib.optionalAttrs (cfg.seedAddresses != [ ]) { } // optionalAttrs (cfg.seedAddresses != [ ]) {
seed_provider = [ seed_provider = [
{ {
class_name = "org.apache.cassandra.locator.SimpleSeedProvider"; class_name = "org.apache.cassandra.locator.SimpleSeedProvider";
parameters = [{ seeds = concatStringsSep "," cfg.seedAddresses; }]; parameters = [{ seeds = concatStringsSep "," cfg.seedAddresses; }];
} }
]; ];
} // lib.optionalAttrs (lib.versionAtLeast cfg.package.version "3") { } // optionalAttrs (versionAtLeast cfg.package.version "3") {
hints_directory = "${cfg.homeDir}/hints"; hints_directory = "${cfg.homeDir}/hints";
} }
); );
@ -76,10 +88,10 @@ let
fullJvmOptions = fullJvmOptions =
cfg.jvmOpts cfg.jvmOpts
++ lib.optionals (cfg.jmxRoles != [ ]) [ ++ optionals (cfg.jmxRoles != [ ]) [
"-Dcom.sun.management.jmxremote.authenticate=true" "-Dcom.sun.management.jmxremote.authenticate=true"
"-Dcom.sun.management.jmxremote.password.file=${cfg.jmxRolesFile}" "-Dcom.sun.management.jmxremote.password.file=${cfg.jmxRolesFile}"
] ++ lib.optionals cfg.remoteJmx [ ] ++ optionals cfg.remoteJmx [
"-Djava.rmi.server.hostname=${cfg.rpcAddress}" "-Djava.rmi.server.hostname=${cfg.rpcAddress}"
]; ];
@ -421,7 +433,7 @@ in
jmxRolesFile = mkOption { jmxRolesFile = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = default =
if lib.versionAtLeast cfg.package.version "3.11" if versionAtLeast cfg.package.version "3.11"
then pkgs.writeText "jmx-roles-file" defaultJmxRolesFile then pkgs.writeText "jmx-roles-file" defaultJmxRolesFile
else null; else null;
example = "/var/lib/cassandra/jmx.password"; example = "/var/lib/cassandra/jmx.password";
@ -497,7 +509,7 @@ in
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
ExecStart = ExecStart =
lib.concatStringsSep " " concatStringsSep " "
([ ([
"${cfg.package}/bin/nodetool" "${cfg.package}/bin/nodetool"
"repair" "repair"
@ -525,7 +537,7 @@ in
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
ExecStart = ExecStart =
lib.concatStringsSep " " concatStringsSep " "
([ ([
"${cfg.package}/bin/nodetool" "${cfg.package}/bin/nodetool"
"repair" "repair"

View File

@ -21,7 +21,7 @@
let let
libPath = lib.makeLibraryPath [ stdenv.cc.cc ]; libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
binPath = with lib; makeBinPath [ binPath = lib.makeBinPath [
bash bash
getopt getopt
gawk gawk