From 261e4890fbfeb9f544fb9e7fcfa6b9bd8dd7d043 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sun, 8 Dec 2024 13:18:24 +0100 Subject: [PATCH] nixos/services.memcached: remove `with lib;` --- .../modules/services/databases/memcached.nix | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/databases/memcached.nix b/nixos/modules/services/databases/memcached.nix index 7a3afc5efafc..29da763e5751 100644 --- a/nixos/modules/services/databases/memcached.nix +++ b/nixos/modules/services/databases/memcached.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.memcached; @@ -17,42 +14,42 @@ in options = { services.memcached = { - enable = mkEnableOption "Memcached"; + enable = lib.mkEnableOption "Memcached"; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "memcached"; description = "The user to run Memcached as"; }; - listen = mkOption { - type = types.str; + listen = lib.mkOption { + type = lib.types.str; default = "127.0.0.1"; description = "The IP address to bind to."; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 11211; description = "The port to bind to."; }; - enableUnixSocket = mkEnableOption "Unix Domain Socket at /run/memcached/memcached.sock instead of listening on an IP address and port. The `listen` and `port` options are ignored"; + enableUnixSocket = lib.mkEnableOption "Unix Domain Socket at /run/memcached/memcached.sock instead of listening on an IP address and port. The `listen` and `port` options are ignored"; - maxMemory = mkOption { - type = types.ints.unsigned; + maxMemory = lib.mkOption { + type = lib.types.ints.unsigned; default = 64; description = "The maximum amount of memory to use for storage, in megabytes."; }; - maxConnections = mkOption { - type = types.ints.unsigned; + maxConnections = lib.mkOption { + type = lib.types.ints.unsigned; default = 1024; description = "The maximum number of simultaneous connections."; }; - extraOptions = mkOption { - type = types.listOf types.str; + extraOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "A list of extra options that will be added as a suffix when running memcached."; }; @@ -62,14 +59,14 @@ in ###### implementation - config = mkIf config.services.memcached.enable { + config = lib.mkIf config.services.memcached.enable { - users.users = optionalAttrs (cfg.user == "memcached") { + users.users = lib.optionalAttrs (cfg.user == "memcached") { memcached.description = "Memcached server user"; memcached.isSystemUser = true; memcached.group = "memcached"; }; - users.groups = optionalAttrs (cfg.user == "memcached") { memcached = {}; }; + users.groups = lib.optionalAttrs (cfg.user == "memcached") { memcached = {}; }; environment.systemPackages = [ memcached ]; @@ -85,7 +82,7 @@ in networking = if cfg.enableUnixSocket then "-s /run/memcached/memcached.sock" else "-l ${cfg.listen} -p ${toString cfg.port}"; - in "${memcached}/bin/memcached ${networking} -m ${toString cfg.maxMemory} -c ${toString cfg.maxConnections} ${concatStringsSep " " cfg.extraOptions}"; + in "${memcached}/bin/memcached ${networking} -m ${toString cfg.maxMemory} -c ${toString cfg.maxConnections} ${lib.concatStringsSep " " cfg.extraOptions}"; User = cfg.user; @@ -110,7 +107,7 @@ in }; }; imports = [ - (mkRemovedOptionModule ["services" "memcached" "socket"] '' + (lib.mkRemovedOptionModule ["services" "memcached" "socket"] '' This option was replaced by a fixed unix socket path at /run/memcached/memcached.sock enabled using services.memcached.enableUnixSocket. '') ];