Refactor shared Nix configuration to use domain parameter

Updated the shared Nix configuration to replace the hostname parameter with a domain parameter, allowing for more flexible virtual host configurations. Adjusted machine1 and machine2 configurations to reflect this change, ensuring proper domain usage for Nginx virtual hosts, including new entries for web-app, LNbits, and image services.
This commit is contained in:
padreug 2025-10-08 17:11:27 +02:00
parent ea697275ba
commit e399130072

View file

@ -1,8 +1,8 @@
{ config, pkgs, hostName, ... }:
{ config, pkgs, domain, ... }:
{
# Set hostname (passed as parameter)
networking.hostName = hostName;
networking.hostName = domain;
# System packages
environment.systemPackages = with pkgs; [
@ -17,10 +17,28 @@
# Enable and configure nginx
services.nginx = {
enable = true;
virtualHosts."${hostName}" = {
# Web-app service
virtualHosts."app.${domain}" = {
root = "/var/src/web-app-dist";
locations."/" = {
index = "index.html";
tryFiles = "$uri $uri/ /index.html";
};
};
# LNbits service (example - adjust as needed)
virtualHosts."lnbits.${domain}" = {
locations."/" = {
proxyPass = "http://localhost:5000";
proxyWebsockets = true;
};
};
# Image service (example - adjust as needed)
virtualHosts."img.${domain}" = {
locations."/" = {
proxyPass = "http://localhost:8080";
};
};
};