diff --git a/host/Rory-ovh/configuration.nix b/host/Rory-ovh/configuration.nix
new file mode 100755
index 0000000..ec2dc13
--- /dev/null
+++ b/host/Rory-ovh/configuration.nix
@@ -0,0 +1,96 @@
+{
+ pkgs,
+ lib,
+ nixpkgs-master,
+ matrix-synapse-unwrapped-patched,
+ draupnir,
+ spacebar,
+ ...
+}:
+
+{
+ imports = [
+ ../../modules/base-server.nix
+
+ ./services/nginx/nginx.nix
+ ./services/postgres.nix
+ ./vm.nix
+ ];
+ boot.loader.grub.devices = lib.mkForce [ "nodev" ];
+
+ networking = {
+ hostName = "Rory-ovh";
+ nat = {
+ enable = true;
+ internalInterfaces = [
+ "ve-+"
+ "vb-+"
+ ];
+ externalInterface = "enp98s0f0";
+ enableIPv6 = false;
+ };
+ enableIPv6 = lib.mkForce false;
+ nameservers = lib.mkForce [ "1.1.1.1" ];
+ firewall.enable = lib.mkForce true;
+ resolvconf.enable = false;
+ defaultGateway = lib.mkForce null;
+ defaultGateway6 = lib.mkForce null;
+ firewall.allowedTCPPorts = [
+ 25565
+ ];
+ };
+
+ systemd.network = {
+ enable = true;
+ networks.enp98s0f0 = {
+ name = "enp98s0f0";
+ DHCP = "no";
+ #gateway = [ "51.210.113.254" ];
+ routes = [
+ {
+ Gateway = "51.210.113.254";
+ GatewayOnLink = true;
+ }
+ ];
+ address = [ "51.210.113.110/32" ];
+ };
+ };
+
+ nixpkgs.config.permittedInsecurePackages = [
+ "olm-3.2.16"
+ "dotnet-runtime-wrapped-7.0.20"
+ "dotnet-runtime-7.0.20"
+ "dotnet-sdk-7.0.20"
+ ];
+ services.irqbalance.enable = true;
+
+ environment.memoryAllocator.provider = "jemalloc";
+
+ networking.firewall.interfaces."ve-spacebar".allowedTCPPorts = [ 5432 ];
+ containers."spacebar" = import ./services/containers/spacebar/container.nix {
+ inherit
+ pkgs
+ lib
+ spacebar
+ ;
+ };
+
+ # prevent a hang on rebuild with forgotten shells...
+ systemd.services."container@spacebar" = {
+ # dependency on postgres for good measure...
+ after = [ "postgresql.service" ];
+ wants = [ "postgresql.service" ];
+ # preStop = ''
+ # for pid in $(pgrep -f "nixos-container root-login spacebar"); do
+ # echo "Killing shell with PID $pid"
+ # kill -9 "$pid"
+ # done
+ # '';
+ };
+
+ system.stateVersion = "22.11"; # DO NOT EDIT!
+
+ environment.systemPackages = with pkgs; [ waypipe ];
+
+ nix.nrBuildUsers = 128;
+}
diff --git a/host/Rory-ovh/services/containers/shared.nix b/host/Rory-ovh/services/containers/shared.nix
new file mode 100644
index 0000000..543e92a
--- /dev/null
+++ b/host/Rory-ovh/services/containers/shared.nix
@@ -0,0 +1,42 @@
+{ pkgs, lib, config, ... }:
+{
+ environment.systemPackages = with pkgs; [
+ lnav
+ lsd
+ htop
+ btop
+ duf
+ kitty.terminfo
+ neovim
+ jq
+ dig
+ ];
+
+ networking.resolvconf.enable = false;
+ networking.nameservers = [
+ "1.1.1.1"
+ "1.0.0.1"
+ "8.8.8.8"
+ "8.4.4.8"
+ ];
+
+ environment.etc."resolv.conf" = lib.mkDefault {
+ text = lib.concatStringsSep "\n" (
+ lib.optionals (config.networking ? nameservers) (map (nameserver: "nameserver ${nameserver}") (config.networking.nameservers))
+ #++ lib.optionals (config.networking ? enableIPv6 && !config.networking.enableIPv6) [ "options no-aaaa" ]
+ ++ lib.optionals (config.networking ? enableIPv6 && config.networking.enableIPv6) [
+ "options single-request"
+ "options single-request-reopen"
+ "options inet6"
+ ]
+ );
+ };
+
+ services.resolved = {
+ enable = lib.mkForce false;
+ dnssec = lib.mkForce "false";
+ dnsovertls = lib.mkForce "false";
+ };
+
+ systemd.oomd.enable = false; # Kinda useless in a container, lol
+}
diff --git a/host/Rory-ovh/services/containers/spacebar/container.nix b/host/Rory-ovh/services/containers/spacebar/container.nix
new file mode 100644
index 0000000..841a663
--- /dev/null
+++ b/host/Rory-ovh/services/containers/spacebar/container.nix
@@ -0,0 +1,35 @@
+{
+ spacebar,
+ ...
+}:
+
+{
+ privateNetwork = true;
+ autoStart = true;
+ specialArgs = {
+ inherit spacebar;
+ };
+ config =
+ { lib, pkgs, ... }:
+ {
+ imports = [
+ ../shared.nix
+ ./root.nix
+ ./services/spacebar.nix
+ ];
+ };
+ hostAddress = "192.168.100.1";
+ localAddress = "192.168.100.22";
+
+ #bindMounts."spacebar-storage" = {
+ # hostPath = "/data/dedicated/spacebar-storage";
+ # mountPoint = "/storage";
+ # isReadOnly = false;
+ #};
+
+ #bindMounts."spacebar-secrets" = {
+ # hostPath = "/data/secrets/spacebar";
+ # mountPoint = "/run/secrets/spacebar";
+ # isReadOnly = true;
+ #};
+}
diff --git a/host/Rory-ovh/services/containers/spacebar/root.nix b/host/Rory-ovh/services/containers/spacebar/root.nix
new file mode 100644
index 0000000..cb7d3cd
--- /dev/null
+++ b/host/Rory-ovh/services/containers/spacebar/root.nix
@@ -0,0 +1,33 @@
+{ pkgs, ... }:
+
+{
+ networking.useHostResolvConf = true;
+
+ networking.hosts = {
+ "192.168.100.1" = [
+ "matrix.rory.gay"
+ "rory.gay"
+ ];
+ };
+
+ networking.firewall = {
+ enable = true;
+ allowedTCPPorts = [
+ 3001
+ 3002
+ 3003
+ ];
+ };
+
+ # check that we can reach the database server before starting the service
+ #systemd.services."spacebar-apply-migrations" =
+ # let
+ # address = "192.168.100.1";
+ # in
+ # {
+ # path = [ pkgs.netcat pkgs.bash ];
+ # serviceConfig = {
+ # ExecStartPre = "${pkgs.bash}/bin/sh -c 'until ${pkgs.netcat}/bin/nc -z ${address} 5432; do echo \"Waiting for database server...\"; sleep 0.2; done'";
+ # };
+ # };
+}
diff --git a/host/Rory-ovh/services/containers/spacebar/services/spacebar.nix b/host/Rory-ovh/services/containers/spacebar/services/spacebar.nix
new file mode 100644
index 0000000..0c1b37c
--- /dev/null
+++ b/host/Rory-ovh/services/containers/spacebar/services/spacebar.nix
@@ -0,0 +1,181 @@
+{ spacebar, ... }:
+
+let
+ sb = import "${spacebar}/nix/modules/default/lib.nix";
+in
+{
+ imports = [ spacebar.nixosModules.default ];
+ services.spacebarchat-server = {
+ enable = true;
+ serverName = "spacebar.chat";
+ apiEndpoint = sb.mkEndpoint "api.rory.server.spacebar.chat" 3001 true;
+ gatewayEndpoint = sb.mkEndpoint "gateway.rory.server.spacebar.chat" 3002 true;
+ cdnEndpoint = sb.mkEndpoint "cdn.rory.server.spacebar.chat" 3003 true;
+ #cdnPath = "/storage";
+
+ #cdnSignaturePath = "/run/secrets/spacebar/cdnSignature";
+ #legacyJwtSecretPath = "/run/secrets/spacebar/legacyJwtSecret";
+ #mailjetApiKeyPath = "/run/secrets/spacebar/mailjetApiKey";
+ #mailjetApiSecretPath = "/run/secrets/spacebar/mailjetApiSecret";
+ ## smtpPasswordPath = "/run/secrets/spacebar/smtpPassword";
+ #gifApiKeyPath = "/run/secrets/spacebar/gifApiKey";
+ ## rabbitmqHostPath = "/run/secrets/spacebar/rabbitmqHost";
+ #abuseIpDbApiKeyPath = "/run/secrets/spacebar/abuseIpDbApiKey";
+ #captchaSecretKeyPath = "/run/secrets/spacebar/captchaSecretKey";
+ #captchaSiteKeyPath = "/run/secrets/spacebar/captchaSiteKey";
+ #ipdataApiKeyPath = "/run/secrets/spacebar/ipdataApiKey";
+ #requestSignaturePath = "/run/secrets/spacebar/requestSignature";
+
+ settings = {
+ security = {
+ forwardedFor = "X-Forwarded-For";
+ trustedProxies = "192.168.100.1, linklocal";
+ cdnSignUrls = true;
+ cdnSignatureIncludeIp = true;
+ cdnSignatureIncludeUserAgent = true;
+ cdnSignatureDuration = "5m";
+ };
+ general = {
+ frontPage = "https://spacebar.chat";
+ instanceDescription = "The official testing for Spacebar";
+ instanceId = "1007550087590649856";
+ instanceName = "Spacebar Staging Official";
+ publicUrl = "https://rory.server.spacebar.chat";
+ tosPage = "https://docs.spacebar.chat/contributing/conduct/";
+ correspondenceUserID = "1006598230156341276";
+ correspondenceEmail = "root@rory.gay";
+ };
+ guild = {
+ autoJoin = {
+ bots = false;
+ canLeave = true;
+ enabled = true;
+ guilds = [ "1006649183970562092" ];
+ };
+ };
+ limits = {
+ guild = {
+ maxMembers = 25000000;
+ maxEmojis = 2000;
+ maxChannelsInCategory = 65535;
+ maxChannels = 250;
+ maxRoles = 250;
+ maxBulkBanUsers = 200;
+ maxStickers = 500;
+ };
+ message = {
+ maxCharacters = 1048576;
+ maxTTSCharacters = 160;
+ maxReactions = 2048;
+ maxAttachmentSize = 1073741824;
+ maxEmbedDownloadSize = 5242880;
+ maxBulkDelete = 1000;
+ maxPreloadCount = 100;
+ };
+ channel = {
+ maxPins = 500;
+ maxTopic = 1024;
+ maxWebhooks = 100;
+ };
+ rate = {
+ ip = {
+ window = 5;
+ count = 500;
+ };
+ global = {
+ count = 250;
+ window = 5;
+ };
+ error = {
+ window = 5;
+ count = 10;
+ };
+ routes = {
+ guild = {
+ window = 5;
+ count = 5;
+ };
+ webhook = {
+ count = 10;
+ window = 5;
+ };
+ channel = {
+ count = 10;
+ window = 5;
+ };
+ auth = {
+ login = {
+ window = 60;
+ count = 5;
+ };
+ register = {
+ count = 2;
+ window = 43200;
+ };
+ };
+ };
+ enabled = false;
+ };
+ user = {
+ maxGuilds = 1000;
+ maxUsername = 64;
+ maxFriends = 2000;
+ maxBio = 500;
+ };
+ absoluteRate = {
+ register = {
+ limit = 25;
+ window = 3600000;
+ enabled = false;
+ };
+ sendMessage = {
+ limit = 120;
+ window = 60000;
+ enabled = false;
+ };
+ };
+ };
+ user = {
+ blockedContains = [
+ "discord"
+ "clyde"
+ "mail.ru"
+ "penis"
+ "child"
+ "admin"
+ "owner"
+ "moderator"
+ "Noruya"
+ "𝖞𝖔𝖗𝖚𝖟𝖆"
+ "spacebar"
+ "1488"
+ "hitler"
+ "nigger"
+ "nitro"
+ "monero"
+ "gmail.com"
+ "outlook.com"
+ "steam"
+ ];
+ };
+ };
+ extraEnvironment = {
+ DATABASE = "postgres://postgres:postgres@192.168.100.1/spacebar";
+ #WEBRTC_PORT_RANGE=60000-61000;
+ #PUBLIC_IP=216.230.228.60;
+ LOG_REQUESTS = "-200,204,304";
+ LOG_VALIDATION_ERRORS = true;
+ #DB_LOGGING=true;
+ #LOG_GATEWAY_TRACES=true;
+ #LOG_PROTO_UPDATES=true;
+ #LOG_PROTO_FRECENCY_UPDATES=true;
+ #LOG_PROTO_SETTINGS_UPDATES=true;
+ #WRTC_PUBLIC_IP=webrtc.old.server.spacebar.chat;
+ WRTC_PUBLIC_IP = "216.230.228.19";
+ WRTC_PORT_MIN = 60000;
+ WRTC_PORT_MAX = 65000;
+ WRTC_LIBRARY = "@spacebarchat/medooze-webrtc";
+ #WRTC_LIBRARY=mediasoup-spacebar-wrtc;
+ };
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/nginx.nix b/host/Rory-ovh/services/nginx/nginx.nix
new file mode 100755
index 0000000..d3ba2f5
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/nginx.nix
@@ -0,0 +1,65 @@
+{ config, pkgs, ... }:
+let
+ serveDir = config: {
+ enableACME = if config ? ssl then config.ssl else !config.virtualisation.isVmVariant;
+ addSSL = if config ? ssl then config.ssl else true;
+ root = if config ? path then config.path else builtins.throw "path is required";
+ locations = {
+ "/" = {
+ index = "index.html";
+ };
+ };
+ };
+in
+{
+ services = {
+ nginx = {
+ enable = true;
+ recommendedProxySettings = true;
+ recommendedTlsSettings = true;
+ experimentalZstdSettings = true;
+ #recommendedGzipSettings = true;
+ recommendedBrotliSettings = true;
+ recommendedOptimisation = true;
+ #defaultMimeTypes = ../../../../packages/nginx/mime.types;
+ appendConfig = ''
+ worker_processes 16;
+ '';
+ eventsConfig = ''
+ #use kqueue;
+ worker_connections 512;
+ '';
+ appendHttpConfig = ''
+ #sendfile on;
+ disable_symlinks off;
+ log_format combined_vhosts '$remote_addr - $remote_user [$time_local] {host="$host",server_name="$server_name",upstream=$upstream_addr,t=$request_time[u_conn=$upstream_connect_time,u_hdr=$upstream_header_time,u_resp=$upstream_response_time]} "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
+ access_log /var/log/nginx/access.log combined_vhosts;
+ '';
+ additionalModules = with pkgs.nginxModules; [ moreheaders ];
+ virtualHosts = {
+ #spacebar...
+ "rory.server.spacebar.chat" = import ./spacebar.chat/server/rory/root.nix { inherit config; };
+ "api.rory.server.spacebar.chat" = import ./spacebar.chat/server/rory/api.nix { inherit config; };
+ "gateway.rory.server.spacebar.chat" = import ./spacebar.chat/server/rory/gateway.nix { inherit config; };
+ "cdn.rory.server.spacebar.chat" = import ./spacebar.chat/server/rory/cdn.nix { inherit config; };
+ # legacy
+ "old.server.spacebar.chat" = import ./spacebar.chat/server/rory/root.nix { inherit config; };
+ "api.old.server.spacebar.chat" = import ./spacebar.chat/server/rory/api.nix { inherit config; };
+ "gateway.old.server.spacebar.chat" = import ./spacebar.chat/server/rory/gateway.nix { inherit config; };
+ "cdn.old.server.spacebar.chat" = import ./spacebar.chat/server/rory/cdn.nix { inherit config; };
+ };
+ };
+ };
+ systemd.services.nginx.serviceConfig = {
+ LimitNOFILE = 5000000;
+ };
+ security.acme.acceptTerms = true;
+ security.acme.defaults.email = "root@rory.gay";
+
+ networking.hosts."127.0.0.1" = builtins.attrNames config.services.nginx.virtualHosts;
+ networking.firewall.allowedTCPPorts = [
+ 80
+ 443
+ ];
+ networking.firewall.allowedUDPPorts = [ 443 ];
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/old/api.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/api.nix
new file mode 100644
index 0000000..8b7df6d
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/api.nix
@@ -0,0 +1,14 @@
+{
+ enableACME = true;
+ forceSSL = true;
+ locations = {
+ "/" = {
+ proxyPass = "http://192.168.1.200:3001";
+ proxyWebsockets = true;
+ extraConfig =
+ "proxy_ssl_server_name on;" +
+ "proxy_pass_header Authorization;"
+ ;
+ };
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/old/cdn.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/cdn.nix
new file mode 100644
index 0000000..89958fe
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/cdn.nix
@@ -0,0 +1,14 @@
+{
+ enableACME = true;
+ forceSSL = true;
+ locations = {
+ "/" = {
+ proxyPass = "http://192.168.1.200:3003";
+ proxyWebsockets = true;
+ extraConfig =
+ "proxy_ssl_server_name on;" +
+ "proxy_pass_header Authorization;"
+ ;
+ };
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/old/gateway.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/gateway.nix
new file mode 100644
index 0000000..ff95a5e
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/gateway.nix
@@ -0,0 +1,14 @@
+{
+ enableACME = true;
+ forceSSL = true;
+ locations = {
+ "/" = {
+ proxyPass = "http://192.168.1.200:3002";
+ proxyWebsockets = true;
+ extraConfig =
+ "proxy_ssl_server_name on;" +
+ "proxy_pass_header Authorization;"
+ ;
+ };
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/old/root.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/root.nix
new file mode 100644
index 0000000..8b7df6d
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/old/root.nix
@@ -0,0 +1,14 @@
+{
+ enableACME = true;
+ forceSSL = true;
+ locations = {
+ "/" = {
+ proxyPass = "http://192.168.1.200:3001";
+ proxyWebsockets = true;
+ extraConfig =
+ "proxy_ssl_server_name on;" +
+ "proxy_pass_header Authorization;"
+ ;
+ };
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/api.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/api.nix
new file mode 100644
index 0000000..00bbc6c
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/api.nix
@@ -0,0 +1,9 @@
+{ config }:
+{
+ enableACME = !config.virtualisation.isVmVariant;
+ addSSL = !config.virtualisation.isVmVariant;
+ locations."/" = {
+ proxyPass = "http://192.168.100.22:3001";
+ extraConfig = "proxy_ssl_server_name on;" + "proxy_pass_header Authorization;";
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/cdn.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/cdn.nix
new file mode 100644
index 0000000..02894d7
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/cdn.nix
@@ -0,0 +1,9 @@
+{ config }:
+{
+ enableACME = !config.virtualisation.isVmVariant;
+ addSSL = !config.virtualisation.isVmVariant;
+ locations."/" = {
+ proxyPass = "http://192.168.100.22:3003";
+ extraConfig = "proxy_ssl_server_name on;" + "proxy_pass_header Authorization;";
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/gateway.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/gateway.nix
new file mode 100644
index 0000000..88a37da
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/gateway.nix
@@ -0,0 +1,10 @@
+{ config }:
+{
+ enableACME = !config.virtualisation.isVmVariant;
+ addSSL = !config.virtualisation.isVmVariant;
+ locations."/" = {
+ proxyPass = "http://192.168.100.22:3002";
+ proxyWebsockets = true;
+ extraConfig = "proxy_ssl_server_name on;" + "proxy_pass_header Authorization;";
+ };
+}
diff --git a/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/root.nix b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/root.nix
new file mode 100644
index 0000000..00bbc6c
--- /dev/null
+++ b/host/Rory-ovh/services/nginx/spacebar.chat/server/rory/root.nix
@@ -0,0 +1,9 @@
+{ config }:
+{
+ enableACME = !config.virtualisation.isVmVariant;
+ addSSL = !config.virtualisation.isVmVariant;
+ locations."/" = {
+ proxyPass = "http://192.168.100.22:3001";
+ extraConfig = "proxy_ssl_server_name on;" + "proxy_pass_header Authorization;";
+ };
+}
diff --git a/host/Rory-ovh/services/postgres.nix b/host/Rory-ovh/services/postgres.nix
new file mode 100755
index 0000000..5faf1d3
--- /dev/null
+++ b/host/Rory-ovh/services/postgres.nix
@@ -0,0 +1,103 @@
+{ config, pkgs, ... }:
+
+{
+ #systemd.tmpfiles.rules = [ "d /data/dedicated/postgres 0750 postgres postgres" ];
+
+ services.postgresql = {
+ enable = true;
+ package = pkgs.postgresql_17_jit;
+ enableTCPIP = true;
+ authentication = pkgs.lib.mkOverride 10 ''
+ # TYPE, DATABASE, USER, ADDRESS, METHOD
+ local all all trust
+ host all all 127.0.0.1/32 trust
+ host all all ::1/128 trust
+ host all all 192.168.100.22/32 trust
+ host discordbots discordbots 192.168.1.2/32 trust
+ host matrix-synapse-rory-gay matrix-synapse-rory-gay 192.168.1.5/32 trust
+ host all all 0.0.0.0/0 md5
+ '';
+ # initialScript = pkgs.writeText "backend-initScript" ''
+ # CREATE ROLE nixcloud WITH LOGIN PASSWORD 'nixcloud' CREATEDB;
+ # CREATE DATABASE nixcloud;
+ # GRANT ALL PRIVILEGES ON DATABASE nixcloud TO nixcloud;
+ # '';
+ initialScript = pkgs.writeText "spacebar-initScript" ''
+ CREATE DATABASE spacebar;
+ '';
+ #dataDir = "/data/dedicated/postgres";
+ settings = {
+ # https://pgconfigurator.cybertec.at/
+ max_connections = 2500;
+ superuser_reserved_connections = 3;
+
+ shared_buffers = if config.virtualisation.isVmVariant then "128MB" else "64GB";
+ work_mem = if config.virtualisation.isVmVariant then "64MB" else "32GB";
+ maintenance_work_mem = if config.virtualisation.isVmVariant then "512MB" else "8GB";
+ huge_pages = "try";
+ effective_cache_size = if config.virtualisation.isVmVariant then "1GB" else "64GB"; # was 22
+ effective_io_concurrency = 100;
+ random_page_cost = 1.1;
+
+ # can use this to view stats: SELECT query, total_time, calls, rows FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10;
+ shared_preload_libraries = "pg_stat_statements";
+ track_io_timing = "on";
+ track_functions = "pl";
+ "pg_stat_statements.max" = "10000"; # additional
+ "pg_stat_statements.track" = "all"; # additional
+
+ wal_level = "replica";
+ max_wal_senders = 0;
+ synchronous_commit = "on"; # was ond3
+
+ checkpoint_timeout = "15min";
+ checkpoint_completion_target = "0.9";
+ max_wal_size = "2GB";
+ min_wal_size = "1GB";
+
+ wal_compression = "off";
+ wal_buffers = "-1";
+ wal_writer_delay = "500ms"; # was 100
+ wal_writer_flush_after = "32MB"; # was 1
+ #checkpoint_segments = "64"; # additional
+ default_statistics_target = "250"; # additional
+
+ bgwriter_delay = "200ms";
+ bgwriter_lru_maxpages = "100";
+ bgwriter_lru_multiplier = "2.0";
+ bgwriter_flush_after = "0";
+
+ max_worker_processes = "64"; # was 14
+ max_parallel_workers_per_gather = "32"; # was 7
+ max_parallel_maintenance_workers = "32"; # was 7
+ max_parallel_workers = "64"; # was 14
+ parallel_leader_participation = "on";
+
+ enable_partitionwise_join = "on";
+ enable_partitionwise_aggregate = "on";
+ jit = "on";
+ max_slot_wal_keep_size = "1GB";
+ track_wal_io_timing = "on";
+ maintenance_io_concurrency = "4";
+ wal_recycle = "on";
+
+ };
+ };
+
+ # services.prometheus.exporters.postgres = {
+ # enable = true;
+ # port = 9187;
+ # extraFlags = [
+ # "--collector.database_wraparound"
+ # "--collector.long_running_transactions"
+ # "--collector.postmaster"
+ # "--collector.process_idle"
+ # "--collector.stat_activity_autovacuum"
+ # "--collector.stat_statements"
+ # #"--collector.stat_wal_receiver" #we dont have WAL receivers
+ # "--collector.statio_user_indexes"
+ # "--collector.xlog_location"
+ # ];
+ # };
+
+}
diff --git a/host/Rory-ovh/vm.nix b/host/Rory-ovh/vm.nix
new file mode 100644
index 0000000..7bc237c
--- /dev/null
+++ b/host/Rory-ovh/vm.nix
@@ -0,0 +1,50 @@
+{
+ nixpkgs,
+ modulesPath,
+ pkgs,
+ lib,
+ ...
+}:
+{
+ imports = [
+ # (modulesPath + "/virtualisation/qemu-vm.nix")
+ ];
+
+ networking.firewall.enable = false;
+
+ boot = {
+ initrd = {
+ systemd.enable = true;
+ systemd.emergencyAccess = true;
+ };
+ kernelParams = [
+ "console=ttyS0,115200"
+ "systemd.gpt_auto=0"
+ #"console=tty1"
+ #"quiet"
+ ];
+ loader.timeout = 1;
+ };
+ boot.supportedFilesystems = lib.mkForce [ ];
+ hardware.enableRedistributableFirmware = lib.mkForce false;
+ #environment.systemPackages = lib.mkForce [ ];
+ documentation.enable = lib.mkForce false;
+ documentation.nixos.enable = lib.mkForce false;
+ networking.wireless.enable = lib.mkForce false;
+
+ console = {
+ earlySetup = true;
+ font = "${pkgs.cozette}/share/consolefonts/cozette6x13.psfu";
+ packages = with pkgs; [ cozette ];
+ };
+
+ system = {
+ #activatable = false;
+ copySystemConfiguration = false;
+ includeBuildDependencies = false;
+ disableInstallerTools = lib.mkForce true;
+ build = {
+ separateActivationScript = true;
+ };
+ };
+}
|