Unverified Commit 2d2b5e26 authored by Thiago Kenji Okada's avatar Thiago Kenji Okada Committed by GitHub
Browse files

treewide/nixos: remove `with lib;` part 10 (#369233)

parents 2332ceb4 336a76b1
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@
  pkgs,
  ...
}:

with lib;

let

  cfg = config.services.manticore;
@@ -14,7 +11,7 @@ let

  toSphinx =
    {
      mkKeyValue ? generators.mkKeyValueDefault { } "=",
      mkKeyValue ? lib.generators.mkKeyValueDefault { } "=",
      listsAsDuplicateKeys ? true,
    }:
    attrsOfAttrs:
@@ -22,7 +19,7 @@ let
      # map function to string for each key val
      mapAttrsToStringsSep =
        sep: mapFn: attrs:
        concatStringsSep sep (mapAttrsToList mapFn attrs);
        lib.concatStringsSep sep (lib.mapAttrsToList mapFn attrs);
      mkSection =
        sectName: sectValues:
        ''
@@ -46,9 +43,9 @@ in
  options = {
    services.manticore = {

      enable = mkEnableOption "Manticoresearch";
      enable = lib.mkEnableOption "Manticoresearch";

      settings = mkOption {
      settings = lib.mkOption {
        default = {
          searchd = {
            listen = [
@@ -67,10 +64,10 @@ in
          <https://manual.manticoresearch.com/Server%20settings>
          for more information.
        '';
        type = types.submodule {
        type = lib.types.submodule {
          freeformType = format.type;
        };
        example = literalExpression ''
        example = lib.literalExpression ''
          {
            searchd = {
                listen = [
@@ -90,7 +87,7 @@ in
    };
  };

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {

    systemd = {
      packages = [ pkgs.manticoresearch ];
+22 −25
Original line number Diff line number Diff line
@@ -4,16 +4,13 @@
  pkgs,
  ...
}:

with lib;

let
  cfg = config.services.meilisearch;

in
{

  meta.maintainers = with maintainers; [
  meta.maintainers = with lib.maintainers; [
    Br1ght0ne
    happysalada
  ];
@@ -22,37 +19,37 @@ in
  ###### interface

  options.services.meilisearch = {
    enable = mkEnableOption "MeiliSearch - a RESTful search API";
    enable = lib.mkEnableOption "MeiliSearch - a RESTful search API";

    package = mkPackageOption pkgs "meilisearch" {
    package = lib.mkPackageOption pkgs "meilisearch" {
      extraDescription = ''
        Use this if you require specific features to be enabled. The default package has no features.
      '';
    };

    listenAddress = mkOption {
    listenAddress = lib.mkOption {
      description = "MeiliSearch listen address.";
      default = "127.0.0.1";
      type = types.str;
      type = lib.types.str;
    };

    listenPort = mkOption {
    listenPort = lib.mkOption {
      description = "MeiliSearch port to listen on.";
      default = 7700;
      type = types.port;
      type = lib.types.port;
    };

    environment = mkOption {
    environment = lib.mkOption {
      description = "Defines the running environment of MeiliSearch.";
      default = "development";
      type = types.enum [
      type = lib.types.enum [
        "development"
        "production"
      ];
    };

    # TODO change this to LoadCredentials once possible
    masterKeyEnvironmentFile = mkOption {
    masterKeyEnvironmentFile = lib.mkOption {
      description = ''
        Path to file which contains the master key.
        By doing so, all routes will be protected and will require a key to be accessed.
@@ -61,10 +58,10 @@ in
        MEILI_MASTER_KEY=my_secret_key
      '';
      default = null;
      type = with types; nullOr path;
      type = with lib.types; nullOr path;
    };

    noAnalytics = mkOption {
    noAnalytics = lib.mkOption {
      description = ''
        Deactivates analytics.
        Analytics allow MeiliSearch to know how many users are using MeiliSearch,
@@ -72,10 +69,10 @@ in
        This process is entirely anonymous.
      '';
      default = true;
      type = types.bool;
      type = lib.types.bool;
    };

    logLevel = mkOption {
    logLevel = lib.mkOption {
      description = ''
        Defines how much detail should be present in MeiliSearch's logs.
        MeiliSearch currently supports four log levels, listed in order of increasing verbosity:
@@ -86,10 +83,10 @@ in
          Useful when diagnosing issues and debugging
      '';
      default = "INFO";
      type = types.str;
      type = lib.types.str;
    };

    maxIndexSize = mkOption {
    maxIndexSize = lib.mkOption {
      description = ''
        Sets the maximum size of the index.
        Value must be given in bytes or explicitly stating a base unit.
@@ -97,10 +94,10 @@ in
        Default is 100 GiB
      '';
      default = "107374182400";
      type = types.str;
      type = lib.types.str;
    };

    payloadSizeLimit = mkOption {
    payloadSizeLimit = lib.mkOption {
      description = ''
        Sets the maximum size of accepted JSON payloads.
        Value must be given in bytes or explicitly stating a base unit.
@@ -108,14 +105,14 @@ in
        Default is ~ 100 MB
      '';
      default = "104857600";
      type = types.str;
      type = lib.types.str;
    };

  };

  ###### implementation

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {

    # used to restore dumps
    environment.systemPackages = [ cfg.package ];
@@ -127,7 +124,7 @@ in
      environment = {
        MEILI_DB_PATH = "/var/lib/meilisearch";
        MEILI_HTTP_ADDR = "${cfg.listenAddress}:${toString cfg.listenPort}";
        MEILI_NO_ANALYTICS = boolToString cfg.noAnalytics;
        MEILI_NO_ANALYTICS = lib.boolToString cfg.noAnalytics;
        MEILI_ENV = cfg.environment;
        MEILI_DUMP_DIR = "/var/lib/meilisearch/dumps";
        MEILI_LOG_LEVEL = cfg.logLevel;
@@ -137,7 +134,7 @@ in
        ExecStart = "${cfg.package}/bin/meilisearch";
        DynamicUser = true;
        StateDirectory = "meilisearch";
        EnvironmentFile = mkIf (cfg.masterKeyEnvironmentFile != null) cfg.masterKeyEnvironmentFile;
        EnvironmentFile = lib.mkIf (cfg.masterKeyEnvironmentFile != null) cfg.masterKeyEnvironmentFile;
      };
    };
  };
+6 −9
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@
  pkgs,
  ...
}:

with lib;

let
  cfg = config.services.opensearch;

@@ -28,7 +25,7 @@ in
{

  options.services.opensearch = {
    enable = mkEnableOption "OpenSearch";
    enable = lib.mkEnableOption "OpenSearch";

    package = lib.mkPackageOption pkgs "OpenSearch" {
      default = [ "opensearch" ];
@@ -113,13 +110,13 @@ in
        rootLogger.level = info
        rootLogger.appenderRef.console.ref = console
      '';
      type = types.str;
      type = lib.types.str;
    };

    dataDir = lib.mkOption {
      type = lib.types.path;
      default = "/var/lib/opensearch";
      apply = converge (removeSuffix "/");
      apply = lib.converge (lib.removeSuffix "/");
      description = ''
        Data directory for OpenSearch. If you change this, you need to
        manually create the directory. You also need to create the
@@ -173,7 +170,7 @@ in
    };
  };

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {
    systemd.services.opensearch = {
      description = "OpenSearch Daemon";
      wantedBy = [ "multi-user.target" ];
@@ -194,7 +191,7 @@ in
                  set -o errexit -o pipefail -o nounset -o errtrace
                  shopt -s inherit_errexit
                ''
                + (optionalString (!config.boot.isContainer) ''
                + (lib.optionalString (!config.boot.isContainer) ''
                  # Only set vm.max_map_count if lower than ES required minimum
                  # This avoids conflict if configured via boot.kernel.sysctl
                  if [ $(${pkgs.procps}/bin/sysctl -n vm.max_map_count) -lt 262144 ]; then
@@ -268,7 +265,7 @@ in
          TimeoutStartSec = "infinity";
          DynamicUser = usingDefaultUserAndGroup && usingDefaultDataDir;
        }
        // (optionalAttrs (usingDefaultDataDir) {
        // (lib.optionalAttrs (usingDefaultDataDir) {
          StateDirectory = "opensearch";
          StateDirectoryMode = "0700";
        });
+34 −36
Original line number Diff line number Diff line
@@ -4,8 +4,6 @@
  pkgs,
  ...
}:

with lib;
let

  cfg = config.services.qdrant;
@@ -17,9 +15,9 @@ in

  options = {
    services.qdrant = {
      enable = mkEnableOption "Vector Search Engine for the next generation of AI applications";
      enable = lib.mkEnableOption "Vector Search Engine for the next generation of AI applications";

      settings = mkOption {
      settings = lib.mkOption {
        description = ''
          Configuration for Qdrant
          Refer to <https://github.com/qdrant/qdrant/blob/master/config/config.yaml> for details on supported values.
@@ -43,7 +41,7 @@ in
          telemetry_disabled = true;
        };

        defaultText = literalExpression ''
        defaultText = lib.literalExpression ''
          {
            storage = {
              storage_path = "/var/lib/qdrant/storage";
@@ -64,41 +62,41 @@ in
    };
  };

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {
    services.qdrant.settings = {
      service.static_content_dir = mkDefault pkgs.qdrant-web-ui;
      storage.storage_path = mkDefault "/var/lib/qdrant/storage";
      storage.snapshots_path = mkDefault "/var/lib/qdrant/snapshots";
      service.static_content_dir = lib.mkDefault pkgs.qdrant-web-ui;
      storage.storage_path = lib.mkDefault "/var/lib/qdrant/storage";
      storage.snapshots_path = lib.mkDefault "/var/lib/qdrant/snapshots";
      # The following default values are the same as in the default config,
      # they are just written here for convenience.
      storage.on_disk_payload = mkDefault true;
      storage.wal.wal_capacity_mb = mkDefault 32;
      storage.wal.wal_segments_ahead = mkDefault 0;
      storage.performance.max_search_threads = mkDefault 0;
      storage.performance.max_optimization_threads = mkDefault 1;
      storage.optimizers.deleted_threshold = mkDefault 0.2;
      storage.optimizers.vacuum_min_vector_number = mkDefault 1000;
      storage.optimizers.default_segment_number = mkDefault 0;
      storage.optimizers.max_segment_size_kb = mkDefault null;
      storage.optimizers.memmap_threshold_kb = mkDefault null;
      storage.optimizers.indexing_threshold_kb = mkDefault 20000;
      storage.optimizers.flush_interval_sec = mkDefault 5;
      storage.optimizers.max_optimization_threads = mkDefault 1;
      storage.hnsw_index.m = mkDefault 16;
      storage.hnsw_index.ef_construct = mkDefault 100;
      storage.hnsw_index.full_scan_threshold_kb = mkDefault 10000;
      storage.hnsw_index.max_indexing_threads = mkDefault 0;
      storage.hnsw_index.on_disk = mkDefault false;
      storage.hnsw_index.payload_m = mkDefault null;
      service.max_request_size_mb = mkDefault 32;
      service.max_workers = mkDefault 0;
      service.http_port = mkDefault 6333;
      service.grpc_port = mkDefault 6334;
      service.enable_cors = mkDefault true;
      cluster.enabled = mkDefault false;
      storage.on_disk_payload = lib.mkDefault true;
      storage.wal.wal_capacity_mb = lib.mkDefault 32;
      storage.wal.wal_segments_ahead = lib.mkDefault 0;
      storage.performance.max_search_threads = lib.mkDefault 0;
      storage.performance.max_optimization_threads = lib.mkDefault 1;
      storage.optimizers.deleted_threshold = lib.mkDefault 0.2;
      storage.optimizers.vacuum_min_vector_number = lib.mkDefault 1000;
      storage.optimizers.default_segment_number = lib.mkDefault 0;
      storage.optimizers.max_segment_size_kb = lib.mkDefault null;
      storage.optimizers.memmap_threshold_kb = lib.mkDefault null;
      storage.optimizers.indexing_threshold_kb = lib.mkDefault 20000;
      storage.optimizers.flush_interval_sec = lib.mkDefault 5;
      storage.optimizers.max_optimization_threads = lib.mkDefault 1;
      storage.hnsw_index.m = lib.mkDefault 16;
      storage.hnsw_index.ef_construct = lib.mkDefault 100;
      storage.hnsw_index.full_scan_threshold_kb = lib.mkDefault 10000;
      storage.hnsw_index.max_indexing_threads = lib.mkDefault 0;
      storage.hnsw_index.on_disk = lib.mkDefault false;
      storage.hnsw_index.payload_m = lib.mkDefault null;
      service.max_request_size_mb = lib.mkDefault 32;
      service.max_workers = lib.mkDefault 0;
      service.http_port = lib.mkDefault 6333;
      service.grpc_port = lib.mkDefault 6334;
      service.enable_cors = lib.mkDefault true;
      cluster.enabled = lib.mkDefault false;
      # the following have been altered for security
      service.host = mkDefault "127.0.0.1";
      telemetry_disabled = mkDefault true;
      service.host = lib.mkDefault "127.0.0.1";
      telemetry_disabled = lib.mkDefault true;
    };

    systemd.services.qdrant = {
+5 −8
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@
  pkgs,
  ...
}:

with lib;

let
  cfg = config.services.quickwit;

@@ -19,7 +16,7 @@ in
{

  options.services.quickwit = {
    enable = mkEnableOption "Quickwit";
    enable = lib.mkEnableOption "Quickwit";

    package = lib.mkPackageOption pkgs "Quickwit" {
      default = [ "quickwit" ];
@@ -83,7 +80,7 @@ in
    dataDir = lib.mkOption {
      type = lib.types.path;
      default = "/var/lib/quickwit";
      apply = converge (removeSuffix "/");
      apply = lib.converge (lib.removeSuffix "/");
      description = ''
        Data directory for Quickwit. If you change this, you need to
        manually create the directory. You also need to create the
@@ -130,7 +127,7 @@ in
    };
  };

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {
    systemd.services.quickwit = {
      description = "Quickwit";
      wantedBy = [ "multi-user.target" ];
@@ -143,7 +140,7 @@ in
        {
          ExecStart = ''
            ${cfg.package}/bin/quickwit run --config ${quickwitYml} \
            ${escapeShellArgs cfg.extraFlags}
            ${lib.escapeShellArgs cfg.extraFlags}
          '';
          User = cfg.user;
          Group = cfg.group;
@@ -186,7 +183,7 @@ in
            "@chown"
          ];
        }
        // (optionalAttrs (usingDefaultDataDir) {
        // (lib.optionalAttrs (usingDefaultDataDir) {
          StateDirectory = "quickwit";
          StateDirectoryMode = "0700";
        });
Loading