From 59180328cda59817d71cd58c8f48ead047375064 Mon Sep 17 00:00:00 2001 From: azahi Date: Mon, 17 Feb 2025 02:21:56 +0300 Subject: 2025-02-17 --- modules/postgresql.nix | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'modules/postgresql.nix') diff --git a/modules/postgresql.nix b/modules/postgresql.nix index f88831b..d5b712c 100644 --- a/modules/postgresql.nix +++ b/modules/postgresql.nix @@ -6,22 +6,21 @@ this, ... }: -with lib; let cfg = config.nixfiles.modules.postgresql; in { options.nixfiles.modules.postgresql = { - enable = mkEnableOption "PostgreSQL"; + enable = lib.mkEnableOption "PostgreSQL"; - package = mkOption { - type = types.package; + package = lib.mkOption { + type = lib.types.package; default = pkgs.postgresql_15; description = "PostgreSQL package to use."; }; - extraPostStart = mkOption { - type = with types; listOf str; + extraPostStart = lib.mkOption { + type = with lib.types; listOf str; default = [ ]; description = '' Additional post-startup commands. @@ -32,10 +31,10 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { - assertion = any (x: x == "en_GB.UTF-8/UTF-8") config.i18n.supportedLocales; + assertion = lib.any (x: x == "en_GB.UTF-8/UTF-8") config.i18n.supportedLocales; message = "The locale must be available"; } ]; @@ -70,14 +69,14 @@ in prometheus.exporters.postgres = { enable = true; - listenAddress = mkDefault this.wireguard.ipv4.address; - port = mkDefault 9187; + listenAddress = lib.mkDefault this.wireguard.ipv4.address; + port = lib.mkDefault 9187; }; }; - systemd.services.postgresql.postStart = optionalString ( + systemd.services.postgresql.postStart = lib.optionalString ( cfg.extraPostStart != [ ] - ) concatLines cfg.extraPostStart; + ) lib.concatLines cfg.extraPostStart; environment.variables.PSQLRC = toString ( pkgs.writeText "psqlrc" '' -- cgit 1.4.1