# Nixin web site { config, pkgs, lib, ... }: let inherit (lib) mkOption mkDefault; nixin-web = pkgs.stdenv.mkDerivation { pname = "nixin-web"; version = "0.1-alpha"; src = pkgs.fetchzip { url = "https://git.distrilab.fr/NixiN/nixin-web/actions/runs/85/artifacts/nixin-website.zip"; hash = "sha256-+cgWvbmjV9xckRCeRaj1dWqowBRbe/5497FcoZW+5ec="; stripRoot = false; }; dontConfigure = true; dontBuild = true; installPhase = '' mkdir -p $out cp -a -T $src $out ''; }; in { options = { nixin.web = { http-port = mkOption { type = lib.types.int; }; domain = mkOption { type = lib.types.str; }; }; }; config = { services.nginx.virtualHosts."${config.nixin.web.domain}" = { listen = [ { addr = "127.0.0.1"; port = config.nixin.web.http-port; ssl = false; } { addr = "[::1]"; port = config.nixin.web.http-port; ssl = false; } ]; forceSSL = false; enableACME = false; locations."/".root = ''${nixin-web}''; locations."/".index = "index.html"; }; services.traefik.dynamicConfigOptions.http.services."service-nixin-web" = { loadBalancer.servers = [ { url = "http://localhost:${toString config.nixin.web.http-port}"; } ]; }; services.traefik.dynamicConfigOptions.http.routers."router-nixin-web" = { rule = "Host(`${config.nixin.web.domain}`)"; service = "service-nixin-web"; }; }; }