add options to the nixin-web.nix module
This commit is contained in:
parent
56a57675a1
commit
535a536b57
2 changed files with 44 additions and 31 deletions
|
@ -36,6 +36,11 @@
|
||||||
ipv6 = "2a01:4f9:1a:9a05::2/128";
|
ipv6 = "2a01:4f9:1a:9a05::2/128";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixin.web = {
|
||||||
|
domain = "nixin.lab12.fr";
|
||||||
|
http-port = 8081;
|
||||||
|
};
|
||||||
|
|
||||||
# Enable ip forwarding to route packets for the local network connected to enp3s0
|
# Enable ip forwarding to route packets for the local network connected to enp3s0
|
||||||
boot.kernel.sysctl = {
|
boot.kernel.sysctl = {
|
||||||
"net.ipv4.ip_forward" = 1;
|
"net.ipv4.ip_forward" = 1;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
{
|
# Nixin web site
|
||||||
pkgs,
|
{ config, pkgs, lib, ... }:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
|
inherit (lib) mkOption mkDefault;
|
||||||
|
|
||||||
nixin-web = pkgs.stdenv.mkDerivation {
|
nixin-web = pkgs.stdenv.mkDerivation {
|
||||||
pname = "nixin-web";
|
pname = "nixin-web";
|
||||||
version = "0.1-alpha";
|
version = "0.1-alpha";
|
||||||
|
@ -22,16 +21,24 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.nginx.virtualHosts."nixin.lab12.fr" = {
|
options = {
|
||||||
|
nixin.web = {
|
||||||
|
http-port = mkOption { type = lib.types.int; };
|
||||||
|
domain = mkOption { type = lib.types.str; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
services.nginx.virtualHosts."${config.nixin.web.domain}" = {
|
||||||
listen = [
|
listen = [
|
||||||
{
|
{
|
||||||
addr = "127.0.0.1";
|
addr = "127.0.0.1";
|
||||||
port = 8081;
|
port = config.nixin.web.http-port;
|
||||||
ssl = false;
|
ssl = false;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
addr = "[::1]";
|
addr = "[::1]";
|
||||||
port = 8081;
|
port = config.nixin.web.http-port;
|
||||||
ssl = false;
|
ssl = false;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -43,11 +50,12 @@ in
|
||||||
|
|
||||||
services.traefik.dynamicConfigOptions.http.services."service-nixin-web" = {
|
services.traefik.dynamicConfigOptions.http.services."service-nixin-web" = {
|
||||||
loadBalancer.servers = [
|
loadBalancer.servers = [
|
||||||
{ url = "http://localhost:8081"; }
|
{ url = "http://localhost:${toString config.nixin.web.http-port}"; }
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
services.traefik.dynamicConfigOptions.http.routers."router-nixin-web" = {
|
services.traefik.dynamicConfigOptions.http.routers."router-nixin-web" = {
|
||||||
rule = "Host(`nixin.lab12.fr`)";
|
rule = "Host(`${config.nixin.web.domain}`)";
|
||||||
service = "service-nixin-web";
|
service = "service-nixin-web";
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue