{ config, lib, pkgs, ... }: let cfg = config.niveum.passport; sortOn = a: lib.sort (as1: as2: lib.lessThan (lib.getAttr a as1) (lib.getAttr a as2)); css = '' body { margin: 0; font-family: "Fira Sans Condensed", sans-serif; } main { margin: 0 auto; display: grid; grid-template-columns: 1fr 3fr; grid-gap: 2em; } @media only screen and (max-width: 768px) { main { grid-template-columns: 1fr; } } footer, section { padding: 1em; } footer { text-align: center; } dl { border: 3px double #ccc; padding: 0.5em; } dt { float: left; clear: left; width: 200px; text-align: right; font-weight: bold; margin-right: 1em; margin-bottom: 1em; } dd { margin: 0 0 0 110px; padding: 0 0 0.5em 0; margin-bottom: 1em; } ''; in with lib; { options.niveum.passport = { enable = mkEnableOption "server passport"; introductionHTML = mkOption {type = types.str;}; virtualHost = mkOption { type = types.str; }; services = mkOption { type = types.listOf (types.submodule { options = { title = mkOption {type = types.str;}; link = mkOption { type = types.nullOr types.str; default = null; }; description = mkOption { type = types.str; 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" '' ${config.networking.hostName} passport

${config.networking.hostName}

${cfg.introductionHTML}

Services

${lib.strings.concatMapStringsSep "\n" (service: ''
${lib.optionalString (service.link != null) ""} ${service.title} ${lib.optionalString (service.link != null) ""}
${service.description}
'') (sortOn "title" cfg.services)}
''; } ] }; index index.html; ''; }; }