{ 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 */