mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
format
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
let
|
||||
cfg = config.niveum.passport;
|
||||
sortOn = a: lib.sort (as1: as2: lib.lessThan (lib.getAttr a as1) (lib.getAttr a as2));
|
||||
css = ''
|
||||
@@ -52,20 +53,22 @@
|
||||
}
|
||||
'';
|
||||
in
|
||||
with lib; {
|
||||
options.niveum.passport = {
|
||||
enable = mkEnableOption "server passport";
|
||||
with lib;
|
||||
{
|
||||
options.niveum.passport = {
|
||||
enable = mkEnableOption "server passport";
|
||||
|
||||
introductionHTML = mkOption {type = types.str;};
|
||||
introductionHTML = mkOption { type = types.str; };
|
||||
|
||||
virtualHost = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
virtualHost = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
services = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
services = mkOption {
|
||||
type = types.listOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
title = mkOption {type = types.str;};
|
||||
title = mkOption { type = types.str; };
|
||||
link = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
@@ -75,61 +78,62 @@ in
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
});
|
||||
default = [];
|
||||
}
|
||||
);
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.nginx.enable = true;
|
||||
|
||||
services.nginx.virtualHosts."${cfg.virtualHost}".locations."/passport".extraConfig = ''
|
||||
default_type "text/html";
|
||||
root ${
|
||||
pkgs.linkFarm "www" [
|
||||
{
|
||||
name = "passport/index.html";
|
||||
path = pkgs.writeText "index.html" ''
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>${config.networking.hostName} passport</title>
|
||||
<style>${css}</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<section id="server">
|
||||
<h1>${config.networking.hostName}</h1>
|
||||
${cfg.introductionHTML}
|
||||
</section>
|
||||
|
||||
<section id="services">
|
||||
<h2>Services</h2>
|
||||
<dl>
|
||||
${lib.strings.concatMapStringsSep "\n" (service: ''
|
||||
<dt>
|
||||
${lib.optionalString (service.link != null) "<a href=\"${service.link}\">"}
|
||||
${service.title}
|
||||
${lib.optionalString (service.link != null) "</a>"}
|
||||
</dt>
|
||||
<dd>
|
||||
${service.description}
|
||||
</dd>
|
||||
'') (sortOn "title" cfg.services)}
|
||||
</dl>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<tt>${config.networking.hostName}</tt> is part of the <i><a href="https://github.com/kmein/niveum/tree/master/systems/${config.networking.hostName}">niveum</a></i> network.
|
||||
</footer>
|
||||
</body>
|
||||
'';
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.nginx.enable = true;
|
||||
|
||||
services.nginx.virtualHosts."${cfg.virtualHost}".locations."/passport".extraConfig = ''
|
||||
default_type "text/html";
|
||||
root ${
|
||||
pkgs.linkFarm "www" [
|
||||
{
|
||||
name = "passport/index.html";
|
||||
path = pkgs.writeText "index.html" ''
|
||||
<!doctype html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>${config.networking.hostName} passport</title>
|
||||
<style>${css}</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<section id="server">
|
||||
<h1>${config.networking.hostName}</h1>
|
||||
${cfg.introductionHTML}
|
||||
</section>
|
||||
|
||||
<section id="services">
|
||||
<h2>Services</h2>
|
||||
<dl>
|
||||
${lib.strings.concatMapStringsSep "\n" (service: ''
|
||||
<dt>
|
||||
${lib.optionalString (service.link != null) "<a href=\"${service.link}\">"}
|
||||
${service.title}
|
||||
${lib.optionalString (service.link != null) "</a>"}
|
||||
</dt>
|
||||
<dd>
|
||||
${service.description}
|
||||
</dd>
|
||||
'') (sortOn "title" cfg.services)}
|
||||
</dl>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<tt>${config.networking.hostName}</tt> is part of the <i><a href="https://github.com/kmein/niveum/tree/master/systems/${config.networking.hostName}">niveum</a></i> network.
|
||||
</footer>
|
||||
</body>
|
||||
'';
|
||||
}
|
||||
]
|
||||
};
|
||||
index index.html;
|
||||
'';
|
||||
};
|
||||
}
|
||||
index index.html;
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user