diff --git a/.gitignore b/.gitignore index 732f8b6..9fcfed7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .env result -result-man/ +result-man rust-toolchain.toml target/ diff --git a/nixos/module/generic/placeholder.nix b/nixos/module/generic/placeholder.nix deleted file mode 100644 index c157af7..0000000 --- a/nixos/module/generic/placeholder.nix +++ /dev/null @@ -1 +0,0 @@ -{ ... }: {} diff --git a/nixos/module/generic/postgresql.nix b/nixos/module/generic/postgresql.nix new file mode 100644 index 0000000..992639c --- /dev/null +++ b/nixos/module/generic/postgresql.nix @@ -0,0 +1,67 @@ +{ + inputs, + self, + flake +}: +{ + pkgs, + config, + lib, + ... +}: let + system = pkgs.system; + cfg = config.services.postgresql; + extensionFlags = { + pg_cron = false; + pgjwt = false; + pg_net = false; + pg_smtp_client = false; + http = false; + plsh = false; + hemar = false; + }; +in { + options = { + services.postgresql = { + lazzyExtensions = lib.mkOption { + type = lib.types.attrsOf lib.types.bool; + default = extensionFlags; + }; + environment = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = {}; + }; + }; + }; + config = lib.mkIf cfg.enable { + systemd.services.postgresql.environment = cfg.environment; + services.postgresql = { + settings.shared_preload_libraries = + lib.concatStringsSep ", " + (lib.attrNames ( + lib.filterAttrs (n: v: v && + n != "http" + && n != "plsh" + && n != "pgjwt" + && n != "pg_smtp_client" + ) cfg.lazzyExtensions)); + + extensions = let + packages = { + inherit (cfg.package.pkgs) pg_net pgjwt pg_cron http pg_smtp_client plsh; + hemar = inputs.hutil.packages.${system}.pg-15-hemar; + }; + in + lib.attrValues ( + lib.filterAttrs (n: v: v != null) + (lib.mapAttrs' ( + name: enabled: + if enabled + then lib.nameValuePair name (packages.${name} or (throw "Package ${name} not found in pkgs")) + else null + ) + cfg.lazzyExtensions) + ); + }; + }; +} diff --git a/result-man b/result-man deleted file mode 120000 index ceef440..0000000 --- a/result-man +++ /dev/null @@ -1 +0,0 @@ -/nix/store/914rqhi68mlykix1dd72rspwc5zmnj4g-postgresql-15.7-man \ No newline at end of file