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

View file

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