diff --git a/modules/profiles/media-management/tracearr/default.nix b/modules/profiles/media-management/tracearr/default.nix index 8783a460..91edcaab 100644 --- a/modules/profiles/media-management/tracearr/default.nix +++ b/modules/profiles/media-management/tracearr/default.nix @@ -3,7 +3,7 @@ # `ALTER EXTENSION timescaledb UPDATE;` in the `tracearr` database # # See: https://github.com/NixOS/nixpkgs/issues/214367 -{ config, ... }: { +{ config, pkgs, ... }: { sops.secrets = { maxmind_license_key = { sopsFile = ./secrets.yml; @@ -36,5 +36,20 @@ trustProxy = true; }; + systemd.services."migrate-tracearr-db-timescale-extension" = { + requiredBy = [ "tracearr.service" ]; + before = [ "tracearr.service" ]; + after = [ "postgresql.target" ]; + environment.PGPORT = toString config.services.postgresql.settings.port; + path = [ pkgs.postgresql ]; + serviceConfig = { + Type = "oneshot"; + User = "postgres"; + }; + script = '' + psql tracearr -c 'ALTER EXTENSION timescaledb UPDATE;' + ''; + }; + services.postgresqlBackup.databases = [ "tracearr" ]; } diff --git a/modules/profiles/networking/blocky/default.nix b/modules/profiles/networking/blocky/default.nix index db07fd3f..ea36b800 100644 --- a/modules/profiles/networking/blocky/default.nix +++ b/modules/profiles/networking/blocky/default.nix @@ -42,6 +42,7 @@ }; denylists = { ads = [ "https://big.oisd.nl/domainswild" ]; + ps5 = [ ]; }; allowlists = { ads = [ @@ -52,9 +53,21 @@ link.dwell.com '') ]; + ps5 = [ + (pkgs.writeText "ps5-allowlist.txt" '' + googleads.g.doubleclick.net + insights-collector.newrelic.com + smetrics.aem.playstation.com + static.doubleclick.net + '') + ]; }; clientGroupsBlock = { default = [ "ads" ]; + "10.100.0.101/32" = [ + "ads" + "ps5" + ]; }; }; caching = { diff --git a/modules/profiles/networking/blocky/postgresql.nix b/modules/profiles/networking/blocky/postgresql.nix index 79f9a6f3..939a8bb2 100644 --- a/modules/profiles/networking/blocky/postgresql.nix +++ b/modules/profiles/networking/blocky/postgresql.nix @@ -1,7 +1,22 @@ -{ profiles, ... }: { +{ + config, + pkgs, + profiles, + ... +}: +{ imports = [ profiles.databases.postgresql ]; services.postgresql = { + extensions = + ps: with ps; [ + timescaledb + timescaledb_toolkit + ]; + settings = { + shared_preload_libraries = [ "timescaledb" ]; + max_locks_per_transaction = 256; + }; initialScriptText = '' CREATE ROLE blocky WITH LOGIN PASSWORD 'blocky' CREATEDB; CREATE DATABASE blocky; @@ -20,9 +35,9 @@ }; services.blocky.settings.queryLog = { - type = "postgresql"; + type = "timescale"; target = "postgres://blocky:blocky@localhost:5432/blocky"; - logRetentionDays = 90; + logRetentionDays = 180; flushInterval = "5s"; }; @@ -33,4 +48,21 @@ RestartSec = "1"; }; }; + + services.postgresqlBackup.databases = [ "blocky" ]; + + systemd.services."migrate-tracearr-db-timescale-extension" = { + requiredBy = [ "tracearr.service" ]; + before = [ "tracearr.service" ]; + after = [ "postgresql.target" ]; + environment.PGPORT = toString config.services.postgresql.settings.port; + path = [ pkgs.postgresql ]; + serviceConfig = { + Type = "oneshot"; + User = "postgres"; + }; + script = '' + psql tracearr -c 'ALTER EXTENSION timescaledb UPDATE;' + ''; + }; }