feat : Refractor my host specific to be more generic

This commit is contained in:
Wateir 2025-12-23 16:47:50 +01:00
parent 0d29fd5686
commit 23a6282e6d
10 changed files with 196 additions and 163 deletions

View file

@ -1,5 +1,25 @@
{ ... }:
{
{ config, lib, ... }:
with lib;
let
mkServiceOption = { desc, defaultEnabled ? false, extraOpts ? {} }: mkOption {
description = "Configuration for the ${desc}";
default = {};
type = types.submodule {
options = {
enable = mkEnableOption desc // { default = defaultEnabled; };
} // extraOpts;
};
};
mkPortOption = default: mkOption {
type = types.port;
default = default;
description = "Port for the service to listen on.";
};
in {
imports = [
./nginx.nix
./newt.nix
@ -9,4 +29,48 @@
./roundcube.nix
./vaultWarden.nix
];
options.module = {
domain = mkOption {
type = types.str;
default = "wateir.fr";
};
hostName = mkOption {
type = types.str;
default = "${config.networking.hostName}.${config.module.domain}";
description = "Global FQDN for all hosted services.";
};
acme = mkServiceOption {
desc = "ACME DNS Challenge";
};
tailscale = mkServiceOption {
desc = "Tailscale VPN";
defaultEnabled = true;
};
newt = mkServiceOption {
desc = "Newt custom wireguard tunnel";
};
roundcube = mkServiceOption {
desc = "Roundcube webapp";
extraOpts = { port = mkPortOption 1984; };
};
vaultwarden = mkServiceOption {
desc = "Vaultwarden password manager";
extraOpts = {
externalPort = mkPortOption 8000;
internalPort = mkPortOption 8222;
};
};
searxng = mkServiceOption {
desc = "SearXNG meta-search engine";
extraOpts = { port = mkPortOption 1692; };
};
};
}

18
module/forgejo.nix Normal file
View file

@ -0,0 +1,18 @@
{ config,lib, ... }:
lib.mkIf config.module.forgejo.enable {
services.forgejo = {
enable = true;
database.type = "postgres";
# Enable support for Git Large File Storage
lfs.enable = true;
settings = {
server = {
DOMAIN = "git.example.com";
# You need to specify this to remove the port from URLs in the web UI.
ROOT_URL = "https://${srv.DOMAIN}/";
HTTP_PORT = 3000;
};
};
};
}