shortcutdomains: generate an index page
misusing nix as an html templating language, yay! We could (and maybe should) also use something more reasonable instead, e.g. jekyll or hakyll, but for a simple listing nix turns out to be quite enough. The page doesn't look all too well for now; I haven't set any css, or even added some <div>-tags for basic styling.
This commit is contained in:
parent
e07d23e2ee
commit
9eed435ea3
1 changed files with 35 additions and 5 deletions
|
@ -2,21 +2,51 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
shortdomain = "i4f.de";
|
shortdomain = "i4f.de";
|
||||||
short = abbrv: target: {
|
short = name: target: {
|
||||||
name = "${abbrv}.${shortdomain}";
|
inherit name target;
|
||||||
|
};
|
||||||
|
toVirtualHosts = {name, target, ...}: {
|
||||||
|
name = "${name}.${shortdomain}";
|
||||||
value = {
|
value = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
locations."/".return = "302 https://${target}$request_uri";
|
locations."/".return = "302 https://${target}$request_uri";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
redirects = [
|
||||||
{
|
|
||||||
services.nginx.virtualHosts = lib.listToAttrs [
|
|
||||||
(short "d" "discuss.infra4future.de")
|
(short "d" "discuss.infra4future.de")
|
||||||
(short "m" "mattermost.infra4future.de")
|
(short "m" "mattermost.infra4future.de")
|
||||||
(short "c" "cloud.infra4future.de")
|
(short "c" "cloud.infra4future.de")
|
||||||
(short "s" "survey.infra4future.de")
|
(short "s" "survey.infra4future.de")
|
||||||
(short "g" "gitlab.infra4future.de")
|
(short "g" "gitlab.infra4future.de")
|
||||||
];
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.nginx.virtualHosts =
|
||||||
|
lib.listToAttrs (map toVirtualHosts redirects)
|
||||||
|
// {
|
||||||
|
${shortdomain} = {
|
||||||
|
enableACME = true;
|
||||||
|
forceSSL = true;
|
||||||
|
root = pkgs.writeText "index.html" ''
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Infra4future shortlinks</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
</head>
|
||||||
|
<body><h1>Shortlinks for infra4future.de</h1>
|
||||||
|
${lib.strings.concatStrings
|
||||||
|
(map ({name, target,...}:
|
||||||
|
''
|
||||||
|
<p>
|
||||||
|
<a href="https://${target}">${name}.${shortdomain} → ${target}</a>
|
||||||
|
</p>
|
||||||
|
'')
|
||||||
|
redirects)
|
||||||
|
}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue