diff --git a/nixos/flake.lock b/nixos/flake.lock index 8ccef71..3979be2 100644 --- a/nixos/flake.lock +++ b/nixos/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "blog": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1794903473, + "narHash": "sha256-dixOsoH2a1UbhFwQvlGNG2Bg8hvZWn3VIKxnfQAcEI4=", + "ref": "main", + "rev": "f4c1887a42cc190f2d535eb4273f7d3533c8ef16", + "revCount": 23, + "type": "git", + "url": "https://git.asxp.io/asxpi/blog" + }, + "original": { + "ref": "main", + "type": "git", + "url": "https://git.asxp.io/asxpi/blog" + } + }, "comin": { "inputs": { "flake-compat": "flake-compat", @@ -94,6 +115,7 @@ }, "root": { "inputs": { + "blog": "blog", "comin": "comin", "crawler-alert": "crawler-alert", "nixpkgs": "nixpkgs", diff --git a/nixos/flake.nix b/nixos/flake.nix index 0985d69..9c119e9 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -15,6 +15,11 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; }; + # The apps, each from its own repository (hosts/asxpio-services/apps.nix) + blog = { + url = "git+https://git.asxp.io/asxpi/blog?ref=main"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; # only HTML ships + }; # services.crawler-alert (hosts/asxpio-ops/crawler.nix) crawler-alert = { url = "git+https://git.asxp.io/asxpi/traefik-crawlers-statistics?ref=main"; @@ -29,6 +34,7 @@ sops-nix, comin, crawler-alert, + blog, ... }: let @@ -79,7 +85,10 @@ ./hosts/asxpio-ops crawler-alert.nixosModules.default ]; - asxpio-services = mkHost [ ./hosts/asxpio-services ]; + asxpio-services = mkHost [ + ./hosts/asxpio-services + blog.nixosModules.default + ]; }; }; } diff --git a/nixos/hosts/asxpio-ops/traefik.nix b/nixos/hosts/asxpio-ops/traefik.nix index a432c1d..3c3da31 100644 --- a/nixos/hosts/asxpio-ops/traefik.nix +++ b/nixos/hosts/asxpio-ops/traefik.nix @@ -35,6 +35,12 @@ in type = lib.types.listOf lib.types.str; default = [ ]; }; + # Above the app containers' labels (1000) while a service + # takes over from its container + priority = lib.mkOption { + type = lib.types.nullOr lib.types.int; + default = null; + }; }; } ); @@ -43,7 +49,9 @@ in config = { sops.secrets."traefik/letsencrypt_email" = { }; sops.templates."traefik.env".content = '' - TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL=${config.sops.placeholder."traefik/letsencrypt_email"} + TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL=${ + config.sops.placeholder."traefik/letsencrypt_email" + } ''; services.traefik = { @@ -169,13 +177,17 @@ in tls.certResolver = "letsencrypt"; }; } - // lib.mapAttrs (name: r: { - rule = lib.concatMapStringsSep " || " (h: "Host(`${h}`)") r.hosts; - entryPoints = [ "websecure" ]; - service = name; - inherit (r) middlewares; - tls.certResolver = "letsencrypt"; - }) config.asxpio.routes; + // lib.mapAttrs ( + name: r: + { + rule = lib.concatMapStringsSep " || " (h: "Host(`${h}`)") r.hosts; + entryPoints = [ "websecure" ]; + service = name; + inherit (r) middlewares; + tls.certResolver = "letsencrypt"; + } + // lib.optionalAttrs (r.priority != null) { inherit (r) priority; } + ) config.asxpio.routes; services = { garage-web.loadBalancer.servers = [ { url = "http://127.0.0.1:3902"; } ]; diff --git a/nixos/hosts/asxpio-services/apps.nix b/nixos/hosts/asxpio-services/apps.nix new file mode 100644 index 0000000..6955b6d --- /dev/null +++ b/nixos/hosts/asxpio-services/apps.nix @@ -0,0 +1,13 @@ +# The apps, built from their own repositories' flakes (inputs in +# ../../flake.nix) and served here; Traefik on asxpio-ops routes to them +# over the private network (asxpio.routes there). A release is a bump of +# the app's input in flake.lock. +{ ... }: +{ + # A new or changed virtual host reloads nginx instead of restarting it + services.nginx.enableReload = true; + + services.blog.enable = true; # :8081 + + asxpio.security.ports = [ "tcp/8081/nginx" ]; +} diff --git a/nixos/hosts/asxpio-services/default.nix b/nixos/hosts/asxpio-services/default.nix index 82be0ff..4252d72 100644 --- a/nixos/hosts/asxpio-services/default.nix +++ b/nixos/hosts/asxpio-services/default.nix @@ -3,6 +3,7 @@ { imports = [ ./acme-forward.nix + ./apps.nix ./minecraft.nix ./replica.nix ./runner.nix