From 726669ace8a2e13d4211da4a2adfa9ee5f9d9f38 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 29 Apr 2021 08:39:35 +0200 Subject: [PATCH] cassandra: use Nix scope checking --- .../modules/services/databases/cassandra.nix | 30 +++++++++++++------ pkgs/servers/nosql/cassandra/generic.nix | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/databases/cassandra.nix b/nixos/modules/services/databases/cassandra.nix index 4ce7a068aedc..ebb50ddf50b2 100644 --- a/nixos/modules/services/databases/cassandra.nix +++ b/nixos/modules/services/databases/cassandra.nix @@ -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" diff --git a/pkgs/servers/nosql/cassandra/generic.nix b/pkgs/servers/nosql/cassandra/generic.nix index 029eb1605458..cab21080a043 100644 --- a/pkgs/servers/nosql/cassandra/generic.nix +++ b/pkgs/servers/nosql/cassandra/generic.nix @@ -21,7 +21,7 @@ let libPath = lib.makeLibraryPath [ stdenv.cc.cc ]; - binPath = with lib; makeBinPath [ + binPath = lib.makeBinPath [ bash getopt gawk