From 52e33b951cb5bcb9d2dcd46b60eedbe4c465c310 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Sun, 20 Oct 2024 00:21:02 -0500 Subject: [PATCH 01/18] Use home-manager thunderbird option --- oscar/configuration.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oscar/configuration.nix b/oscar/configuration.nix index abf5210..db1e3ae 100644 --- a/oscar/configuration.nix +++ b/oscar/configuration.nix @@ -138,7 +138,6 @@ libreoffice-qt prismlauncher qgis - thunderbird # command line applications beets @@ -163,6 +162,8 @@ factorio ]; + programs.thunderbird.enable = true; + programs.bash.enable = true; programs.direnv = { From 40bb9b51f6bc82fa4366d86cdd1bc797475d0904 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 31 Oct 2024 00:55:10 -0500 Subject: [PATCH 02/18] Start setting up bert --- bert/Makefile | 16 +++++ bert/README.md | 23 +++++++ bert/configuration.nix | 63 +++++++++++++++++++ bert/hardware-configuration.nix | 42 +++++++++++++ bert/services/http/home.chandlerswift.com.nix | 14 +++++ bert/services/http/index.nix | 12 ++++ bert/services/http/maps.chandlerswift.com.nix | 14 +++++ bert/services/http/stjohnscccc.org.nix | 42 +++++++++++++ 8 files changed, 226 insertions(+) create mode 100644 bert/Makefile create mode 100644 bert/README.md create mode 100644 bert/configuration.nix create mode 100644 bert/hardware-configuration.nix create mode 100644 bert/services/http/home.chandlerswift.com.nix create mode 100644 bert/services/http/index.nix create mode 100644 bert/services/http/maps.chandlerswift.com.nix create mode 100644 bert/services/http/stjohnscccc.org.nix diff --git a/bert/Makefile b/bert/Makefile new file mode 100644 index 0000000..c6583fc --- /dev/null +++ b/bert/Makefile @@ -0,0 +1,16 @@ +# https://stackoverflow.com/a/23324703 +current_dir:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + +.PHONY: deploy +deploy: + rsync -avz $(current_dir)/ root@bert:config/ + ssh root@bert nixos-rebuild switch --fast -I nixos-config=/root/config/configuration.nix + +.PHONY: local-build-deploy +local-build-deploy: + nixos-rebuild switch --fast -I nixos-config=./configuration.nix --build-host root@bert --target-host root@bert + +.PHONY: deploy-upgrade +deploy-upgrade: + rsync -avz $(current_dir)/ root@bert:config/ + ssh root@bert nixos-rebuild switch --upgrade-all --fast -I nixos-config=/root/config/configuration.nix diff --git a/bert/README.md b/bert/README.md new file mode 100644 index 0000000..5fc22b6 --- /dev/null +++ b/bert/README.md @@ -0,0 +1,23 @@ +# Installation +1. Install NixOS minimal +2. `ssh-keygen -N "" -f /etc/secrets/initrd/ssh_host_ed25519_key` +2. Enable SSH server and add root SSH key +3. Deploy updated config with `make` +4. Set up [Remote Disk Unlocking](https://nixos.wiki/wiki/Remote_disk_unlocking) + 1. mkdir -p /etc/secrets/initrd && ssh-keygen -N "" -f /etc/secrets/initrd/ssh_host_25519_key +5. Deploy content to web services + +# Notes on Caddy +Until 2.8 is released with 24.11, Caddy has a pretty limited sense of what +content-types should be compressed: + +https://github.com/caddyserver/caddy/blob/v2.7.6/modules/caddyhttp/encode/encode.go#L85-L101 + +Specifically, this doesn't include GeoJSON, which is a bit of a shame for +maps.chandlerswift.com. That said, I'll probably be upgrading to 24.11 as soon +as it comes out, so in the intervening time I'm just not going to worry about +it. + +The list was expanded in this PR: + +https://github.com/caddyserver/caddy/pull/6081 diff --git a/bert/configuration.nix b/bert/configuration.nix new file mode 100644 index 0000000..8004161 --- /dev/null +++ b/bert/configuration.nix @@ -0,0 +1,63 @@ +{ config, pkgs, lib, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + ./services/http/index.nix + ]; + + # Bootloader + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Set up SSH unlocking + boot.initrd = { + availableKernelModules = [ "e1000e" ]; + network = { + enable = true; + ssh = { + enable = true; + port = 22; + authorizedKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhPyyqS3BGYor3zLbjc8hZuhem3mS8TNmvWogXcnz/b chandler@chandlerswift.com" ]; + hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ]; + shell = "/bin/cryptsetup-askpass"; + }; + }; + }; + + boot.initrd.luks.devices."luks-48836129-1aa0-45c7-9fd1-6b053fa620b1".device = "/dev/disk/by-uuid/48836129-1aa0-45c7-9fd1-6b053fa620b1"; + networking.hostName = "bert"; + + # Enable networking + networking.networkmanager.enable = true; + + time.timeZone = "America/Chicago"; + i18n.defaultLocale = "en_US.UTF-8"; + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + environment.systemPackages = with pkgs; [ + rsync + ]; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + users.users.root.openssh.authorizedKeys.keys = [''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhPyyqS3BGYor3zLbjc8hZuhem3mS8TNmvWogXcnz/b chandler@chandlerswift.com'' ]; + + networking.firewall.allowedTCPPorts = [ + 80 # Caddy + 443 # Caddy + ]; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "24.05"; # Did you read the comment? + +} diff --git a/bert/hardware-configuration.nix b/bert/hardware-configuration.nix new file mode 100644 index 0000000..bd11bff --- /dev/null +++ b/bert/hardware-configuration.nix @@ -0,0 +1,42 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/5abc0802-3969-460c-8089-5fec9f985c18"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-da40f6d2-49d7-4a55-8a2e-94fa5f28dbbc".device = "/dev/disk/by-uuid/da40f6d2-49d7-4a55-8a2e-94fa5f28dbbc"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/B684-07FB"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/f5d7bb99-03aa-4f7c-9d4a-e264ceb514c6"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/bert/services/http/home.chandlerswift.com.nix b/bert/services/http/home.chandlerswift.com.nix new file mode 100644 index 0000000..7cfb495 --- /dev/null +++ b/bert/services/http/home.chandlerswift.com.nix @@ -0,0 +1,14 @@ + +{ + services.caddy.virtualHosts."home.chandlerswift.com".extraConfig = '' + encode zstd gzip + file_server + root * /srv/home.chandlerswift.com + # hide .git # ??? + ''; + systemd.tmpfiles.settings."10-home-chandlerswift-com" = { + "/srv/home.chandlerswift.com" = { + d = {}; + }; + }; +} diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix new file mode 100644 index 0000000..8c61469 --- /dev/null +++ b/bert/services/http/index.nix @@ -0,0 +1,12 @@ +{ + imports = [ + ./home.chandlerswift.com.nix + ./maps.chandlerswift.com.nix + ./stjohnscccc.org.nix + ]; + + services.caddy = { + enable = true; + email = "chandler@chandlerswift.com"; + }; +} diff --git a/bert/services/http/maps.chandlerswift.com.nix b/bert/services/http/maps.chandlerswift.com.nix new file mode 100644 index 0000000..74251bb --- /dev/null +++ b/bert/services/http/maps.chandlerswift.com.nix @@ -0,0 +1,14 @@ + +{ + services.caddy.virtualHosts."maps.chandlerswift.com".extraConfig = '' + encode zstd gzip + file_server + root * /srv/maps.chandlerswift.com + # hide .git # ??? + ''; + systemd.tmpfiles.settings."10-maps-chandlerswift-com" = { + "/srv/maps.chandlerswift.com" = { + d = {}; + }; + }; +} diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix new file mode 100644 index 0000000..a9309e0 --- /dev/null +++ b/bert/services/http/stjohnscccc.org.nix @@ -0,0 +1,42 @@ +{ pkgs, lib, config, ... }: +let + app = "stjohnscccc"; + domain = "${app}.chandlerswift.com"; # TODO + dataDir = "/srv/http/${domain}"; +in { + services.phpfpm.pools.${app} = { + user = app; + settings = { + "listen.owner" = config.services.caddy.user; + "pm" = "dynamic"; + "pm.max_children" = 32; + # "pm.max_requests" = 500; + "pm.start_servers" = 1; + "pm.min_spare_servers" = 1; + "pm.max_spare_servers" = 4; + "php_admin_value[error_log]" = "stderr"; + "php_admin_flag[log_errors]" = true; + "catch_workers_output" = true; + }; + # phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; + }; + services.caddy.virtualHosts.${domain}.extraConfig = '' + root * ${dataDir}/public + encode zstd gzip + file_server + php_fastcgi unix//run/php/php-fpm.sock + log + ''; + users.users.${app} = { + isSystemUser = true; + createHome = true; + home = dataDir; + group = app; + }; + users.groups.${app} = {}; + systemd.tmpfiles.settings."10-stjohnscccc.org" = { + "/srv/stjohnscccc.org" = { + d = {}; + }; + }; +} From db8861398748a4abc3b6fcad94df35e1a950da59 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 31 Oct 2024 01:50:48 -0500 Subject: [PATCH 03/18] Add basic prometheus/grafana setup --- bert/configuration.nix | 1 + bert/services/http/home.chandlerswift.com.nix | 1 + bert/services/http/index.nix | 5 +++ bert/services/monitoring.nix | 41 +++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 bert/services/monitoring.nix diff --git a/bert/configuration.nix b/bert/configuration.nix index 8004161..b175a80 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -5,6 +5,7 @@ [ ./hardware-configuration.nix ./services/http/index.nix + ./services/monitoring.nix ]; # Bootloader diff --git a/bert/services/http/home.chandlerswift.com.nix b/bert/services/http/home.chandlerswift.com.nix index 7cfb495..404673d 100644 --- a/bert/services/http/home.chandlerswift.com.nix +++ b/bert/services/http/home.chandlerswift.com.nix @@ -4,6 +4,7 @@ encode zstd gzip file_server root * /srv/home.chandlerswift.com + reverse_proxy /grafana/* localhost:3000 # hide .git # ??? ''; systemd.tmpfiles.settings."10-home-chandlerswift-com" = { diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 8c61469..9c65855 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -8,5 +8,10 @@ services.caddy = { enable = true; email = "chandler@chandlerswift.com"; + globalConfig = '' + servers { + metrics # Enable Prometheus monitoring + } + ''; }; } diff --git a/bert/services/monitoring.nix b/bert/services/monitoring.nix new file mode 100644 index 0000000..8f524c4 --- /dev/null +++ b/bert/services/monitoring.nix @@ -0,0 +1,41 @@ +{ + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "caddy"; + static_configs = [{ + targets = [ + "localhost:2019" + ]; + }]; + } + { + job_name = "node"; + static_configs = [{ + targets = [ + "localhost:9100" + ]; + }]; + } + ]; + exporters.node = { + enable = true; + # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/prometheus/exporters.nix + enabledCollectors = [ "systemd" ]; + # /nix/store/zgsw0yx18v10xa58psanfabmg95nl2bb-node_exporter-1.8.1/bin/node_exporter --help + # extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ]; + }; + }; + + services.grafana = { + enable = true; + settings = { + server = { + root_url = "https://home.chandlerswift.com/grafana/"; + serve_from_sub_path = true; + }; + }; + }; + +} From d104278ad1f2fedbd590280b48574f9f7b2a2413 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Thu, 31 Oct 2024 02:04:15 -0500 Subject: [PATCH 04/18] Add Factorio Server --- bert/configuration.nix | 1 + bert/services/factorio.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 bert/services/factorio.nix diff --git a/bert/configuration.nix b/bert/configuration.nix index b175a80..1e09172 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -4,6 +4,7 @@ imports = [ ./hardware-configuration.nix + ./services/factorio.nix ./services/http/index.nix ./services/monitoring.nix ]; diff --git a/bert/services/factorio.nix b/bert/services/factorio.nix new file mode 100644 index 0000000..10e0b27 --- /dev/null +++ b/bert/services/factorio.nix @@ -0,0 +1,17 @@ +{ + # nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + # "factorio-headless" + # ]; + services.factorio = let + factorio-nixpkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/7e35ac30ea1d236419653182559367ecd8a30675.tar.gz") { + config.allowUnfree = true; + }; + in { + enable = true; + package = factorio-nixpkgs.factorio-headless; + openFirewall = true; + nonBlockingSaving = true; + game-name = "Chandler's Factorio Server"; + description = "Job 28:2"; + }; +} From 4d74ca100a1bcafb2f6ad74c017ec3c2448bf6ee Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 1 Nov 2024 01:36:31 -0500 Subject: [PATCH 05/18] Use DHCP for first stage boot This approach was recommended by nixos.wiki, and formerly by wiki.nixos.org, which has since switched to instead mentioning `boot.initrd.network.udhcpc.enable = true;`. It's not entirely clear to me which has an advantage over the other. This kernel parameter means that the kernel itself does the DHCP request, which is pretty neat! That seems to get set up in this file, though I haven't tracked down the exact details: https://github.com/torvalds/linux/blob/master/net/ipv4/ipconfig.c It seems like udhcpc may _also_ be enabled (since networking.useDHCP is set for the main system?), so maybe that could be disabled, but this appears to work so I'm rolling with it for the time being! Without the kernel param set, udhcpc tries and fails with errors like this: ``` <<< NixOS Stage 1 >>> loading module dm_mod... loading module af_packet... running udev... Starting systemd-udevd version 255.9 bringing up network interface eno1... acquiring IP address via DHCP on eno1... udhcpc: started, v1.36.1 udhcpc: broadcasting discover udhcpc: broadcasting discover udhcpc: broadcasting discover udhcpc: no lease, failing Passphrase for /dev/disk/by-uuid/00000000-0000-0000-0000-000000000000: _ ``` Compare with a working output: ``` <<< NixOS Stage 1 >>> loading module dm_mod... loading module af_packet... running udev... Starting systemd-udevd version 255.9 bringing up network interface eno1... acquiring IP address via DHCP on eno1... udhcpc: started, v1.36.1 udhcpc: broadcasting discover udhcpc: broadcasting discover udhcpc: broadcasting discover udhcpc: broadcasting select for 192.168.1.20, server 192.168.1.1 udhcpc: lease of 192.168.1.20 obtained from 192.168.1.1, lease time 43200 Passphrase for /dev/disk/by-uuid/00000000-0000-0000-0000-000000000000: _ ``` --- bert/configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/bert/configuration.nix b/bert/configuration.nix index 1e09172..5f46d8b 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -14,6 +14,7 @@ boot.loader.efi.canTouchEfiVariables = true; # Set up SSH unlocking + boot.kernelParams = [ "ip=dhcp" ]; boot.initrd = { availableKernelModules = [ "e1000e" ]; network = { From 3c8150a5aaa19f11ea83c34f3e6c55a5c53ada60 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 1 Nov 2024 01:30:48 -0500 Subject: [PATCH 06/18] Fix stage2 IPv6 networking When `ip=dhcp` is passed as a kernel param (which I assume, but don't know for sure, just gets passed to systemd and probably then to systemd-networkd or NetworkManager or whatever does the networking in the initrd?), IPv6 doesn't come up. With the param, bad IPv6: ```text 2: eno1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 3c:52:82:00:46:d6 brd ff:ff:ff:ff:ff:ff altname enp0s31f6 inet 192.168.1.20/24 brd 192.168.1.255 scope global eno1 valid_lft forever preferred_lft forever inet6 2601:441:8301:8af7:94e1:4d4c:73c2:ac31/64 scope global temporary dynamic valid_lft 322763sec preferred_lft 86330sec inet6 fd0a:8f9f:6f83:0:3e52:82ff:fe00:46d6/64 scope global dynamic mngtmpaddr proto kernel_ra valid_lft forever preferred_lft forever inet6 2601:441:8301:8af7:3e52:82ff:fe00:46d6/64 scope global dynamic mngtmpaddr proto kernel_ra valid_lft 322763sec preferred_lft 322763sec inet6 fe80::3e52:82ff:fe00:46d6/64 scope link proto kernel_ll valid_lft forever preferred_lft forever ``` whereas without the param I get good (whatever that means) addresses: ```text 2: eno1: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 3c:52:82:00:46:d6 brd ff:ff:ff:ff:ff:ff altname enp0s31f6 inet 192.168.1.20/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1 valid_lft 43188sec preferred_lft 43188sec inet6 fd0a:8f9f:6f83::33b/128 scope global dynamic noprefixroute valid_lft 43190sec preferred_lft 43190sec inet6 2601:441:8301:8af7::33b/128 scope global dynamic noprefixroute valid_lft 43190sec preferred_lft 43190sec inet6 2601:441:8301:8af7:b572:fc6c:ba27:dcdb/64 scope global temporary dynamic valid_lft 322965sec preferred_lft 86235sec inet6 2601:441:8301:8af7:f3f0:df23:a6bb:7d25/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 322965sec preferred_lft 322965sec inet6 fd0a:8f9f:6f83:0:485e:f55d:fa1d:cef4/64 scope global temporary dynamic valid_lft 604790sec preferred_lft 86235sec inet6 fd0a:8f9f:6f83:0:7851:1417:807:f017/64 scope global mngtmpaddr noprefixroute valid_lft forever preferred_lft forever inet6 fe80::eb0c:1983:24a5:3e42/64 scope link noprefixroute valid_lft forever preferred_lft forever ``` I'm honestly not entirely sure what this _should_ look like, but what I _do_ know is that in the "bad" configuration, SSH takes an extra ~10s to connect as it has to wait for two ~5s `No route to host` timeouts: ```console [chandler@oscar:~]$ ssh -v root@bert OpenSSH_9.8p1, OpenSSL 3.0.14 4 Jun 2024 debug1: Reading configuration data /home/chandler/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 5: Applying options for * debug1: Connecting to bert [fd0a:8f9f:6f83::33b] port 22. debug1: connect to address fd0a:8f9f:6f83::33b port 22: No route to host debug1: Connecting to bert [2601:441:8301:8af7::33b] port 22. debug1: connect to address 2601:441:8301:8af7::33b port 22: No route to host debug1: Connecting to bert [192.168.1.20] port 22. debug1: Connection established. ``` Future work: What _should_ my IPv6 config look like? Is there any way I can keep network config stable between the initrd and the booted system? Why is this recommended against? > The default is false when systemd is enabled in initrd, because the > systemd-networkd documentation suggests it. --- bert/configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/bert/configuration.nix b/bert/configuration.nix index 5f46d8b..d3d4d92 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -19,6 +19,7 @@ availableKernelModules = [ "e1000e" ]; network = { enable = true; + flushBeforeStage2 = true; # Without this, stage2 IPv6 config is messed up? ssh = { enable = true; port = 22; From 3237237cdd506139e4bed45ef67adc8880c453a5 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Fri, 1 Nov 2024 01:48:25 -0500 Subject: [PATCH 07/18] Reduce bootloader timeout for faster boot --- bert/configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/bert/configuration.nix b/bert/configuration.nix index d3d4d92..2251ddd 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -12,6 +12,7 @@ # Bootloader boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + boot.loader.timeout = 1; # Set up SSH unlocking boot.kernelParams = [ "ip=dhcp" ]; From c993aa7c257e5763d547def409aa5e8a53ab0bd2 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Mon, 4 Nov 2024 19:20:49 -0600 Subject: [PATCH 08/18] Add files.chandlerswift.com --- bert/services/http/files.chandlerswift.com.nix | 13 +++++++++++++ bert/services/http/index.nix | 1 + 2 files changed, 14 insertions(+) create mode 100644 bert/services/http/files.chandlerswift.com.nix diff --git a/bert/services/http/files.chandlerswift.com.nix b/bert/services/http/files.chandlerswift.com.nix new file mode 100644 index 0000000..aad3102 --- /dev/null +++ b/bert/services/http/files.chandlerswift.com.nix @@ -0,0 +1,13 @@ + +{ + services.caddy.virtualHosts."files.chandlerswift.com".extraConfig = '' + encode zstd gzip + file_server + root * /srv/files.chandlerswift.com + ''; + systemd.tmpfiles.settings."10-files-chandlerswift-com" = { + "/srv/files.chandlerswift.com" = { + d = {}; + }; + }; +} diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 9c65855..c294d53 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -1,5 +1,6 @@ { imports = [ + ./files.chandlerswift.com.nix ./home.chandlerswift.com.nix ./maps.chandlerswift.com.nix ./stjohnscccc.org.nix From 8afb236c5248670fc29643ddfe79ce549a5668ed Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Tue, 5 Nov 2024 23:32:46 -0600 Subject: [PATCH 09/18] Add swiftgang.net --- bert/services/http/index.nix | 1 + bert/services/http/swiftgang.net.nix | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 bert/services/http/swiftgang.net.nix diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index c294d53..6b0430a 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -4,6 +4,7 @@ ./home.chandlerswift.com.nix ./maps.chandlerswift.com.nix ./stjohnscccc.org.nix + ./swiftgang.net.nix ]; services.caddy = { diff --git a/bert/services/http/swiftgang.net.nix b/bert/services/http/swiftgang.net.nix new file mode 100644 index 0000000..d2d0756 --- /dev/null +++ b/bert/services/http/swiftgang.net.nix @@ -0,0 +1,13 @@ + +{ + services.caddy.virtualHosts."swiftgang.net".extraConfig = '' + encode zstd gzip + file_server + root * /srv/swiftgang.net + ''; + systemd.tmpfiles.settings."10-swiftgang-net" = { + "/srv/swiftgang.net" = { + d = {}; + }; + }; +} From 0e4a2c5b9dc9b6707c7fbe1a061c4cfd0fb06359 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Tue, 5 Nov 2024 23:47:48 -0600 Subject: [PATCH 10/18] Add forgejo --- bert/configuration.nix | 1 + bert/services/forgejo.nix | 19 +++++++++++++++++++ bert/services/http/git.chandlerswift.com.nix | 5 +++++ bert/services/http/index.nix | 1 + 4 files changed, 26 insertions(+) create mode 100644 bert/services/forgejo.nix create mode 100644 bert/services/http/git.chandlerswift.com.nix diff --git a/bert/configuration.nix b/bert/configuration.nix index 2251ddd..f9a6c33 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -7,6 +7,7 @@ ./services/factorio.nix ./services/http/index.nix ./services/monitoring.nix + ./services/forgejo.nix ]; # Bootloader diff --git a/bert/services/forgejo.nix b/bert/services/forgejo.nix new file mode 100644 index 0000000..9d7d619 --- /dev/null +++ b/bert/services/forgejo.nix @@ -0,0 +1,19 @@ +{ + services.forgejo = { + enable = true; + settings = { + DEFAULT = { + APP_NAME = "Forgejo: Beyond coding. We Forge."; # TODO + }; + server = { + # USE_PROXY_PROTOCOL = true; + DOMAIN = "git.chandlerswift.com"; + #SSH_DOMAIN = "git.chandlerswift.com"; + ROOT_URL = "https://git.chandlerswift.com/"; + HTTP_PORT = 3001; + LANDING_PAGE = "/chandlerswift"; + }; + service.DISABLE_REGISTRATION = true; + }; + }; +} diff --git a/bert/services/http/git.chandlerswift.com.nix b/bert/services/http/git.chandlerswift.com.nix new file mode 100644 index 0000000..609c95f --- /dev/null +++ b/bert/services/http/git.chandlerswift.com.nix @@ -0,0 +1,5 @@ +{config, ...}: { + services.caddy.virtualHosts."git.chandlerswift.com".extraConfig = '' + reverse_proxy localhost:${toString config.services.forgejo.settings.server.HTTP_PORT} + ''; +} diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 6b0430a..51e12c7 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -1,6 +1,7 @@ { imports = [ ./files.chandlerswift.com.nix + ./git.chandlerswift.com.nix ./home.chandlerswift.com.nix ./maps.chandlerswift.com.nix ./stjohnscccc.org.nix From fee81ed3c717d1037fc3e1d0e57e0c20cb5d8d97 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Tue, 5 Nov 2024 23:48:09 -0600 Subject: [PATCH 11/18] Move /srv/* into /srv/www/* --- bert/services/http/files.chandlerswift.com.nix | 4 ++-- bert/services/http/home.chandlerswift.com.nix | 4 ++-- bert/services/http/maps.chandlerswift.com.nix | 4 ++-- bert/services/http/stjohnscccc.org.nix | 4 ++-- bert/services/http/swiftgang.net.nix | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bert/services/http/files.chandlerswift.com.nix b/bert/services/http/files.chandlerswift.com.nix index aad3102..74c5e0c 100644 --- a/bert/services/http/files.chandlerswift.com.nix +++ b/bert/services/http/files.chandlerswift.com.nix @@ -3,10 +3,10 @@ services.caddy.virtualHosts."files.chandlerswift.com".extraConfig = '' encode zstd gzip file_server - root * /srv/files.chandlerswift.com + root * /srv/www/files.chandlerswift.com ''; systemd.tmpfiles.settings."10-files-chandlerswift-com" = { - "/srv/files.chandlerswift.com" = { + "/srv/www/files.chandlerswift.com" = { d = {}; }; }; diff --git a/bert/services/http/home.chandlerswift.com.nix b/bert/services/http/home.chandlerswift.com.nix index 404673d..eef8812 100644 --- a/bert/services/http/home.chandlerswift.com.nix +++ b/bert/services/http/home.chandlerswift.com.nix @@ -3,12 +3,12 @@ services.caddy.virtualHosts."home.chandlerswift.com".extraConfig = '' encode zstd gzip file_server - root * /srv/home.chandlerswift.com + root * /srv/www/home.chandlerswift.com reverse_proxy /grafana/* localhost:3000 # hide .git # ??? ''; systemd.tmpfiles.settings."10-home-chandlerswift-com" = { - "/srv/home.chandlerswift.com" = { + "/srv/www/home.chandlerswift.com" = { d = {}; }; }; diff --git a/bert/services/http/maps.chandlerswift.com.nix b/bert/services/http/maps.chandlerswift.com.nix index 74251bb..fb21cb8 100644 --- a/bert/services/http/maps.chandlerswift.com.nix +++ b/bert/services/http/maps.chandlerswift.com.nix @@ -3,11 +3,11 @@ services.caddy.virtualHosts."maps.chandlerswift.com".extraConfig = '' encode zstd gzip file_server - root * /srv/maps.chandlerswift.com + root * /srv/www/maps.chandlerswift.com # hide .git # ??? ''; systemd.tmpfiles.settings."10-maps-chandlerswift-com" = { - "/srv/maps.chandlerswift.com" = { + "/srv/www/maps.chandlerswift.com" = { d = {}; }; }; diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index a9309e0..7cbc99a 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -2,7 +2,7 @@ let app = "stjohnscccc"; domain = "${app}.chandlerswift.com"; # TODO - dataDir = "/srv/http/${domain}"; + dataDir = "/srv/www/http/${domain}"; in { services.phpfpm.pools.${app} = { user = app; @@ -35,7 +35,7 @@ in { }; users.groups.${app} = {}; systemd.tmpfiles.settings."10-stjohnscccc.org" = { - "/srv/stjohnscccc.org" = { + "/srv/www/stjohnscccc.org" = { d = {}; }; }; diff --git a/bert/services/http/swiftgang.net.nix b/bert/services/http/swiftgang.net.nix index d2d0756..82bee79 100644 --- a/bert/services/http/swiftgang.net.nix +++ b/bert/services/http/swiftgang.net.nix @@ -3,10 +3,10 @@ services.caddy.virtualHosts."swiftgang.net".extraConfig = '' encode zstd gzip file_server - root * /srv/swiftgang.net + root * /srv/www/swiftgang.net ''; systemd.tmpfiles.settings."10-swiftgang-net" = { - "/srv/swiftgang.net" = { + "/srv/www/swiftgang.net" = { d = {}; }; }; From be53e216204b60e4cd868467d8a350e83b54692e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Tue, 5 Nov 2024 23:54:16 -0600 Subject: [PATCH 12/18] Remove `animal`, which was replaced by `bert` --- animal/Makefile | 3 -- animal/configuration.nix | 75 ------------------------------- animal/eric.nix | 17 ------- animal/hardware-configuration.nix | 19 -------- animal/kathe.nix | 26 ----------- animal/monitoring.nix | 20 --------- animal/web.nix | 20 --------- 7 files changed, 180 deletions(-) delete mode 100644 animal/Makefile delete mode 100644 animal/configuration.nix delete mode 100644 animal/eric.nix delete mode 100644 animal/hardware-configuration.nix delete mode 100644 animal/kathe.nix delete mode 100644 animal/monitoring.nix delete mode 100644 animal/web.nix diff --git a/animal/Makefile b/animal/Makefile deleted file mode 100644 index 9c3acda..0000000 --- a/animal/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -.PHONY: deploy -deploy: - nixos-rebuild switch --fast -I nixos-config=./configuration.nix --build-host root@animal.chandlerswift.com --target-host root@animal.chandlerswift.com diff --git a/animal/configuration.nix b/animal/configuration.nix deleted file mode 100644 index 137722c..0000000 --- a/animal/configuration.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ config, lib, pkgs, ... }: { - -# config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ -# "minecraft-server" -# ]; - - imports = [ - ./hardware-configuration.nix - ./web.nix - ./monitoring.nix - ./kathe.nix - ./eric.nix - ]; - - networking.hostName = "animal"; - time.timeZone = "America/Chicago"; - i18n.defaultLocale = "en_US.UTF-8"; - - fileSystems."/mnt/nas" = { - device = "//home.chandlerswift.com/chandlerpublic"; - fsType = "cifs"; - options = [ "guest" "port=55445" ]; - }; - -# services.minecraft-server = { -# enable = true; -# declarative = true; -# eula = true; -# dataDir = "/srv/minecraft"; -# openFirewall = true; -# whitelist = { -# chandlerswift = "04095aeb-edec-3c3f-b0d5-d703fab53c9c"; -# villlater = "90b7fcd6-9f43-38c5-8ea2-163f13b092f0"; -# LarryHorton = "de963636-138f-3ef4-8c52-a2dcf9a328f4"; -# IsaacSwift = "88e17365-4b63-3385-a4b6-b2c4864b0b98"; -# Mayornnaise = "be25bf89-ef07-3fa3-926b-20b939df62f1"; -# Ripptide66 = "a94051cb-5769-3726-86b5-bc9fe4cbe5f5"; -# }; -# }; - - services.murmur = { - # TODO https://nixos.org/manual/nixos/stable/options#opt-services.murmur.enable - # TODO https://github.com/azlux/botamusique - #enable = true; - }; - - environment.systemPackages = with pkgs; [ rsync ]; - - services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = [''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhPyyqS3BGYor3zLbjc8hZuhem3mS8TNmvWogXcnz/b chandler@chandlerswift.com'' ]; - -# services.jitsi-meet = { -# enable = true; -# hostName = "meet.animal.chandlerswift.com"; -# nginx.enable = false; -# caddy.enable = true; -# }; -# services.jitsi-videobridge.openFirewall = true; - - - networking.firewall.allowedTCPPorts = [ - 80 # Caddy - 443 # Caddy - ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - - # This option defines the first version of NixOS you have installed on this particular machine, - # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. - # - # Most users should NEVER change this value after the initial install, for any reason, - # even if you've upgraded your system to a new NixOS release. - system.stateVersion = "24.05"; - -} - diff --git a/animal/eric.nix b/animal/eric.nix deleted file mode 100644 index 4eb1783..0000000 --- a/animal/eric.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - -# users.users.eric = { -# isNormalUser = true; -# description = "Eric Villnow"; -# openssh.authorizedKeys.keys = [ -# # TODO -# ]; -# }; - - services.caddy.virtualHosts."nas.ericvillnow.com" = { - serverAliases = ["nas.vill.how"]; - extraConfig = '' - reverse_proxy http://192.168.10.11:80 - ''; - }; -} diff --git a/animal/hardware-configuration.nix b/animal/hardware-configuration.nix deleted file mode 100644 index 9bf6dc6..0000000 --- a/animal/hardware-configuration.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ modulesPath, ... }: -{ - imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; - boot.loader.grub = { - efiSupport = true; - efiInstallAsRemovable = true; - device = "nodev"; - }; - fileSystems."/boot" = { device = "/dev/disk/by-uuid/FDD2-F69B"; fsType = "vfat"; }; - boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; - boot.initrd.kernelModules = [ "nvme" ]; - fileSystems."/" = { device = "/dev/vda2"; fsType = "ext4"; }; - swapDevices = [{ - device = "/swapfile"; - size = 4 * 1024; # 4GB - }]; - boot.tmp.cleanOnBoot = true; - zramSwap.enable = true; -} diff --git a/animal/kathe.nix b/animal/kathe.nix deleted file mode 100644 index f083c75..0000000 --- a/animal/kathe.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - - users.users.kathe = { - isNormalUser = true; - description = "Käthe Swift"; - openssh.authorizedKeys.keys = [ - # TODO: ed25519 - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDTORULg2qqAJs5i9V7YpavlDaQBdPsEtj7s23B50qRz+VjP9rNQC8F2bVgI1BbI7CqQho2IFCG2nAiBqciLAMxTqaihI6OlNyhVJvkVSXxy2ru8NEKTPA2UnciepxeyQGfgstv8d+8mLiDbcytWDbtNoTymhy5DjCwki8gnQQTO1XVcJr5N12OsvoaCcikYQwTcxgXG0rVxlg/DUQJeaV1hZdHwpgr1cbdX2JxMONo8wcW5Ox5ZJs/+Zz72iOfoa9DXJChfdOQ5dMC+WVGwd3JbHQLWQmnCepYBKiUv8JMN7ZkDBcyIFJ+dc7F/CwBrPAF9g93GEauEilWulKV4AmbqdxY+lK/hp0fSr69H4bkqLmeAeXTHIlTge1FuQKNSKHeBhQ4y7OxDc0IEzDCE7OXT04fn6etsZcFb2JIYhFZWKGxiwSYWAjfdkmVnC48sC6Q3Heonk/IxZwbKVOUlo7B0q43A4PzTWiOWFcFKDGXn3KrNRCXuLfaYxYDyTEc2ss=" - ]; - }; - - services.caddy.virtualHosts."piano.animal.chandlerswift.com".extraConfig = '' - encode gzip - file_server - root /srv/piano.animal.chandlerswift.com - # hide .git # ??? - ''; - systemd.tmpfiles.settings."10-piano-animal-chandlerswift-com" = { - "/srv/piano.animal.chandlerswift.com" = { - d = { - user = "kathe"; - mode = "0755"; - }; - }; - }; -} diff --git a/animal/monitoring.nix b/animal/monitoring.nix deleted file mode 100644 index 707d3ba..0000000 --- a/animal/monitoring.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - services.grafana = { - enable = true; - settings = { - server = { - http_addr = "127.0.0.1"; - http_port = 3000; - domain = "monitoring.animal.chandlerswift.com"; - }; - }; - }; - - services.prometheus = { - enable = true; - }; - - services.caddy.virtualHosts."monitoring.animal.chandlerswift.com".extraConfig = '' - reverse_proxy :3000 - ''; -} diff --git a/animal/web.nix b/animal/web.nix deleted file mode 100644 index 6e0e106..0000000 --- a/animal/web.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - services.caddy = { - enable = true; - virtualHosts."animal.chandlerswift.com".extraConfig = '' - respond "Hello, world!" - ''; - }; - - services.caddy.virtualHosts."maps.animal.chandlerswift.com".extraConfig = '' - encode gzip - file_server - root /srv/maps.animal.chandlerswift.com - # hide .git # ??? - ''; - systemd.tmpfiles.settings."10-maps-animal-chandlerswift-com" = { - "/srv/maps.animal.chandlerswift.com" = { - d = {}; - }; - }; -} From 808d65206abc8e845cff6f1486d6de29559bb963 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Tue, 5 Nov 2024 23:58:14 -0600 Subject: [PATCH 13/18] Set up nix-shell/direnv --- .envrc | 1 + .gitignore | 1 + shell.nix | 11 +++++++++++ 3 files changed, 13 insertions(+) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..0a722d7 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix; diff --git a/.gitignore b/.gitignore index 7ea4304..9c43034 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ keys.toml +.direnv diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..81d6525 --- /dev/null +++ b/shell.nix @@ -0,0 +1,11 @@ +let +# nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05"; + pkgs = import { config = {}; overlays = []; }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + # nixd + gnumake + ]; +} From c72358ace8316969e0f0b6d5e6b99efc9a35076e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Wed, 6 Nov 2024 00:00:16 -0600 Subject: [PATCH 14/18] bert: Disable ssh password auth --- bert/configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/bert/configuration.nix b/bert/configuration.nix index f9a6c33..c475e2a 100644 --- a/bert/configuration.nix +++ b/bert/configuration.nix @@ -51,6 +51,7 @@ # Enable the OpenSSH daemon. services.openssh.enable = true; + services.openssh.settings.PasswordAuthentication = false; users.users.root.openssh.authorizedKeys.keys = [''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhPyyqS3BGYor3zLbjc8hZuhem3mS8TNmvWogXcnz/b chandler@chandlerswift.com'' ]; networking.firewall.allowedTCPPorts = [ From 8c4a6a3c23a7d0729a41342c1c714fbe2cec36ff Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Wed, 6 Nov 2024 00:00:51 -0600 Subject: [PATCH 15/18] Add katherineandchandler.com --- bert/services/http/index.nix | 1 + bert/services/http/katherineandchandler.com.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 bert/services/http/katherineandchandler.com.nix diff --git a/bert/services/http/index.nix b/bert/services/http/index.nix index 51e12c7..3054875 100644 --- a/bert/services/http/index.nix +++ b/bert/services/http/index.nix @@ -3,6 +3,7 @@ ./files.chandlerswift.com.nix ./git.chandlerswift.com.nix ./home.chandlerswift.com.nix + ./katherineandchandler.com.nix ./maps.chandlerswift.com.nix ./stjohnscccc.org.nix ./swiftgang.net.nix diff --git a/bert/services/http/katherineandchandler.com.nix b/bert/services/http/katherineandchandler.com.nix new file mode 100644 index 0000000..352cf32 --- /dev/null +++ b/bert/services/http/katherineandchandler.com.nix @@ -0,0 +1,14 @@ + +{ + services.caddy.virtualHosts."katherineandchandler.com".extraConfig = '' + encode zstd gzip + file_server + root * /srv/www/katherineandchandler.com + # hide .git # ??? + ''; + systemd.tmpfiles.settings."10-katherineandchandler-com" = { + "/srv/www/katherineandchandler.com" = { + d = {}; + }; + }; +} From 23ad3c1a4743e16daef51bebc4dcc1599055368c Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Wed, 6 Nov 2024 01:22:11 -0600 Subject: [PATCH 16/18] Fix config for stjohnscccc.org --- bert/services/http/stjohnscccc.org.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index 7cbc99a..4a65ce1 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -2,7 +2,7 @@ let app = "stjohnscccc"; domain = "${app}.chandlerswift.com"; # TODO - dataDir = "/srv/www/http/${domain}"; + dataDir = "/srv/www/stjohnscccc.org"; in { services.phpfpm.pools.${app} = { user = app; @@ -22,14 +22,26 @@ in { }; services.caddy.virtualHosts.${domain}.extraConfig = '' root * ${dataDir}/public - encode zstd gzip - file_server - php_fastcgi unix//run/php/php-fpm.sock - log + + handle /downloads/* { + file_server { + browse + hide .gitignore + } + } + + handle { + encode zstd gzip + php_fastcgi unix/${config.services.phpfpm.pools.${app}.socket} + file_server + } + + handle_errors { + respond "{err.status_code} {err.status_text}" + } ''; users.users.${app} = { isSystemUser = true; - createHome = true; home = dataDir; group = app; }; From 9fdf26756e752f7ec7baf4b8fd1d90437589835e Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Wed, 6 Nov 2024 01:44:04 -0600 Subject: [PATCH 17/18] Make Caddy's browse template explicit --- bert/services/http/caddy-browse-template.html | 1144 +++++++++++++++++ bert/services/http/stjohnscccc.org.nix | 2 +- 2 files changed, 1145 insertions(+), 1 deletion(-) create mode 100644 bert/services/http/caddy-browse-template.html diff --git a/bert/services/http/caddy-browse-template.html b/bert/services/http/caddy-browse-template.html new file mode 100644 index 0000000..e0e1296 --- /dev/null +++ b/bert/services/http/caddy-browse-template.html @@ -0,0 +1,1144 @@ +{{- define "icon"}} + {{- if .IsDir}} + {{- if .IsSymlink}} + + + + + + {{- else}} + + + + + {{- end}} + {{- else if or (eq .Name "LICENSE") (eq .Name "README")}} + + + + + + + {{- else if .HasExt ".jpg" ".jpeg" ".png" ".gif" ".webp" ".tiff" ".bmp" ".heif" ".heic" ".svg"}} + {{- if eq .Tpl.Layout "grid"}} + + {{- else}} + + + + + + + + {{- end}} + {{- else if .HasExt ".mp4" ".mov" ".m4v" ".mpeg" ".mpg" ".avi" ".ogg" ".webm" ".mkv" ".vob" ".gifv" ".3gp"}} + + + + + + + + + + + + {{- else if .HasExt ".mp3" ".m4a" ".aac" ".ogg" ".flac" ".wav" ".wma" ".midi" ".cda"}} + + + + + + + + {{- else if .HasExt ".pdf"}} + + + + + + + + + + {{- else if .HasExt ".csv" ".tsv"}} + + + + + + + + + {{- else if .HasExt ".txt" ".doc" ".docx" ".odt" ".fodt" ".rtf"}} + + + + + + + + + {{- else if .HasExt ".xls" ".xlsx" ".ods" ".fods"}} + + + + + + + + + {{- else if .HasExt ".ppt" ".pptx" ".odp" ".fodp"}} + + + + + + + + + + + {{- else if .HasExt ".zip" ".gz" ".xz" ".tar" ".7z" ".rar" ".xz" ".zst"}} + + + + + + + + + + + + {{- else if .HasExt ".deb" ".dpkg"}} + + + + + + {{- else if .HasExt ".rpm" ".exe" ".flatpak" ".appimage" ".jar" ".msi" ".apk"}} + + + + + + + + + {{- else if .HasExt ".ps1"}} + + + + + + + {{- else if .HasExt ".py" ".pyc" ".pyo"}} + + + + + + + + + {{- else if .HasExt ".bash" ".sh" ".com" ".bat" ".dll" ".so"}} + + + + + {{- else if .HasExt ".dmg"}} + + + + + + + + + {{- else if .HasExt ".iso" ".img"}} + + + + + + + + {{- else if .HasExt ".md" ".mdown" ".markdown"}} + + + + + + + {{- else if .HasExt ".ttf" ".otf" ".woff" ".woff2" ".eof"}} + + + + + + + + + {{- else if .HasExt ".go"}} + + + + + + + + + {{- else if .HasExt ".html" ".htm"}} + + + + + + + + + + + + + {{- else if .HasExt ".js"}} + + + + + + + + {{- else if .HasExt ".css"}} + + + + + + + + + {{- else if .HasExt ".json" ".json5" ".jsonc"}} + + + + + + + + {{- else if .HasExt ".ts"}} + + + + + + + + + + {{- else if .HasExt ".sql"}} + + + + + + + + + + + {{- else if .HasExt ".db" ".sqlite" ".bak" ".mdb"}} + + + + + + + {{- else if .HasExt ".eml" ".email" ".mailbox" ".mbox" ".msg"}} + + + + + + {{- else if .HasExt ".crt" ".pem" ".x509" ".cer" ".ca-bundle"}} + + + + + + + + + + {{- else if .HasExt ".key" ".keystore" ".jks" ".p12" ".pfx" ".pub"}} + + + + + + {{- else}} + {{- if .IsSymlink}} + + + + + + + + {{- else}} + + + + + + {{- end}} + {{- end}} +{{- end}} + + + + {{html .Name}} + + + + + +{{- if eq .Layout "grid"}} + +{{- end}} + + +
+
+ +

+ {{range $i, $crumb := .Breadcrumbs}}{{html $crumb.Text}}{{if ne $i 0}}/{{end}}{{end}} +

+
+
+
+
+
+
+ + {{.NumDirs}} director{{if eq 1 .NumDirs}}y{{else}}ies{{end}} + + + {{.NumFiles}} file{{if ne 1 .NumFiles}}s{{end}} + + {{- if ne 0 .Limit}} + + (of which only {{.Limit}} are displayed) + + {{- end}} +
+ + + + + + + List + + + + + + + + + + Grid + +
+
+ {{- if eq .Layout "grid"}} + {{- range .Items}} +
+ + {{template "icon" .}} +
{{html .Name}}
+
{{.HumanSize}}
+
+
+ {{- end}} + {{- else}} + + + + + + + + + + + + {{- if .CanGoUp}} + + + + + + + + {{- end}} + {{- range .Items}} + + + + {{- if .IsDir}} + + {{- else}} + + {{- end}} + + + + {{- end}} + +
+ {{- if and (eq .Sort "namedirfirst") (ne .Order "desc")}} + + + + + + + {{- else if and (eq .Sort "namedirfirst") (ne .Order "asc")}} + + + + + + + {{- else}} + + + + + + + {{- end}} + + {{- if and (eq .Sort "name") (ne .Order "desc")}} + + Name + + + + + + {{- else if and (eq .Sort "name") (ne .Order "asc")}} + + Name + + + + + + {{- else}} + + Name + + {{- end}} + +
+ + + + + + +
+
+ {{- if and (eq .Sort "size") (ne .Order "desc")}} + + Size + + + + + + {{- else if and (eq .Sort "size") (ne .Order "asc")}} + + Size + + + + + + {{- else}} + + Size + + {{- end}} + + {{- if and (eq .Sort "time") (ne .Order "desc")}} + + Modified + + + + + + {{- else if and (eq .Sort "time") (ne .Order "asc")}} + + Modified + + + + + + {{- else}} + + Modified + + {{- end}} +
+ + + + + + Up + +
+ + {{template "icon" .}} + {{html .Name}} + + +
+
+
+ {{.HumanSize}} +
+
+
+ +
+ {{- end}} +
+
+
+ + + + + diff --git a/bert/services/http/stjohnscccc.org.nix b/bert/services/http/stjohnscccc.org.nix index 4a65ce1..b462c02 100644 --- a/bert/services/http/stjohnscccc.org.nix +++ b/bert/services/http/stjohnscccc.org.nix @@ -25,7 +25,7 @@ in { handle /downloads/* { file_server { - browse + browse ${./caddy-browse-template.html} hide .gitignore } } From cdc6b0cb2a0c62a7dcb6e9255f57b1759a901a84 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Wed, 6 Nov 2024 01:44:36 -0600 Subject: [PATCH 18/18] Remove obtrusive Caddy footer from browse template --- bert/services/http/caddy-browse-template.html | 76 ------------------- 1 file changed, 76 deletions(-) diff --git a/bert/services/http/caddy-browse-template.html b/bert/services/http/caddy-browse-template.html index e0e1296..079ab14 100644 --- a/bert/services/http/caddy-browse-template.html +++ b/bert/services/http/caddy-browse-template.html @@ -986,82 +986,6 @@ footer { -