2024-03-02 22:05:30 +01:00
|
|
|
{inputs, ...}: {
|
2023-06-19 01:19:55 +02:00
|
|
|
flake.nixngConfigurations.ingressToothpick = inputs.nixng.nglib.makeSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
name = "ingress-toothpick";
|
|
|
|
inherit (inputs) nixpkgs;
|
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
config = {
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
nglib,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
singleton
|
|
|
|
;
|
|
|
|
in {
|
|
|
|
dumb-init = {
|
|
|
|
enable = true;
|
|
|
|
sigell.entries = [
|
|
|
|
{
|
|
|
|
signal = "HUP";
|
|
|
|
action = {
|
|
|
|
type = "exec";
|
|
|
|
environment = {
|
|
|
|
PATH = "${pkgs.bash}/bin:${pkgs.busybox}/bin";
|
|
|
|
};
|
|
|
|
command = [
|
|
|
|
"bash"
|
|
|
|
"-c"
|
|
|
|
"kill -s HUP \"$(cat /nginx.pid)\""
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
signal = "TERM";
|
|
|
|
action = {
|
|
|
|
type = "signal";
|
|
|
|
rewrite = "TERM";
|
|
|
|
selector = {
|
|
|
|
type = "child";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
type.services = {};
|
|
|
|
};
|
|
|
|
init.services.nginx.shutdownOnExit = true;
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
system.activation = {
|
|
|
|
resolv-conf =
|
|
|
|
nglib.dag.dagEntryBefore ["certbot"]
|
|
|
|
''
|
|
|
|
export PATH=${pkgs.busybox}/bin
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
mkdir -p /etc
|
|
|
|
echo "nameserver 8.8.8.8" > /etc/resolv.conf
|
|
|
|
'';
|
|
|
|
};
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
services.certbot = {
|
|
|
|
enable = true;
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
acceptTerms = true;
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
domains = {
|
|
|
|
"redalder.org" = {
|
|
|
|
extraDomains = [
|
|
|
|
"hydra.redalder.org"
|
|
|
|
"gitea.redalder.org"
|
|
|
|
"matrix.redalder.org"
|
2024-04-27 22:10:15 +02:00
|
|
|
"buildbot.redalder.org"
|
2024-03-02 22:05:30 +01:00
|
|
|
"nixng.org"
|
|
|
|
];
|
|
|
|
webroot = "/var/www/certbot";
|
|
|
|
email = "admin@redalder.org";
|
|
|
|
extraOptions = "--expand --keep-until-expiring --renew-with-new-domains -v";
|
2023-06-19 01:19:55 +02:00
|
|
|
};
|
2024-03-02 22:05:30 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
envsubst = true;
|
|
|
|
configuration = [
|
|
|
|
{
|
|
|
|
daemon = "off";
|
|
|
|
worker_processes = 2;
|
|
|
|
user = "nginx";
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
events."" = {
|
|
|
|
use = "epoll";
|
|
|
|
worker_connections = 128;
|
|
|
|
};
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
error_log = ["/dev/stderr" "warn"];
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
pid = "/nginx.pid";
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
stream."" = {
|
|
|
|
include = [
|
|
|
|
["/local/streams.conf"]
|
|
|
|
];
|
|
|
|
};
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
http."" = {
|
|
|
|
server_tokens = "off";
|
|
|
|
include = [
|
|
|
|
["${pkgs.nginx}/conf/mime.types"]
|
|
|
|
["/local/upstreams.conf"]
|
|
|
|
];
|
|
|
|
charset = "utf-8";
|
|
|
|
access_log = ["/dev/stdout" "combined"];
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
server."" = {
|
|
|
|
listen = ["80" "default_server"];
|
|
|
|
server_name = [
|
|
|
|
"redalder.org"
|
|
|
|
"nixng.org"
|
|
|
|
];
|
2023-06-19 01:19:55 +02:00
|
|
|
|
2024-03-02 22:05:30 +01:00
|
|
|
location."/" = {
|
|
|
|
return = ["301" "https://$$host$$request_uri"];
|
2023-06-19 01:19:55 +02:00
|
|
|
};
|
2024-03-02 22:05:30 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-06-19 01:19:55 +02:00
|
|
|
};
|
|
|
|
}
|