nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit 73df4997672415620dc80f72794ca96b3df44082
parent c3e9b18480d07dc5cee30b6f28740256fbcf7193
Author: mtmn <miro@haravara.org>
Date:   Mon, 13 Apr 2026 00:48:16 +0200

chore: cleanup static

Diffstat:
Mhosts/nixaran/configuration.nix | 0
Mmodules/mixins/dotfiles/config/shell/rc/aliased-short-names | 1-
Mmodules/services/caddy.nix | 18------------------
Mmodules/services/static.nix | 47++++++++++++-----------------------------------
4 files changed, 12 insertions(+), 54 deletions(-)

diff --git a/hosts/nixaran/configuration.nix b/hosts/nixaran/configuration.nix Binary files differ. diff --git a/modules/mixins/dotfiles/config/shell/rc/aliased-short-names b/modules/mixins/dotfiles/config/shell/rc/aliased-short-names @@ -102,7 +102,6 @@ alias datamix='datasette serve $HOME/.mixxx/mixxxdb.sqlite --setting sql_time_li alias nd='nix develop' alias hms='backup nix && nh home switch ~/src/nix' -alias hmdiff='home-manager generations | head -n 2 | cut -d' ' -f 7 | tac | xargs nvd diff' alias amsp='mpva https://radio.stereoscenic.com/asp-s --no-resume-playback' alias nts1='mpva https://stream-relay-geo.ntslive.net/stream --no-resume-playback' diff --git a/modules/services/caddy.nix b/modules/services/caddy.nix @@ -4,8 +4,6 @@ ... }: let cfg = config.services.haravara.caddy; - mtmnCfg = config.services.haravara.mtmn; - staticFiles = ../../static/mtmn; mkAuthSnippet = name: authDomain: '' (${name}) { @@ -21,10 +19,6 @@ } ''; in { - options.services.haravara.mtmn = { - enable = lib.mkEnableOption "mtmn static site"; - }; - options.services.haravara.caddy = { enable = lib.mkEnableOption "Caddy reverse proxy and static site server"; email = lib.mkOption { @@ -70,20 +64,8 @@ in { } } ''; - virtualHosts = lib.optionalAttrs mtmnCfg.enable { - "mtmn.name".extraConfig = '' - root * ${staticFiles} - file_server - handle /moments-eluding { - redir https://soundcloud.com/haravara/sets/moments-eluding permanent - } - ''; - }; }; networking.firewall.allowedTCPPorts = [80 443]; - systemd.tmpfiles.rules = [ - "d /var/lib/haravara/static 0755 caddy caddy -" - ]; }; } diff --git a/modules/services/static.nix b/modules/services/static.nix @@ -17,11 +17,6 @@ in { type = lib.types.str; description = "Directory name in static folder"; }; - hasMine = lib.mkOption { - type = lib.types.bool; - default = false; - description = "Whether to handle the ~m/mine directory mapping"; - }; hasRedirect = lib.mkOption { type = lib.types.bool; default = false; @@ -32,6 +27,11 @@ in { default = false; description = "Whether to handle /s/ shortener proxy"; }; + extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Extra Caddy config appended to the virtual host"; + }; }; }); }; @@ -41,41 +41,17 @@ in { users.users.caddy.extraGroups = ["storage-users"]; systemd.tmpfiles.rules = - [ - "d /var/lib/haravara/static 0755 caddy caddy -" - ] - ++ (lib.concatLists (lib.mapAttrsToList (_: opt: - [ - "d /var/lib/haravara/static/${opt.dir} 0755 caddy caddy -" - "L+ /var/lib/haravara/static/${opt.dir}/index.html - - - - ${staticFiles}/${opt.dir}/index.html" - ] - ++ lib.optionals opt.hasMine [ - "d /var/lib/haravara/static/${opt.dir}/mine 0755 caddy caddy -" - "L+ /var/lib/haravara/static/${opt.dir}/mine/tempo.html - - - - ${staticFiles}/${opt.dir}/mine/tempo.html" - # Special case for avatar which might not exist in all dirs, but we link it if it's there - "L+ /var/lib/haravara/static/${opt.dir}/mine/avatar.jpg - - - - ${staticFiles}/${opt.dir}/mine/avatar.jpg" - ] - ++ lib.optionals (opt.dir != "") [ - "L+ /var/lib/haravara/static/${opt.dir}/hello.jpg - - - - ${staticFiles}/${opt.dir}/hello.jpg" - ]) - cfg.domains)); + ["d /var/lib/haravara/static 0755 caddy caddy -"] + ++ lib.mapAttrsToList ( + _: opt: "L+ /var/lib/haravara/static/${opt.dir} - - - - ${staticFiles}/${opt.dir}" + ) + cfg.domains; services.caddy.virtualHosts = lib.mapAttrs (domain: opt: { extraConfig = '' root * /var/lib/haravara/static/${opt.dir} - '' - + lib.optionalString opt.hasMine '' - # Map ~m to the physical 'mine' directory - handle /~m/* { - uri strip_prefix /~m - file_server { - root /var/lib/haravara/static/${opt.dir}/mine - } - } - '' - + '' file_server '' + lib.optionalString opt.hasShortener '' @@ -85,7 +61,8 @@ in { '' + lib.optionalString opt.hasRedirect '' redir / https://${lib.concatStringsSep "." (lib.drop 1 (lib.splitString "." domain))} - ''; + '' + + opt.extraConfig; }) cfg.domains; };