diff options
| Commit | 4a93734a74aaefa2f85c9a5483d1668483209267 (patch) | |
|---|---|---|
| Author | 2026-01-24 23:39:28 +0200 | |
| Committer | 2026-01-24 23:39:28 +0200 | |
| Files | 0f6c1caf2f0f13d56baeaedb4796f003490be7dd /machines | |
| nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar nix-4a93734a74aaefa2f85c9a5483d1668483209267.tar.gz nix-4a93734a74aaefa2f85c9a5483d1668483209267.zip | ||
| Parent | 705da9ba2e25fad5f680896f50307f3373d621e2 (diff) | |
feat(machines)!: Split duties between marduk and uttu
6 files changed, 89 insertions, 117 deletions
| -rw-r--r-- | machines/marduk/aim.nix | 5 | ||||
| -rw-r--r-- | machines/marduk/configuration.nix | 59 | ||||
| -rw-r--r-- | machines/marduk/httpd.nix | 40 | ||||
| -rw-r--r-- | machines/marduk/mail.nix | 7 | ||||
| -rw-r--r-- | machines/uttu/configuration.nix | 89 | ||||
| -rw-r--r-- | machines/uttu/httpd.nix | 6 |
diff --git a/machines/marduk/aim.nix b/machines/marduk/aim.nix index 707cf36..95113f9 100644 --- a/machines/marduk/aim.nix +++ b/machines/marduk/aim.nix @@ -1,7 +1,8 @@ { config, ... }: let - aimDomain = "aim." + config.constants.tld; + inherit (config.srv) tld; + aimDomain = "aim." + tld; in { - services.dnsmasq.settings.address = [ "/${aimDomain}/${config.constants.ip}" ]; + srv.slds = [ "aim" ]; services.retro-aim-server = { enable = true; diff --git a/machines/marduk/configuration.nix b/machines/marduk/configuration.nix index c7a12b7..b99840f 100644 --- a/machines/marduk/configuration.nix +++ b/machines/marduk/configuration.nix @@ -1,48 +1,39 @@ # This is device is meant to be a home, LOCAL ONLY server! # The configurations you will find are woefully insecure and hard-coded. -{ lib, ... }: { +{ config, lib, ... }: { imports = [ - ./httpd.nix ./mail.nix ./aim.nix ./kamen.nix ]; - options = { - constants = lib.mkOption { - type = lib.types.attrs; + srv = { + static = { + ip = "192.168.0.20"; + interface = "enp1s0"; }; + # This is actually a fantastic TLD. Very few sites use it, you may + # consider it as an abbreviation of "internal" and is one of the + # "original" gTLDs, introduced in 1988, so every device will always + # work with it. + tld = "int"; }; - config = rec { - constants = { - # I've currently set this IP in my router configuration. - # It would be better to write a proper static IP NixOS config, but its - # fine like that. - ip = "192.168.0.10"; - # This is actually a fantastic TLD. Very few sites use it, you may - # consider it as an abbreviation of "internal" and is one of the - # "original" gTLDs, introduced in 1988, so every device will always - # work with it. - tld = "int"; - }; - - # This improves SSH speed via server.int - # The main problem is that when SSH-ing with server.int, the domain is - # queried, however DNS resolution doesn't happen through dnsmasq but - # through the nss hosts, which causes ~20 seconds of delay. - # Now we're first checking /etc/hosts and then the databases listed. - networking.hosts = { - ${constants.ip} = [ "server.int" ]; - }; - system.nssDatabases.hosts = lib.mkForce [ - "files" - "mymachines" - "mdns4_minimal" - "[NOTFOUND=return]" - "myhostname" - "dns" - ]; + # This improves SSH speed via server.int + # The main problem is that when SSH-ing with server.int, the domain is + # queried, however DNS resolution doesn't happen through dnsmasq but + # through the nss hosts, which causes ~20 seconds of delay. + # Now we're first checking /etc/hosts and then the databases listed. + networking.hosts = { + ${config.srv.static.ip} = [ "${config.networking.hostName}.${config.srv.tld}" ]; }; + system.nssDatabases.hosts = lib.mkForce [ + "files" + "mymachines" + "mdns4_minimal" + "[NOTFOUND=return]" + "myhostname" + "dns" + ]; } diff --git a/machines/marduk/httpd.nix b/machines/marduk/httpd.nix deleted file mode 100644 index eb6d8af..0000000 --- a/machines/marduk/httpd.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ config, ... }: let - inherit (config.constants) ip tld; -in { - services.dnsmasq.settings.address = [ - "/server.${tld}/ftp.${tld}/samba.${tld}/${ip}" - ]; - - services.httpd = { - virtualHosts = { - "server.${tld}" = { - listen = [ { port = 80; } ]; - documentRoot = "/var/www/server"; - locations."/server-status".extraConfig = '' - SetHandler server-status - ''; - }; - - #== File servers ==# - - "samba.${tld}" = rec { - listen = [ { port = 80; } ]; - documentRoot = "/NetworkDirectory"; - extraConfig = '' - <Directory "${documentRoot}"> - IndexOptions +NameWidth=* +Charset=UTF-8 - </Directory> - ''; - }; - "ftp.${tld}" = rec { - listen = [ { port = 80; } ]; - documentRoot = "/home/ftp"; - extraConfig = '' - <Directory "${documentRoot}"> - IndexOptions +NameWidth=* +Charset=UTF-8 - </Directory> - ''; - }; - }; - }; -} diff --git a/machines/marduk/mail.nix b/machines/marduk/mail.nix index 928be56..9436035 100644 --- a/machines/marduk/mail.nix +++ b/machines/marduk/mail.nix @@ -17,11 +17,10 @@ # Authentication method: Normal Password # Username : NAME@mail.int { pkgs, config, ... }: let - mailDomain = "mail." + config.constants.tld; + inherit (config.srv) tld; + mailDomain = "mail." + tld; in { - services.dnsmasq.settings.address = [ - "/${mailDomain}/${config.constants.ip}" - ]; + srv.slds = [ "mail" ]; services.maddy = { localDomains = [ mailDomain ]; diff --git a/machines/uttu/configuration.nix b/machines/uttu/configuration.nix index 7d18b3d..e3a1d5c 100644 --- a/machines/uttu/configuration.nix +++ b/machines/uttu/configuration.nix @@ -1,44 +1,67 @@ # This is device is meant to be a home, LOCAL ONLY server! # The configurations you will find are woefully insecure and hard-coded. -{ lib, ... }: { +{ config, lib, ... }: { imports = [ ./httpd.nix ]; - options = { - constants = lib.mkOption { - type = lib.types.attrs; + srv = { + static = { + ip = "192.168.0.10"; + interface = "enp1s0"; }; + # This is actually a fantastic TLD. Very few sites use it, you may + # consider it as an abbreviation of "internal" and is one of the + # "original" gTLDs, introduced in 1988, so every device will always + # work with it. + tld = "int"; }; - config = rec { - constants = { - # I've currently set this IP in my router configuration. - # It would be better to write a proper static IP NixOS config, but its - # fine like that. - ip = "192.168.0.11"; - # This is actually a fantastic TLD. Very few sites use it, you may - # consider it as an abbreviation of "internal" and is one of the - # "original" gTLDs, introduced in 1988, so every device will always - # work with it. - tld = "int"; - }; - - # This improves SSH speed via server.int - # The main problem is that when SSH-ing with server.int, the domain is - # queried, however DNS resolution doesn't happen through dnsmasq but - # through the nss hosts, which causes ~20 seconds of delay. - # Now we're first checking /etc/hosts and then the databases listed. - networking.hosts = { - ${constants.ip} = [ "server.int" ]; - }; - system.nssDatabases.hosts = lib.mkForce [ - "files" - "mymachines" - "mdns4_minimal" - "[NOTFOUND=return]" - "myhostname" - "dns" - ]; + # This improves SSH speed via server.int + # The main problem is that when SSH-ing with server.int, the domain is + # queried, however DNS resolution doesn't happen through dnsmasq but + # through the nss hosts, which causes ~20 seconds of delay. + # Now we're first checking /etc/hosts and then the databases listed. + networking.hosts = { + ${config.srv.static.ip} = [ "${config.networking.hostName}.${config.srv.tld}" ]; }; + system.nssDatabases.hosts = lib.mkForce [ + "files" + "mymachines" + "mdns4_minimal" + "[NOTFOUND=return]" + "myhostname" + "dns" + ]; + + # Redirect all domains, defined by marduk, to marduk + services.dnsmasq.settings.address = let + configurationPath = ../marduk/configuration.nix; + + importModule = path: + let + module = import path; + in + if builtins.isFunction module + then module { config = {}; lib = {}; pkgs = {}; } + else module; + + inherit (importModule configurationPath) srv; + + extractAttrs = moduleImport: + let + module = importModule moduleImport; + in + (module.srv.slds or []) ++ + (builtins.foldl' + (acc: x: + acc ++ extractAttrs x) + [] + (module.imports or [])); + + slds = extractAttrs configurationPath; + in + builtins.map + (sld: "/${sld}.${srv.tld}/${srv.static.ip}") + slds; } diff --git a/machines/uttu/httpd.nix b/machines/uttu/httpd.nix index eb6d8af..ca215d7 100644 --- a/machines/uttu/httpd.nix +++ b/machines/uttu/httpd.nix @@ -1,9 +1,7 @@ { config, ... }: let - inherit (config.constants) ip tld; + inherit (config.srv) tld; in { - services.dnsmasq.settings.address = [ - "/server.${tld}/ftp.${tld}/samba.${tld}/${ip}" - ]; + srv.slds = [ "server" "ftp" "samba" ]; services.httpd = { virtualHosts = { |
