diff --git a/server/configuration.org b/server/configuration.org index dfd6c5a..6f5088a 100644 --- a/server/configuration.org +++ b/server/configuration.org @@ -32,7 +32,7 @@ configurations. #+begin_src nix { config, pkgs, lib, ... }: let - version = "23.05"; + version = "23.11"; myEmail = "CaptainJawZ@outlook.com"; myName = "Danilo Reyes"; cpuArchitecture = "skylake"; @@ -277,7 +277,6 @@ nixpkgs = { allowUnfree = true; permittedInsecurePackages = [ "openssl-1.1.1w" - "nodejs-14.21.3" ]; }; # localSystem = { @@ -383,7 +382,7 @@ fzf # fuzzy finder! super cool and useful gdu # disk-space utility, somewhat useful du-dust # rusty du trash-cli # oop! didn't meant to delete that -unstable.eza # like ls but with colors +eza # like ls but with colors rmlint # probably my favourite app, amazing dupe finder that integrates well with BTRFS smartmontools # check hard drie health #+end_src @@ -707,6 +706,34 @@ environment = { dlib fd ripgrep + # Upgrades postgres + (let + # XXX specify the postgresql package you'd like to upgrade to. + # Do not forget to list the extensions you need. + newPostgres = pkgs.postgresql_16.withPackages (pp: [ + # pp.plv8 + ]); + in pkgs.writeScriptBin "upgrade-pg-cluster" '' + set -eux + # XXX it's perhaps advisable to stop all services that depend on postgresql + systemctl stop postgresql + + 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 \ + "$@" + '') ]; variables = rec { # PATH diff --git a/server/servers.nix b/server/servers.nix index e819b48..e3ec3ac 100644 --- a/server/servers.nix +++ b/server/servers.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, modulesPath, ... }: let localhost = "127.0.0.1"; - postgresPort = toString (config.services.postgresql.port); + postgresSocket = "/run/postgresql"; unstable = import (builtins.fetchTarball "https://github.com/nixos/nixpkgs/tarball/master") { config = config.nixpkgs.config; @@ -19,7 +19,9 @@ in { nextcloud = base // { extraGroups = [ "render" ]; packages = (with pkgs; [ - nodejs_14 + nodejs + python3 + python3Packages.tensorflowWithCuda perl (perlPackages.buildPerlPackage rec { pname = "Image-ExifTool"; @@ -38,8 +40,8 @@ in { group = "piracy"; }; in { - sonarr = base // { package = unstable.pkgs.sonarr; }; - radarr = base // { package = unstable.pkgs.radarr; }; + sonarr = base // { package = pkgs.sonarr; }; + radarr = base // { package = pkgs.radarr; }; bazarr = base // { }; jellyfin = base // { }; prowlarr.enable = true; @@ -49,11 +51,8 @@ in { consumptionDirIsPublic = true; extraConfig = { PAPERLESS_DBENGINE = "postgress"; - PAPERLESS_DBHOST = "${localhost}"; PAPERLESS_DBNAME = "paperless"; - PAPERLESS_DBUSER = "paperless"; - PAPERLESS_DBPASS = "sopacerias"; - PAPERLESS_DBPORT = "${postgresPort}"; + PAPERLESS_DBHOST = postgresSocket; PAPERLESS_CONSUMER_IGNORE_PATTERN = builtins.toJSON [ ".DS_STORE/*" "desktop.ini" ]; PAPERLESS_TIME_ZONE = "America/Mexico_City"; @@ -66,15 +65,14 @@ in { vaultwarden = { enable = true; dbBackend = "postgresql"; - package = unstable.pkgs.vaultwarden; + package = pkgs.vaultwarden; config = { ROCKET_ADDRESS = "${localhost}"; ROCKET_PORT = 8222; WEBSOCKET_PORT = 8333; ADMIN_TOKEN = "x9BLqz2QmnU5RmrMLt2kPpoPBTNPZxNFw/b8XrPgpQML2/01+MYENl87dmhDX+Jm"; - DATABASE_URL = - "postgresql://vaultwarden:sopacerias@${localhost}:${postgresPort}/vaultwarden"; + DATABASE_URL = "postgresql:///vaultwarden?host=${postgresSocket}"; ENABLE_DB_WAL = false; WEBSOCKET_ENABLED = true; SHOW_PASSWORD_HINT = false; @@ -104,8 +102,7 @@ in { overwriteProtocol = "https"; defaultPhoneRegion = "MX"; dbtype = "pgsql"; - dbuser = "nextcloud"; - dbpassFile = "${pkgs.writeText "dbpass" "sopacerias"}"; + dbhost = postgresSocket; dbtableprefix = "oc_"; dbname = "nextcloud"; trustedProxies = [ "nginx" ]; @@ -153,22 +150,23 @@ in { postgresql = { enable = true; ensureDatabases = [ "paperless" "nextcloud" "mealie" "vaultwarden" ]; + package = pkgs.postgresql_16; ensureUsers = [ { name = "nextcloud"; - ensurePermissions = { "DATABASE nextcloud" = "ALL PRIVILEGES"; }; + ensureDBOwnership = true; } { name = "paperless"; - ensurePermissions = { "DATABASE paperless" = "ALL PRIVILEGES"; }; + ensureDBOwnership = true; } { name = "mealie"; - ensurePermissions = { "DATABASE mealie" = "ALL PRIVILEGES"; }; + ensureDBOwnership = true; } { name = "vaultwarden"; - ensurePermissions = { "DATABASE vaultwarden" = "ALL PRIVILEGES"; }; + ensureDBOwnership = true; } ]; authentication = pkgs.lib.mkOverride 10 ''