48 lines
1.8 KiB
Nix
48 lines
1.8 KiB
Nix
{ config, pkgs, lib, mkDomain, allSubdomains, ... }:
|
|
let
|
|
# TODO: support fully qualified urls as well
|
|
customDescriptions = rec {
|
|
index = "This page";
|
|
links = "Linktree";
|
|
element = pkgs.element-web.meta.description;
|
|
refleksjon = "My dad is a cheapskate";
|
|
roroslyd = "My dad is a cheapskate";
|
|
www = "wwwwwwwwwwwwwww";
|
|
${config.networking.hostName} = www;
|
|
shlink = "Url shortener";
|
|
docs = "Various documentation";
|
|
};
|
|
in
|
|
{
|
|
# list of other endpoints hosted with nginx
|
|
# it assumes the owest subdomain equals a package name in pkgs or python3.pkgs.
|
|
|
|
services.nginx.virtualHosts.${mkDomain "index"} = {
|
|
forceSSL = true; # addSSL = true;
|
|
enableACME = true; #useACMEHost = acmeDomain;
|
|
root = with lib; let
|
|
getName = domain: head (lib.splitString "." domain);
|
|
getDomain = domain: concatStringsSep "." (tail (lib.splitString "." domain));
|
|
getDesc = domain: let
|
|
name = getName domain;
|
|
in if lib.hasAttr name customDescriptions
|
|
then customDescriptions.${name}
|
|
else if lib.hasAttr name pkgs.python3Packages
|
|
then pkgs.python3Packages.${name}.meta.description
|
|
else if lib.hasAttr name pkgs
|
|
then pkgs.${name}.meta.description
|
|
else if lib.hasAttrByPath [name "package"] config.services
|
|
then config.services.${name}.package.meta.description
|
|
else "";
|
|
mkRow = domain: ''<tr><td><a href="//${domain}">${getName domain}<span style=\"opacity: 0.65;\">.${getDomain domain}</span></a><td>${getDesc domain}'';
|
|
in pkgs.writeTextDir "index.html" ''
|
|
<!DOCTYPE html>
|
|
<table>
|
|
<tr><th>url<th>description
|
|
${lib.concatStringsSep "\n" (map mkRow allSubdomains)}
|
|
</table>
|
|
'';
|
|
};
|
|
|
|
}
|