diff --git a/nixos/access/gensokyo.nix b/nixos/access/gensokyo/default.nix similarity index 71% rename from nixos/access/gensokyo.nix rename to nixos/access/gensokyo/default.nix index 591427ea..7760a4a8 100644 --- a/nixos/access/gensokyo.nix +++ b/nixos/access/gensokyo/default.nix @@ -9,7 +9,6 @@ inherit (lib.strings) escapeRegex; inherit (gensokyo-zone.lib) domain; inherit (config.services) nginx; - minecraftBackups = "${config.kyuuto.dataDir}/minecraft/simplebackups"; in { services.nginx.virtualHosts.gensokyoZone = { serverName = domain; @@ -25,20 +24,6 @@ in { } ]; }; - "/minecraft/backups" = { - root = pkgs.linkFarm "genso-minecraft-backups" [ - { - name = "minecraft/backups"; - path = minecraftBackups; - } - ]; - extraConfig = '' - gzip off; - autoindex on; - auth_basic "private"; - auth_basic_user_file ${config.sops.secrets.access-web-htpasswd.path}; - ''; - }; "/.well-known/webfinger" = let # https://www.rfc-editor.org/rfc/rfc7033#section-3.1 oidc = { @@ -73,11 +58,4 @@ in { }; }; }; - systemd.services.nginx.serviceConfig.BindReadOnlyPaths = [ - minecraftBackups - ]; - sops.secrets.access-web-htpasswd = { - sopsFile = mkDefault ../secrets/access.yaml; - owner = nginx.user; - }; } diff --git a/nixos/access/gensokyo/minecraft.nix b/nixos/access/gensokyo/minecraft.nix new file mode 100644 index 00000000..20e491b1 --- /dev/null +++ b/nixos/access/gensokyo/minecraft.nix @@ -0,0 +1,61 @@ +{ + config, + gensokyo-zone, + lib, + pkgs, + ... +}: let + inherit (lib.modules) mkMerge mkDefault; + inherit (gensokyo-zone.lib) domain; + inherit (config.services) nginx; + minecraftBackups = "${config.kyuuto.dataDir}/minecraft/simplebackups"; + minecraftDownloads = "${config.kyuuto.shareDir}/projects/minecraft/public"; + root = pkgs.linkFarm "genso-minecraft-backups" [ + { + name = "minecraft/downloads"; + path = minecraftDownloads; + } + { + name = "minecraft/backups"; + path = minecraftBackups; + } + { + name = "minecraft/wiki/dummy"; + path = "nope"; + } + ]; + extraConfig = '' + gzip off; + autoindex on; + ''; + authPrivate = '' + auth_basic "private"; + auth_basic_user_file ${config.sops.secrets.access-web-htpasswd.path}; + ''; +in { + services.nginx.virtualHosts.gensokyoZone = { + locations = { + "/minecraft" = { + inherit root extraConfig; + }; + "/minecraft/wiki" = { + return = "302 https://wiki.${domain}/minecraft/"; + }; + "/minecraft/backups" = { + inherit root; + extraConfig = mkMerge [ + extraConfig + authPrivate + ]; + }; + }; + }; + systemd.services.nginx.serviceConfig.BindReadOnlyPaths = [ + minecraftBackups + minecraftDownloads + ]; + sops.secrets.access-web-htpasswd = { + sopsFile = mkDefault ../../secrets/access.yaml; + owner = nginx.user; + }; +}