diff --git a/hosts/hackens-org/hackens-my.nix b/hosts/hackens-org/hackens-my.nix index ea56f7a..47d8a36 100644 --- a/hosts/hackens-org/hackens-my.nix +++ b/hosts/hackens-org/hackens-my.nix @@ -1,11 +1,11 @@ # Inspire du club reseau -{ ... }: +{ lib, ... }: { imports = [ ./modules/my.nix ]; my = { email = "hackens@clipper.ens.fr"; - acmeStaging = true; + acmeStaging = lib.mkDefault true; debug = false; subZone = "new.hackens.org"; }; diff --git a/hosts/hackens-org/modules/staticWebsite.nix b/hosts/hackens-org/modules/staticWebsites.nix similarity index 69% rename from hosts/hackens-org/modules/staticWebsite.nix rename to hosts/hackens-org/modules/staticWebsites.nix index 7fd2d7a..83d9d46 100644 --- a/hosts/hackens-org/modules/staticWebsite.nix +++ b/hosts/hackens-org/modules/staticWebsites.nix @@ -1,7 +1,7 @@ { lib, config , ... }: with lib; let - eachSite = config.services.staticWebsite; + eachSite = config.services.staticWebsites; website = { name, ... }: { options = { root = mkOption { @@ -16,14 +16,18 @@ let }; }; }; - debug = config.my.debug; in { - options.services.staticWebsite = lib.mkOption { - type = types.attrsOf (types.submodule website); - description = "Specification of one or more static-websites to serve"; + options.services.staticWebsites = { + sites = mkOption { + type = types.attrsOf (types.submodule website); + description = "Specification of one or more static websites to serve"; + }; + debug = mkOption { + type = types.bool; + default = false; + }; }; - config = mkIf (eachSite != {}) { services.nginx = { enable = true; diff --git a/hosts/hackens-org/modules/webhook.nix b/hosts/hackens-org/modules/webhooks.nix similarity index 75% rename from hosts/hackens-org/modules/webhook.nix rename to hosts/hackens-org/modules/webhooks.nix index 130885e..d83664d 100644 --- a/hosts/hackens-org/modules/webhook.nix +++ b/hosts/hackens-org/modules/webhooks.nix @@ -3,12 +3,11 @@ with lib; let json = pkgs.formats.json {}; cfg = config.services.webhook; - debug = config.my.debug; in { - options.services.webhook = { + options.services.webhooks = { enable = mkEnableOption "Set up webhooks"; - pkg = mkOption { + package = mkOption { type = types.package; default = pkgs.webhook; description = "`webhook` package to use"; @@ -17,7 +16,7 @@ in type = types.str; description = "The vhost on which webhook will listen"; }; - endPoint = mkOption { + endpoint = mkOption { type = types.str; default = "hooks"; description = "The endpoint of the webhooks"; @@ -31,13 +30,16 @@ in default = 9000; description = "The local port used to (proxy)pass requests from nginx to webhook"; }; + debug = mkOption { + type = types.bool; + default = false; }; config = mkIf cfg.enable { services.nginx = { enable = true; virtualHosts."${cfg.hostname}" = { - locations."${cfg.endPoint}".proxyPass = "http://127.0.0.1:${toString cfg.internalPort}/hooks"; - enableACME = if debug then false else true; + locations."${cfg.endpoint}".proxyPass = "http://127.0.0.1:${toString cfg.internalPort}/hooks"; + enableACME = if cfg.debug then false else true; }; }; systemd.services.webhook = { @@ -46,7 +48,7 @@ in Description = "Small server for creating HTTP hooks"; Documentation = "https://github.com/adnanh/webhook/"; }; - script = "${cfg.pkg}/bin/webhook -nopanic -ip \"127.0.0.1\" -port \"${toString cfg.internalPort}\" -verbose -hooks ${json.generate "conf.json" cfg.hooks}"; + script = "${cfg.package}/bin/webhook -nopanic -ip \"127.0.0.1\" -port \"${toString cfg.internalPort}\" -verbose -hooks ${json.generate "conf.json" cfg.hooks}"; wantedBy = [ "mulit-user.target" ]; }; }; diff --git a/hosts/hackens-org/test-static.nix b/hosts/hackens-org/test-static.nix index c37a6a8..bb61648 100644 --- a/hosts/hackens-org/test-static.nix +++ b/hosts/hackens-org/test-static.nix @@ -1,6 +1,6 @@ { config, pkgs, ... }: { - services.staticWebsite.test = { + services.staticWebsites.test = { hostname = "test.${config.my.subZone}"; root = pkgs.writeTextDir "index.html" "Hello world!"; }; diff --git a/hosts/hackens-org/test-webhook.nix b/hosts/hackens-org/test-webhook.nix index b287451..dacb339 100644 --- a/hosts/hackens-org/test-webhook.nix +++ b/hosts/hackens-org/test-webhook.nix @@ -1,6 +1,6 @@ { config, pkgs, ... }: { - services.webhook = { + services.webhooks = { enable = true; hostname = "test-webhook.${config.my.subZone}"; hooks = [