From d07661561be3559a6dfe411f8a64efd56518a368 Mon Sep 17 00:00:00 2001 From: Xavier Lagraula Date: Mon, 11 May 2026 14:46:33 +0200 Subject: [PATCH] refactor: move host-specific settings to hosts directory - Move defaultNameServers from network/dns.nix to hosts/servers/default.nix and hosts/workstations/default.nix - Move SMTP configuration from network/smtp.nix to hosts/servers/default.nix and hosts/workstations/default.nix - Move proxy configuration from network/proxy.nix to hosts/servers/default.nix and hosts/workstations/default.nix - Move NTP servers from network/time.nix to hosts/default.nix - Remove network/proxy.nix and network/smtp.nix (host-specific settings don't belong in network/) - Update network/default.nix to only import dns.nix and time.nix This refactoring separates environment-specific network parameters (domain, timezone) from host-specific settings (DNS servers, SMTP, proxy, NTP servers), making the configuration more logical and maintainable. --- environments/sample/hosts/default.nix | 19 +++++++++++-- environments/sample/hosts/servers/default.nix | 24 ++++++++++++++-- .../sample/hosts/workstations/default.nix | 28 ++++++++++++++++--- environments/sample/network/default.nix | 4 +-- environments/sample/network/dns.nix | 8 +----- environments/sample/network/proxy.nix | 18 ------------ environments/sample/network/smtp.nix | 12 -------- environments/sample/network/time.nix | 10 ++----- 8 files changed, 65 insertions(+), 58 deletions(-) delete mode 100644 environments/sample/network/proxy.nix delete mode 100644 environments/sample/network/smtp.nix diff --git a/environments/sample/hosts/default.nix b/environments/sample/hosts/default.nix index 5c422ec..9403a59 100644 --- a/environments/sample/hosts/default.nix +++ b/environments/sample/hosts/default.nix @@ -1,14 +1,27 @@ { config, pkgs, lib, ... }: -{ +let + # Import environment-specific network parameters + env = import ../../network { }; +in { # Common settings for all hosts in the sample environment # This file is imported by all host configurations (servers and workstations) - # TODO: Move common settings here later + # NTP servers for this environment + services.ntp.servers = [ + "10.10.128.1" # IPv4 gateway + "fd00::1" # IPv6 gateway + ]; + + # Time settings from network configuration + time.timeZone = env.time.timeZone; + time.hardwareClock = env.time.hardwareClock; + + # TODO: Move other common settings here later # Examples: # - Common users/groups # - Common packages # - Common services # - Common security policies # - Common monitoring/alerting -} \ No newline at end of file +} diff --git a/environments/sample/hosts/servers/default.nix b/environments/sample/hosts/servers/default.nix index 79b31ff..a50502a 100644 --- a/environments/sample/hosts/servers/default.nix +++ b/environments/sample/hosts/servers/default.nix @@ -1,10 +1,28 @@ { config, pkgs, lib, ... }: -{ +let + # Import environment-specific network parameters + env = import ../../../network { }; +in { # Common settings for all servers in the sample environment # This file is imported by all server configurations - # TODO: Move common server settings here later + # Default DNS servers for this environment + networking.nameServers = [ "10.40.128.10" ]; + + # SMTP relay configuration + services.postfix = { + enable = true; + relayHost = "smtp.lagraula.fr"; + relayPort = 587; + useTLS = true; + fromAddress = "noreply@sample.lagraula.fr"; + }; + + # Proxy configuration for servers (none for now) + environment.systemPackages = with pkgs; [ ]; + + # TODO: Move other common server settings here later # Examples: # - Server-specific users/groups # - Server-specific packages @@ -12,4 +30,4 @@ # - Server-specific security policies # - Server-specific monitoring/alerting # - Locale: en_US.UTF-8 (for servers) -} \ No newline at end of file +} diff --git a/environments/sample/hosts/workstations/default.nix b/environments/sample/hosts/workstations/default.nix index 728c73b..f6e2324 100644 --- a/environments/sample/hosts/workstations/default.nix +++ b/environments/sample/hosts/workstations/default.nix @@ -1,15 +1,35 @@ { config, pkgs, lib, ... }: -{ +let + # Import environment-specific network parameters + env = import ../../../network { }; +in { # Common settings for all workstations in the sample environment # This file is imported by all workstation configurations - # TODO: Move common workstation settings here later + # Default DNS servers for this environment + networking.nameServers = [ "10.40.128.10" ]; + + # SMTP relay configuration + services.postfix = { + enable = true; + relayHost = "smtp.lagraula.fr"; + relayPort = 587; + useTLS = true; + fromAddress = "noreply@sample.lagraula.fr"; + }; + + # Proxy configuration for workstations (none for now) + environment.systemPackages = with pkgs; [ ]; + + # Locale for workstations (French) + i18n.defaultLocale = "fr_FR.UTF-8"; + + # TODO: Move other common workstation settings here later # Examples: # - Workstation-specific users/groups # - Workstation-specific packages # - Workstation-specific services # - Workstation-specific security policies # - Workstation-specific monitoring/alerting - # - Locale: fr_FR.UTF-8 (for workstations) -} \ No newline at end of file +} diff --git a/environments/sample/network/default.nix b/environments/sample/network/default.nix index 54f3d33..fcd7824 100644 --- a/environments/sample/network/default.nix +++ b/environments/sample/network/default.nix @@ -11,6 +11,4 @@ { dns = import ./dns.nix; time = import ./time.nix; - proxy = import ./proxy.nix; - smtp = import ./smtp.nix; -} \ No newline at end of file +} diff --git a/environments/sample/network/dns.nix b/environments/sample/network/dns.nix index 5f20cb1..f1e7bb4 100644 --- a/environments/sample/network/dns.nix +++ b/environments/sample/network/dns.nix @@ -4,9 +4,6 @@ # Sample DNS configuration for the sample environment domain = "sample.lagraula.fr"; - # Default DNS servers for this environment - defaultNameServers = [ "10.40.128.10" ]; - # Forwarders for this environment forwarders = [ "1.1.1.1" "8.8.8.8" ]; @@ -15,7 +12,4 @@ # Recursion policy recursion = "AllowOnlyForPrivateNetworks"; - - # Email for Let's Encrypt - letsEncryptEmail = "xavier@lagraula.fr"; -} \ No newline at end of file +} diff --git a/environments/sample/network/proxy.nix b/environments/sample/network/proxy.nix deleted file mode 100644 index 91e1a87..0000000 --- a/environments/sample/network/proxy.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # Proxy configuration for this environment - # Currently no proxy is used — direct access for all hosts - - workstations = { - httpProxy = ""; - httpsProxy = ""; - noProxy = ""; - }; - - servers = { - httpProxy = ""; - httpsProxy = ""; - noProxy = ""; - }; -} \ No newline at end of file diff --git a/environments/sample/network/smtp.nix b/environments/sample/network/smtp.nix deleted file mode 100644 index 7075698..0000000 --- a/environments/sample/network/smtp.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - # SMTP relay configuration for this environment - relayHost = "smtp.lagraula.fr"; - relayPort = 587; - - useTLS = true; - useSTARTTLS = true; - - fromAddress = "noreply@sample.lagraula.fr"; -} \ No newline at end of file diff --git a/environments/sample/network/time.nix b/environments/sample/network/time.nix index 8a534e0..7c8872c 100644 --- a/environments/sample/network/time.nix +++ b/environments/sample/network/time.nix @@ -1,15 +1,9 @@ { config, pkgs, lib, ... }: { - # NTP servers for this environment - ntpServers = [ - "10.10.128.1" # IPv4 gateway - "fd00::1" # IPv6 gateway - ]; - - # Time zone + # Time zone for this environment timeZone = "Europe/Paris"; # Hardware clock setting hardwareClock = "UTC"; -} \ No newline at end of file +}