Sites statique #5

Open
sinavir wants to merge 12 commits from static_website into master
4 changed files with 25 additions and 23 deletions
Showing only changes of commit 06add9c83e - Show all commits

View file

@ -1,10 +1,12 @@
# Inspire du club reseau # Inspire du club reseau
{ ... }: { ... }:
{ {
imports = [ ./my.nix ]; imports = [ ./modules/my.nix ];
my = { my = {
email = "hackens@clipper.ens.fr"; email = "hackens@clipper.ens.fr";
acmeStaging = true; acmeStaging = true;
debug = true;
subZone = "new.hackens.org";
}; };
} }

View file

@ -1,6 +1,7 @@
# Inspiré du club réseau # Inspiré du club réseau
{ config, lib, ... }: { config, lib, ... }:
with lib; with lib;
with types;
{ {
options.my = { options.my = {
email = mkOption { email = mkOption {
@ -16,12 +17,12 @@ with lib;
}; };
subZone = mkOption { subZone = mkOption {
description = "Sub zone for hosting the services"; description = "Sub zone for hosting the services";
type = str type = str;
};
debug = mkOption { debug = mkOption {
description = "Debug mode"; description = "Debug mode";
type = bool; type = bool;
default = false; default = false;
} };
}; };
}; }

View file

@ -1,8 +1,8 @@
{ lib, config }: { lib, config , ... }:
with lib; with lib;
let let
eachSite = config.services.static-website; eachSite = config.services.staticWebsite;
website = { pkgs, config, name, ... }: { website = { name, ... }: {
options = { options = {
root = mkOption { root = mkOption {
type = types.path; type = types.path;
@ -10,7 +10,7 @@ let
description = "Static files path for the website"; description = "Static files path for the website";
}; };
hostname = mkOption { hostname = mkOption {
type = str; type = types.str;
default = name; default = name;
description = "Website hostname"; description = "Website hostname";
}; };
@ -19,21 +19,20 @@ let
debug = config.my.debug; debug = config.my.debug;
in in
{ {
services.staticWebsite = lib.mkOption { options.services.staticWebsite = lib.mkOption {
type = types.attrsOf (types.submodule website;) type = types.attrsOf (types.submodule website);
description = "Specification of one or more static-websites to serve"; description = "Specification of one or more static-websites to serve";
}; };
config = (mkIf eachSite != {}) { config = mkIf (eachSite != {}) {
services.nginx.enable = cfg; services.nginx = {
virtualHosts = mapAttrs ( hostName: conf: { enable = true;
serverName = conf.path; virtualHosts = mapAttrs ( hostName: conf: {
root = conf.root; serverName = conf.hostname;
forceSSL = if debug then false else true; root = conf.root;
}) eachSite; forceSSL = if debug then false else true;
enableACME = if debug then false else true;
}) eachSite;
};
}; };
} }
/* TODO
ACME
*/

View file

@ -1,4 +1,4 @@
{ config, ... }: { config, ... }:
{ {
services.staticWebsite.testStatic.hostname = "test.${my.subZone}"; services.staticWebsite.test.hostname = "test.${config.my.subZone}";
} }