From 522124e8c7f314c28145362a4ff288aea7bb6d5d Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sat, 16 Dec 2023 20:36:39 -0600 Subject: [PATCH] plugin options --- flake.nix | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 5e9df75..050be4a 100644 --- a/flake.nix +++ b/flake.nix @@ -123,6 +123,37 @@ }; default = {}; }; + plugins = lib.options.mkOption { + type = lib.types.submodule { + options = { + pgvecto-rs = lib.options.mkOption { + type = lib.types.submodule { + options = { + enable = lib.options.mkOption { + description = "Enable pgvecto.rs plugin"; + type = lib.types.bool; + default = true; + }; + }; + }; + default = {}; + }; + postgis = lib.options.mkOption { + type = lib.types.submodule { + options = { + enable = lib.options.mkOption { + description = "Enable postgis plugin"; + type = lib.types.bool; + default = true; + }; + }; + }; + default = {}; + }; + }; + }; + default = {}; + }; replication = lib.options.mkOption { type = lib.types.submodule { options = { @@ -366,10 +397,17 @@ escapeShell = value: lib.replaceStrings ["$"] ["\\$"] value; postgresql = pkgs.postgresql_15.withPackages ( - plugins: [ - plugins.postgis - self.packages.${pkgs.system}.pgvecto-rs - ] + plugins: + ( + lib.optionals cfg.plugins.postgis.enable [ + plugins.postgis + ] + ) + ++ ( + lib.optionals cfg.plugins.pgvecto-rs.enable [ + self.packages.${pkgs.system}.pgvecto-rs + ] + ) ); # rcloneConfig = pkgs.writeTextFile { @@ -633,7 +671,7 @@ password_encryption = "scram-sha-256"; port = cfg.port; shared_buffers = "128MB"; - shared_preload_libraries = "\"vectors.so\""; + shared_preload_libraries = lib.strings.concatStringsSep "," (lib.optionals cfg.plugins.pgvecto-rs.enable ["vectors.so"]); ssl = "on"; ssl_cert_file = "/run/credentials/postgresql.service/fullchain.pem"; ssl_key_file = "/run/credentials/postgresql.service/key.pem";