diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c528b36 --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# ---> Nix +# Ignore build outputs from performing a nix-build or `nix build` command +result +result-* + +# Ignore automatically generated direnv output +.direnv + +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Répertoire des secrets gérés par sops-nix +secrets/* \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc38971 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "nixEnvSelector.nixFile": "${workspaceFolder}/default.nix", + "nixEnvSelector.useFlakes": false +} \ No newline at end of file diff --git a/environments/sample/hosts/default.nix b/environments/sample/hosts/default.nix index 9403a59..8e6ee04 100644 --- a/environments/sample/hosts/default.nix +++ b/environments/sample/hosts/default.nix @@ -8,14 +8,14 @@ in { # This file is imported by all host configurations (servers and workstations) # NTP servers for this environment - services.ntp.servers = [ + environment.ntpServers = [ "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; + environment.timeZone = env.time.timeZone; + environment.hardwareClock = env.time.hardwareClock; # TODO: Move other common settings here later # Examples: diff --git a/environments/sample/hosts/servers/default.nix b/environments/sample/hosts/servers/default.nix index 1265455..5d12af1 100644 --- a/environments/sample/hosts/servers/default.nix +++ b/environments/sample/hosts/servers/default.nix @@ -8,7 +8,7 @@ in { # This file is imported by all server configurations # Default DNS servers for this environment - networking.nameServers = [ "10.40.128.10" "10.40.128.11" ]; + environment.dnsServers = [ "10.40.128.10" "10.40.128.11" ]; # SMTP relay configuration services.postfix = { diff --git a/environments/sample/hosts/servers/dns01/configuration.nix b/environments/sample/hosts/servers/dns01/configuration.nix index 351ea9c..49b1f36 100644 --- a/environments/sample/hosts/servers/dns01/configuration.nix +++ b/environments/sample/hosts/servers/dns01/configuration.nix @@ -22,5 +22,4 @@ listenAddresses = [ "10.0.0.10" "127.0.0.1" "::1" ]; }; - system.stateVersion = "25.11"; -} \ No newline at end of file +} diff --git a/environments/sample/hosts/workstations/default.nix b/environments/sample/hosts/workstations/default.nix index 590a179..1bc0fd6 100644 --- a/environments/sample/hosts/workstations/default.nix +++ b/environments/sample/hosts/workstations/default.nix @@ -8,7 +8,7 @@ in { # This file is imported by all workstation configurations # Default DNS servers for this environment - networking.nameServers = [ "10.40.128.10" "10.40.128.11" ]; + environment.dnsServers = [ "10.40.128.10" "10.40.128.11" ]; # SMTP relay configuration services.postfix = { diff --git a/modules/machine-types/common.nix b/modules/machine-types/common.nix new file mode 100644 index 0000000..5d2ede2 --- /dev/null +++ b/modules/machine-types/common.nix @@ -0,0 +1,60 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.environment; +in { + options.environment = { + ntpServers = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "0.pool.ntp.org" "1.pool.ntp.org" ]; + description = "NTP servers for this environment."; + }; + + dnsServers = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "1.1.1.1" "8.8.8.8" ]; + description = "Authoritative DNS servers for this environment."; + }; + + domain = mkOption { + type = types.str; + default = ""; + example = "example.org"; + description = "DNS domain for this environment."; + }; + + timeZone = mkOption { + type = types.str; + default = "UTC"; + example = "Europe/Paris"; + description = "Timezone for this environment."; + }; + + hardwareClock = mkOption { + type = types.str; + default = "UTC"; + example = "UTC"; + description = "Hardware clock setting for this environment."; + }; + }; + + config = { + # System state version — defined once here for all machine types + system.stateVersion = "25.11"; + + # NTP servers + services.ntp.servers = cfg.ntpServers; + + # Time settings + time.timeZone = cfg.timeZone; + time.hardwareClock = cfg.hardwareClock; + + # Domain and DNS servers + networking.domain = cfg.domain; + networking.nameServers = cfg.dnsServers; + }; +} \ No newline at end of file diff --git a/modules/machine-types/hypervisor/default.nix b/modules/machine-types/hypervisor/default.nix index 3e579ec..606f955 100644 --- a/modules/machine-types/hypervisor/default.nix +++ b/modules/machine-types/hypervisor/default.nix @@ -1,4 +1,6 @@ { config, pkgs, lib, ... }: { + imports = [ ./../common ]; + # TODO: Add hypervisor-specific configuration -} \ No newline at end of file +} diff --git a/modules/machine-types/lxc/default.nix b/modules/machine-types/lxc/default.nix index cb6076e..65a015f 100644 --- a/modules/machine-types/lxc/default.nix +++ b/modules/machine-types/lxc/default.nix @@ -1,6 +1,9 @@ { config, modulesPath, pkgs, lib, ... }: { - imports = [ (modulesPath + "/virtualisation/proxmox-lxc.nix") ]; + imports = [ + ./../common + (modulesPath + "/virtualisation/proxmox-lxc.nix") + ]; nix.settings = { sandbox = false; }; proxmoxLXC = { manageNetwork = false; @@ -43,6 +46,4 @@ }; - system.stateVersion = "25.11"; - -} \ No newline at end of file +} diff --git a/modules/machine-types/vm/default.nix b/modules/machine-types/vm/default.nix index d8c8687..5ba3435 100644 --- a/modules/machine-types/vm/default.nix +++ b/modules/machine-types/vm/default.nix @@ -1,4 +1,6 @@ { config, pkgs, lib, ... }: { + imports = [ ./../common ]; + # TODO: Add VM-specific configuration -} \ No newline at end of file +} diff --git a/modules/machine-types/workstation/default.nix b/modules/machine-types/workstation/default.nix index 726ba3f..8e9664a 100644 --- a/modules/machine-types/workstation/default.nix +++ b/modules/machine-types/workstation/default.nix @@ -1,4 +1,6 @@ { config, pkgs, lib, ... }: { + imports = [ ./../common ]; + # TODO: Add workstation-specific configuration -} \ No newline at end of file +}