From f2e7d24b2f1d38fd50b0013348fb04a4b180f52f Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 7 Feb 2025 21:48:24 -0600 Subject: [PATCH 1/9] bert: Add chandlerswift.com --- bert/services/http/chandlerswift.com.nix | 19 +++++++++++++++++++ bert/services/http/index.nix | 1 + oscar/configuration.nix | 5 ++++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 bert/services/http/chandlerswift.com.nix diff --git a/bert/services/http/chandlerswift.com.nix b/bert/services/http/chandlerswift.com.nix new file mode 100644 index 0000000..0008ea2 --- /dev/null +++ b/bert/services/http/chandlerswift.com.nix @@ -0,0 +1,19 @@ + +{ + services.caddy.virtualHosts."chandlerswift.com".extraConfig = '' + encode zstd gzip + file_server + root * /srv/www/chandlerswift.com + # hide .git # ??? + + handle_errors { + respond "{err.status_code} {err.status_text}" + } + ''; + services.caddy.virtualHosts."www.chandlerswift.com".extraConfig = "redir https://chandlerswift.com{uri}"; + systemd.tmpfiles.settings."10-chandlerswift-com" = { + "/srv/www/chandlerswift.com" = { + d = {}; + }; + }; +} diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index d0fba6f..3e4f574 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -2,6 +2,7 @@ imports = [ ./0hats.com.nix ./bannergen.chandlerswift.com.nix + ./chandlerswift.com.nix ./files.chandlerswift.com.nix ./git.chandlerswift.com.nix ./harborpaperco.com.nix diff --git a/oscar/configuration.nix b/oscar/configuration.nix index 0271c51..0c51647 100644 --- a/oscar/configuration.nix +++ b/oscar/configuration.nix @@ -189,7 +189,10 @@ programs.thunderbird.enable = true; - programs.bash.enable = true; + programs.bash = { + enable = true; + historyControl = [ "ignoredups" "ignorespace" ]; + }; programs.direnv = { enable = true; From 510672f77944d265612df98cb917e51ee8c0575d Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 7 Feb 2025 21:50:13 -0600 Subject: [PATCH 2/9] bert: Add gotosocial on social.chandlerswift.com --- bert/services/http/chandlerswift.com.nix | 4 +++ bert/services/http/index.nix | 1 + .../http/social.chandlerswift.com.nix | 28 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 bert/services/http/social.chandlerswift.com.nix diff --git a/bert/services/http/chandlerswift.com.nix b/bert/services/http/chandlerswift.com.nix index 0008ea2..6bf8c04 100644 --- a/bert/services/http/chandlerswift.com.nix +++ b/bert/services/http/chandlerswift.com.nix @@ -6,6 +6,10 @@ root * /srv/www/chandlerswift.com # hide .git # ??? + redir /.well-known/host-meta* https://social.chandlerswift.com{uri} permanent + redir /.well-known/webfinger* https://social.chandlerswift.com{uri} permanent + redir /.well-known/nodeinfo* https://social.chandlerswift.com{uri} permanent + handle_errors { respond "{err.status_code} {err.status_text}" } diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 3e4f574..25f1356 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -13,6 +13,7 @@ ./maps.chandlerswift.com.nix ./music.chandlerswift.com.nix ./preview.chandlerswift.com.nix + ./social.chandlerswift.com.nix ./stjohnscccc.org.nix ./swiftgang.net.nix ./whereis.chandlerswift.com.nix diff --git a/bert/services/http/social.chandlerswift.com.nix b/bert/services/http/social.chandlerswift.com.nix new file mode 100644 index 0000000..3ae0c29 --- /dev/null +++ b/bert/services/http/social.chandlerswift.com.nix @@ -0,0 +1,28 @@ +{ + services.gotosocial = { + enable = true; + settings = { + landing-page-user = "chandler"; + protocol = "https"; + host = "social.chandlerswift.com"; + account-domain = "chandlerswift.com"; + bind-address = "127.0.0.1"; + port = 8001; + # log-timestamp-format = ""; + storage-local-base-path = "/srv/gotosocial/storage"; + db-type = "sqlite"; + db-address = "/srv/gotosocial/database.sqlite"; + }; + }; + systemd.tmpfiles.settings."10-social-chandlerswift-com" = { + "/srv/gotosocial" = { + d = { + user = "gotosocial"; + }; + }; + }; + services.caddy.virtualHosts."social.chandlerswift.com".extraConfig = '' + encode zstd gzip + reverse_proxy localhost:8001 + ''; +} From 437097a71bc2e958185467a667b010b8bf388724 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 7 Feb 2025 21:53:33 -0600 Subject: [PATCH 3/9] bert: Add chandlerswift.com cloudflare compat redir Cloudflare Pages, the previous home of this site, strips the `.html` suffix from filenames (no small part of the reason this site was moved!) e.g. a recent post would be served on https://chandlerswift.com/2024/11/12/install-lineageos-on-lemonade and not on https://chandlerswift.com/2024/11/12/install-lineageos-on-lemonade.html and the latter would be redirected to the former. To me, this seems like a perversion of file paths for no good reason, and it seems that a not-insubstantial chunk of the internet agrees: https://community.cloudflare.com/search?q=%22.html%22%20%23developers%3Acloudflare-pages This has been repeatedly considered "feature not bug" (despite examples of use cases the feature breaks), e.g. https://github.com/cloudflare/workers-sdk/issues/1488 This PR used AI assistance (and manual verification) for Caddyfile syntax: https://chatgpt.com/share/67a6d4e5-a464-800c-9c4d-910faa53b2dd --- bert/services/http/chandlerswift.com.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bert/services/http/chandlerswift.com.nix b/bert/services/http/chandlerswift.com.nix index 6bf8c04..b2f5ca1 100644 --- a/bert/services/http/chandlerswift.com.nix +++ b/bert/services/http/chandlerswift.com.nix @@ -6,6 +6,12 @@ root * /srv/www/chandlerswift.com # hide .git # ??? + @html_redirect { + file {path}.html + not path *.html + } + redir @html_redirect {path}.html 301 + redir /.well-known/host-meta* https://social.chandlerswift.com{uri} permanent redir /.well-known/webfinger* https://social.chandlerswift.com{uri} permanent redir /.well-known/nodeinfo* https://social.chandlerswift.com{uri} permanent From 71368d508110d99cbf594ebb421e4894d5744bdf Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 7 Feb 2025 22:05:13 -0600 Subject: [PATCH 4/9] bert: Add (ancient) blog.chandlerswift.com redirects Cool URLs don't change, as they say; let's keep these working! --- bert/services/http/chandlerswift.com.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bert/services/http/chandlerswift.com.nix b/bert/services/http/chandlerswift.com.nix index b2f5ca1..0de0de8 100644 --- a/bert/services/http/chandlerswift.com.nix +++ b/bert/services/http/chandlerswift.com.nix @@ -20,6 +20,22 @@ respond "{err.status_code} {err.status_text}" } ''; + services.caddy.virtualHosts."blog.chandlerswift.com".extraConfig = '' + redir /2018/auto-timed-fish-tank-light/ https://chandlerswift.com/projects/fish-tank-light.html permanent + redir /2018/using-a-5-25-floppy-as-a-midi-instrument/ https://chandlerswift.com/projects/midi-floppy.html permanent + redir /2017/building-a-midi-pedalboard/ https://chandlerswift.com/projects/midi-pedalboard.html permanent + redir /2017/esp8266-light-switch-a-few-revisions/ https://chandlerswift.com/projects/light-switch.html permanent + redir /2016/new-relic-and-appfog-2/ https://chandlerswift.com/2016/02/18/new-relic-appfog-v2.html permanent + redir /2015/piano-heatmap-analysis-part-1/ https://chandlerswift.com/2015/09/10/piano-heatmap-part-1.html permanent + redir /2015/solving-windows-update-error-8024402f/ https://chandlerswift.com/2015/08/31/solving-8024402F.html permanent + redir /2015/enable-hotspot-rooted-s6/ https://chandlerswift.com/2015/08/30/enabling-s6-hotspot.html permanent + + redir /* https://chandlerswift.com/ + + handle_errors { + respond "{err.status_code} {err.status_text}" + } + ''; services.caddy.virtualHosts."www.chandlerswift.com".extraConfig = "redir https://chandlerswift.com{uri}"; systemd.tmpfiles.settings."10-chandlerswift-com" = { "/srv/www/chandlerswift.com" = { From 54c4b7136d559cace53ccf2ac00cc52517086652 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Feb 2025 11:39:04 -0600 Subject: [PATCH 5/9] bert: redir stjohnscccc.org/downloads -> downloads/ --- bert/services/http/stjohnscccc.org.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index b462c02..b5dce54 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -23,6 +23,8 @@ in { services.caddy.virtualHosts.${domain}.extraConfig = '' root * ${dataDir}/public + redir /downloads /downloads/ + handle /downloads/* { file_server { browse ${./caddy-browse-template.html} From 384f965b3b06d258ef1f670a225f873e75b7ad02 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Feb 2025 12:04:30 -0600 Subject: [PATCH 6/9] bert: Refactor stjohnscccc.org config --- bert/services/http/stjohnscccc.org.nix | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index b5dce54..c76faf8 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -1,11 +1,6 @@ -{ pkgs, lib, config, ... }: -let - app = "stjohnscccc"; - domain = "${app}.chandlerswift.com"; # TODO - dataDir = "/srv/www/stjohnscccc.org"; -in { - services.phpfpm.pools.${app} = { - user = app; +{ pkgs, lib, config, ... }: { + services.phpfpm.pools.stjohnscccc = { + user = "stjohnscccc"; settings = { "listen.owner" = config.services.caddy.user; "pm" = "dynamic"; @@ -20,8 +15,8 @@ in { }; # phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; }; - services.caddy.virtualHosts.${domain}.extraConfig = '' - root * ${dataDir}/public + services.caddy.virtualHosts."stjohnscccc.org".extraConfig = '' + root * /srv/www/stjohnscccc.org/public redir /downloads /downloads/ @@ -34,7 +29,7 @@ in { handle { encode zstd gzip - php_fastcgi unix/${config.services.phpfpm.pools.${app}.socket} + php_fastcgi unix/${config.services.phpfpm.pools.stjohnscccc.socket} file_server } @@ -42,12 +37,12 @@ in { respond "{err.status_code} {err.status_text}" } ''; - users.users.${app} = { + users.users.stjohnscccc = { isSystemUser = true; - home = dataDir; - group = app; + home = "/srv/www/stjohnscccc.org"; + group = "stjohnscccc"; }; - users.groups.${app} = {}; + users.groups.stjohnscccc = {}; systemd.tmpfiles.settings."10-stjohnscccc.org" = { "/srv/www/stjohnscccc.org" = { d = {}; From a0ed02d1587a56e81fe41adc2fbe3563129e1210 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Feb 2025 12:05:33 -0600 Subject: [PATCH 7/9] bert: Add www redirect for stjohnscccc.org --- bert/services/http/stjohnscccc.org.nix | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index c76faf8..de32cea 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -15,28 +15,31 @@ }; # phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; }; - services.caddy.virtualHosts."stjohnscccc.org".extraConfig = '' - root * /srv/www/stjohnscccc.org/public + services.caddy.virtualHosts."stjohnscccc.org" = { + serverAliases = ["www.stjohnscccc.org"]; + extraConfig = '' + root * /srv/www/stjohnscccc.org/public - redir /downloads /downloads/ + redir /downloads /downloads/ - handle /downloads/* { - file_server { - browse ${./caddy-browse-template.html} - hide .gitignore + handle /downloads/* { + file_server { + browse ${./caddy-browse-template.html} + hide .gitignore + } } - } - handle { - encode zstd gzip - php_fastcgi unix/${config.services.phpfpm.pools.stjohnscccc.socket} - file_server - } + handle { + encode zstd gzip + php_fastcgi unix/${config.services.phpfpm.pools.stjohnscccc.socket} + file_server + } - handle_errors { - respond "{err.status_code} {err.status_text}" - } - ''; + handle_errors { + respond "{err.status_code} {err.status_text}" + } + ''; + }; users.users.stjohnscccc = { isSystemUser = true; home = "/srv/www/stjohnscccc.org"; From 3928a5b44de8fddaff4bd5df89e3a2548fdb0b9d Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Feb 2025 12:16:07 -0600 Subject: [PATCH 8/9] bert: Rephrase site-not-found message This gives me a bit of repudiability in case someone decides to point someunsavorydomain.net at my server -- I don't want to automatically respond indicating "yep, this is mine!" --- bert/services/http/index.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 25f1356..1091929 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -46,8 +46,11 @@

not found - chandlerswift.com

-

This page is hosted with chandlerswift.com, - but the site couldn't be found.

+

+ You've reached a server at + chandlerswift.com, + but the requested site couldn't be found. +

EOF 404 From efb6bc7b9510ab1860cd0ac0cb1a407cb12c5c3e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sat, 8 Feb 2025 12:20:16 -0600 Subject: [PATCH 9/9] bert: Add stjohnscccc.com manual redirect page --- bert/services/http/index.nix | 1 + bert/services/http/stjohnscccc.com.nix | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 bert/services/http/stjohnscccc.com.nix diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 1091929..751d1de 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -14,6 +14,7 @@ ./music.chandlerswift.com.nix ./preview.chandlerswift.com.nix ./social.chandlerswift.com.nix + ./stjohnscccc.com.nix ./stjohnscccc.org.nix ./swiftgang.net.nix ./whereis.chandlerswift.com.nix diff --git a/bert/services/http/stjohnscccc.com.nix b/bert/services/http/stjohnscccc.com.nix new file mode 100644 index 0000000..1e9168f --- /dev/null +++ b/bert/services/http/stjohnscccc.com.nix @@ -0,0 +1,19 @@ +{ + services.caddy.virtualHosts."stjohnscccc.com" = { + serverAliases = ["www.stjohnscccc.com"]; + extraConfig = '' + encode zstd gzip + file_server + root * /srv/www/stjohnscccc.com + + handle_errors { + respond "{err.status_code} {err.status_text}" + } + ''; + }; + systemd.tmpfiles.settings."10-stjohnscccc-com" = { + "/srv/www/stjohnscccc.com" = { + d = {}; + }; + }; +}