diff options
Diffstat (limited to 'modules/postgresql.nix')
-rw-r--r-- | modules/postgresql.nix | 23 |
1 files changed, 11 insertions, 12 deletions
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" '' |