From 0b433a2fa78440a1b8779b82f4729f76efcc0458 Mon Sep 17 00:00:00 2001 From: June Date: Wed, 6 Dec 2023 01:11:25 +0100 Subject: [PATCH] Set PostgreSQL package to PostgreSQL 15 for netbox host Also remove the upgrade script again. Bascially do steps 4 and 5 of the following section of the manual: https://nixos.org/manual/nixos/stable/#module-services-postgres-upgrading --- config/hosts/netbox/postgresql.nix | 32 +++--------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/config/hosts/netbox/postgresql.nix b/config/hosts/netbox/postgresql.nix index 9c13e59..5f49f30 100644 --- a/config/hosts/netbox/postgresql.nix +++ b/config/hosts/netbox/postgresql.nix @@ -1,33 +1,7 @@ { pkgs, config, ... }: { - # Modified version of the script for upgrading PostgreSQL from here: - # https://nixos.org/manual/nixos/stable/#module-services-postgres-upgrading - environment.systemPackages = [ - (let - newPostgres = pkgs.postgresql_15; - in pkgs.writeScriptBin "upgrade-pg-cluster" '' - set -eux - - systemctl stop netbox.service netbox-rq.service - systemctl stop redis-netbox.service - systemctl stop postgresql.service - - export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}" - - export NEWBIN="${newPostgres}/bin" - - export OLDDATA="${config.services.postgresql.dataDir}" - export OLDBIN="${config.services.postgresql.package}/bin" - - install -d -m 0700 -o postgres -g postgres "$NEWDATA" - cd "$NEWDATA" - sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" - - sudo -u postgres $NEWBIN/pg_upgrade \ - --old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ - --old-bindir $OLDBIN --new-bindir $NEWBIN \ - "$@" - '') - ]; + services.postgresql = { + package = pkgs.postgresql_15; + }; }