Sites statique #5
4 changed files with 25 additions and 23 deletions
|
@ -1,10 +1,12 @@
|
|||
# Inspire du club reseau
|
||||
{ ... }:
|
||||
{
|
||||
imports = [ ./my.nix ];
|
||||
imports = [ ./modules/my.nix ];
|
||||
|
||||
my = {
|
||||
email = "hackens@clipper.ens.fr";
|
||||
acmeStaging = true;
|
||||
debug = true;
|
||||
subZone = "new.hackens.org";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Inspiré du club réseau
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
with types;
|
||||
{
|
||||
options.my = {
|
||||
email = mkOption {
|
||||
|
@ -16,12 +17,12 @@ with lib;
|
|||
};
|
||||
subZone = mkOption {
|
||||
description = "Sub zone for hosting the services";
|
||||
type = str
|
||||
|
||||
type = str;
|
||||
};
|
||||
debug = mkOption {
|
||||
description = "Debug mode";
|
||||
type = bool;
|
||||
default = false;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ lib, config }:
|
||||
{ lib, config , ... }:
|
||||
with lib;
|
||||
let
|
||||
eachSite = config.services.static-website;
|
||||
website = { pkgs, config, name, ... }: {
|
||||
eachSite = config.services.staticWebsite;
|
||||
website = { name, ... }: {
|
||||
options = {
|
||||
root = mkOption {
|
||||
type = types.path;
|
||||
|
@ -10,7 +10,7 @@ let
|
|||
description = "Static files path for the website";
|
||||
};
|
||||
hostname = mkOption {
|
||||
type = str;
|
||||
type = types.str;
|
||||
default = name;
|
||||
description = "Website hostname";
|
||||
};
|
||||
|
@ -19,21 +19,20 @@ let
|
|||
debug = config.my.debug;
|
||||
in
|
||||
{
|
||||
services.staticWebsite = lib.mkOption {
|
||||
type = types.attrsOf (types.submodule website;)
|
||||
options.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;
|
||||
config = mkIf (eachSite != {}) {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs ( hostName: conf: {
|
||||
serverName = conf.hostname;
|
||||
root = conf.root;
|
||||
forceSSL = if debug then false else true;
|
||||
enableACME = if debug then false else true;
|
||||
}) eachSite;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/* TODO
|
||||
ACME
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
services.staticWebsite.testStatic.hostname = "test.${my.subZone}";
|
||||
services.staticWebsite.test.hostname = "test.${config.my.subZone}";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue