hackens-org-configurations/hosts/hackens-org/modules/staticWebsite.nix

40 lines
906 B
Nix
Raw Normal View History

2022-03-31 09:36:51 +02:00
{ lib, config }:
with lib;
let
eachSite = config.services.static-website;
website = { pkgs, config, name, ... }: {
options = {
root = mkOption {
type = types.path;
default = "/var/lib/nginx/static/${name}";
description = "Static files path for the website";
};
hostname = mkOption {
type = str;
default = name;
description = "Website hostname";
};
};
};
debug = config.my.debug;
in
{
services.staticWebsite = lib.mkOption {
type = types.attrsOf (types.submodule website;)
description = "Specification of one or more static-websites to serve";
};
config = (mkIf eachSite != {}) {
services.nginx.enable = cfg;
virtualHosts = mapAttrs ( hostName: conf: {
serverName = conf.path;
root = conf.root;
forceSSL = if debug then false else true;
}) eachSite;
};
}
/* TODO
ACME
*/