1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: add serveHtml helper

This commit is contained in:
2021-10-11 20:02:17 +02:00
parent f6ffd477d1
commit 2384a4eef5
3 changed files with 11 additions and 18 deletions

View File

@@ -1,11 +1,12 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
inherit (import <niveum/lib>) serveHtml;
stations = [ stations = [
900068204 # A/M 900068204 # A/M
900068302 # KAS 900068302 # KAS
900068203 # B-P 900068203 # B-P
]; ];
fahrplanHtml = '' fahrplan = pkgs.writeText "fahrplan.html" ''
<!DOCTYPE html> <!DOCTYPE html>
<title>Fahrplan</title> <title>Fahrplan</title>
<link <link
@@ -51,10 +52,6 @@ in
}; };
services.nginx.virtualHosts."bvg.kmein.r" = { services.nginx.virtualHosts."bvg.kmein.r" = {
locations."/".extraConfig = '' locations."/".extraConfig = serveHtml fahrplan pkgs;
default_type "text/html";
root ${pkgs.linkFarm "fahrplan" [{ name = "index.html"; path = pkgs.writeText "fahrplan.html" fahrplanHtml; }]};
index index.html;
'';
}; };
} }

View File

@@ -1,6 +1,6 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
let let
inherit (import <niveum/lib>) tmpfilesConfig; inherit (import <niveum/lib>) tmpfilesConfig serveHtml;
radioStore = "/var/lib/radio"; radioStore = "/var/lib/radio";
htgenPort = 8080; htgenPort = 8080;
@@ -197,17 +197,7 @@ in
forceSSL = true; forceSSL = true;
locations = lib.mkMerge ( locations = lib.mkMerge (
[ [
{ { "/".extraConfig = serveHtml (import ./station-list.nix { inherit pkgs lib stations; }) pkgs; }
"/".extraConfig = ''
default_type "text/html";
root ${pkgs.linkFarm "station-list" [{
name = "index.html";
path = import ./station-list.nix { inherit pkgs lib stations; };
}]};
index index.html;
'';
# skip
}
] ++ (lib.mapAttrsToList (name: station: { ] ++ (lib.mapAttrsToList (name: station: {
"= /${name}/status".proxyPass = "http://127.0.0.1:${toString htgenPort}"; "= /${name}/status".proxyPass = "http://127.0.0.1:${toString htgenPort}";
"= /${name}/listen.ogg".proxyPass = "http://127.0.0.1:${toString station.streamPort}"; "= /${name}/listen.ogg".proxyPass = "http://127.0.0.1:${toString station.streamPort}";

View File

@@ -7,6 +7,12 @@ rec {
removeRules = lib.concatMapStringsSep "\n" (rule: "iptables -D ${rule} || true"); removeRules = lib.concatMapStringsSep "\n" (rule: "iptables -D ${rule} || true");
}; };
serveHtml = file: pkgs: ''
default_type "text/html";
root ${pkgs.linkFarm "fahrplan" [{ name = "index.html"; path = file; }]};
index index.html;
'';
sshPort = 22022; sshPort = 22022;
colours = import ./colours/mac-os.nix; colours = import ./colours/mac-os.nix;