Renommages, améliorations mineures

This commit is contained in:
Maurice Debray 2022-04-03 01:27:30 +02:00
parent 5f02d633bd
commit 19c2b1326a
5 changed files with 23 additions and 17 deletions

View file

@ -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";
};

View file

@ -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 {
options.services.staticWebsites = {
sites = mkOption {
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";
};
debug = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf (eachSite != {}) {
services.nginx = {
enable = true;

View file

@ -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" ];
};
};

View file

@ -1,6 +1,6 @@
{ config, pkgs, ... }:
{
services.staticWebsite.test = {
services.staticWebsites.test = {
hostname = "test.${config.my.subZone}";
root = pkgs.writeTextDir "index.html" "Hello world!";
};

View file

@ -1,6 +1,6 @@
{ config, pkgs, ... }:
{
services.webhook = {
services.webhooks = {
enable = true;
hostname = "test-webhook.${config.my.subZone}";
hooks = [