diff --git a/hosts/hackens-org/hackens-my.nix b/hosts/hackens-org/hackens-my.nix index d1d04ce..f22d3ef 100644 --- a/hosts/hackens-org/hackens-my.nix +++ b/hosts/hackens-org/hackens-my.nix @@ -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"; }; } diff --git a/hosts/hackens-org/modules/my.nix b/hosts/hackens-org/modules/my.nix index 92caf6f..29f2870 100644 --- a/hosts/hackens-org/modules/my.nix +++ b/hosts/hackens-org/modules/my.nix @@ -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; - } + }; }; -}; +} diff --git a/hosts/hackens-org/modules/staticWebsite.nix b/hosts/hackens-org/modules/staticWebsite.nix index 674276b..7fd2d7a 100644 --- a/hosts/hackens-org/modules/staticWebsite.nix +++ b/hosts/hackens-org/modules/staticWebsite.nix @@ -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 -*/ diff --git a/hosts/hackens-org/test-static.nix b/hosts/hackens-org/test-static.nix index c17caa6..8a0094a 100644 --- a/hosts/hackens-org/test-static.nix +++ b/hosts/hackens-org/test-static.nix @@ -1,4 +1,4 @@ { config, ... }: { - services.staticWebsite.testStatic.hostname = "test.${my.subZone}"; + services.staticWebsite.test.hostname = "test.${config.my.subZone}"; }