From 6a42052663df9aaa5cc480fcdfe319d1b659ac75 Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 9 Sep 2026 18:33:46 +0200 Subject: [PATCH] Simplification : fusion base.nix+desktop.nix+accounts.nix -> hosts/common/default.nix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aucun changement fonctionnel, juste moins de fichiers à gérer côté admin (structure inspirée de modules/anssi/ : un rôle clair par fichier, mais un seul profil ici donc un seul fichier commun suffit). hosts/usagers/configuration.nix importe désormais juste `../common` (default.nix résolu automatiquement) + le layout disko. Co-Authored-By: Claude Sonnet 5 --- README.md | 2 +- hosts/common/accounts.nix | 23 --- hosts/common/base.nix | 125 -------------- hosts/common/default.nix | 294 ++++++++++++++++++++++++++++++++ hosts/common/desktop.nix | 161 ----------------- hosts/usagers/configuration.nix | 6 +- 6 files changed, 297 insertions(+), 314 deletions(-) delete mode 100644 hosts/common/accounts.nix delete mode 100644 hosts/common/base.nix create mode 100644 hosts/common/default.nix delete mode 100644 hosts/common/desktop.nix diff --git a/README.md b/README.md index 574924a..7e9646e 100644 --- a/README.md +++ b/README.md @@ -387,7 +387,7 @@ Pour un PC sans câble réseau (après l'installation, ou en dépannage). ### Option 1 — NetworkManager -Déjà actif par défaut dans ce repo (`hosts/common/base.nix`). Rien à ajouter dans `configuration.nix`. +Déjà actif par défaut dans ce repo (`hosts/common/default.nix`). Rien à ajouter dans `configuration.nix`. ```nix networking.networkmanager.enable = true; diff --git a/hosts/common/accounts.nix b/hosts/common/accounts.nix deleted file mode 100644 index 1a74c2d..0000000 --- a/hosts/common/accounts.nix +++ /dev/null @@ -1,23 +0,0 @@ -# Compte admin des machines de la flotte : root, mot de passe "nixos" -# STABLE (pas d'expiration forcée ici, contrairement à nixos_users) — -# ces machines sont génériques/partagées, un mot de passe connu et -# constant sur tout le parc est voulu pour l'administration courante. -{ pkgs, ... }: - -{ - users.mutableUsers = true; - - users.users.root = { - initialPassword = "nixos"; - }; - - # Login root direct autorisé nativement dès qu'un mot de passe est - # défini (console/tty). SSH reste sur le défaut NixOS (clé uniquement) : - # le mot de passe "nixos" n'ouvre pas la porte à distance, seulement en - # local sur la machine. - - # `initialPassword` n'est appliqué par NixOS qu'à la création du compte, - # donc un rebuild/auto-upgrade ultérieur ne le réécrit jamais — mais ici - # on ne force pas non plus de changement : "nixos" doit rester valide - # indéfiniment sur la flotte. -} diff --git a/hosts/common/base.nix b/hosts/common/base.nix deleted file mode 100644 index 404ac1d..0000000 --- a/hosts/common/base.nix +++ /dev/null @@ -1,125 +0,0 @@ -# Socle commun à toutes les machines de la flotte (repo public). -{ pkgs, lib, ... }: - -{ - imports = [ ../../modules/anssi ]; - - # Nom uniforme, pas d'identification individuelle pour l'instant (voir - # README). À revoir via le numéro de série DMI si le besoin apparaît. - networking.hostName = "Nixos_Fleet"; - networking.networkmanager.enable = true; - - # Couverture matérielle maximale (wifi/Bluetooth/PCI) sur un parc - # hétérogène inconnu à l'avance. Inclut enableRedistributableFirmware. - hardware.enableAllFirmware = lib.mkDefault true; - - # Durcissement ANSSI (modules/anssi/, vendored depuis SécurixOS). - # level "intermediary" : couvre déjà tout ce qui était réglé à la main - # sur le profil oreo (R9/R11/R12/R14). category "client" : postes de - # travail, pas des serveurs. - # - # R12 force net.ipv4.ip_forward = 0 : sans impact sur des postes - # clients. Ne pas importer ce module sur pxe-server/configuration.nix - # (a besoin du forwarding inverse). - security.anssi = { - enable = true; - level = "intermediary"; - category = "client"; - - # R8 (mitigations CPU) coupe l'hyperthreading via "mds=full,nosmt" : - # trop coûteux sur le matériel bas de gamme du parc. Désactivé via - # exception plutôt que contourné en silence ; réappliqué ci-dessous - # sans le "nosmt". - exceptions.R8.rationale = "SMT conservé : impact perf trop lourd sur le parc (matériel bas de gamme, parfois 4 Go de RAM). Mitigations réappliquées ci-dessous sans 'nosmt'."; - }; - - # R8 (modules/anssi/kernel-options.nix), sauf mds=full,nosmt -> mds=full. - boot.kernelParams = [ - "l1tf=full,force" - "page_poison=on" - "pti=on" - "slab_nomerge=yes" - "slub_debug=FZP" - "spec_store_bypass_disable=seccomp" - "spectre_v2=on" - "mds=full" # sans ",nosmt" : hyperthreading conservé - "mce=0" - "page_alloc.shuffle=1" - "rng_core.default_quality=500" - ]; - - # Pas couvert par le module ANSSI (R45 en exception : AppArmor - # partiellement supporté sur NixOS). - systemd.coredump.enable = false; - security.apparmor.packages = [ pkgs.apparmor-profiles ]; - security.apparmor.enableCache = true; - - # Bluetooth (même config que le profil oreo) : pas d'allumage auto au - # boot, blueman pour la gestion depuis Cinnamon. - hardware.bluetooth = { - enable = true; - powerOnBoot = false; - }; - services.blueman.enable = true; - - time.timeZone = "Europe/Paris"; - i18n.defaultLocale = "fr_FR.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "fr_FR.UTF-8"; - LC_IDENTIFICATION = "fr_FR.UTF-8"; - LC_MEASUREMENT = "fr_FR.UTF-8"; - LC_MONETARY = "fr_FR.UTF-8"; - LC_NAME = "fr_FR.UTF-8"; - LC_NUMERIC = "fr_FR.UTF-8"; - LC_PAPER = "fr_FR.UTF-8"; - LC_TELEPHONE = "fr_FR.UTF-8"; - LC_TIME = "fr_FR.UTF-8"; - }; - services.xserver.xkb = { - layout = "fr"; - variant = ""; - }; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.systemd-boot.configurationLimit = 10; - - services.openssh.enable = true; - networking.firewall.enable = true; - - # Swap compressé en RAM : couvre le bas du parc (4 Go, desktop complet). - zramSwap = { - enable = true; - memoryPercent = 50; - }; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - nixpkgs.config.allowUnfree = true; - - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - # Convergence automatique depuis le repo public, sans netrc. Cadence - # weekly (même format que oreo, plutôt que daily). - system.autoUpgrade = { - enable = true; - dates = "weekly"; - flake = "git+https://gitea.miniclic.net/Damien/Nixos_Fleet.git#usagers"; - }; - - environment.systemPackages = with pkgs; [ - git - curl - wget - htop - nixfmt - ]; - - system.stateVersion = "26.05"; -} diff --git a/hosts/common/default.nix b/hosts/common/default.nix new file mode 100644 index 0000000..21fae03 --- /dev/null +++ b/hosts/common/default.nix @@ -0,0 +1,294 @@ +# Socle commun à toutes les machines de la flotte (repo public) : compte +# système, réseau/durcissement, bureau Cinnamon/Firefox. Un seul fichier +# plutôt que plusieurs petits (base/desktop/accounts) -- chaque option +# n'a qu'un seul endroit où la chercher. +{ pkgs, lib, ... }: + +{ + imports = [ ../../modules/anssi ]; + + # Nom uniforme, pas d'identification individuelle pour l'instant (voir + # README). À revoir via le numéro de série DMI si le besoin apparaît. + networking.hostName = "Nixos_Fleet"; + networking.networkmanager.enable = true; + + # Couverture matérielle maximale (wifi/Bluetooth/PCI) sur un parc + # hétérogène inconnu à l'avance. Inclut enableRedistributableFirmware. + hardware.enableAllFirmware = lib.mkDefault true; + + # Durcissement ANSSI (modules/anssi/, vendored depuis SécurixOS). + # level "intermediary" : couvre déjà tout ce qui était réglé à la main + # sur le profil oreo (R9/R11/R12/R14). category "client" : postes de + # travail, pas des serveurs. + # + # R12 force net.ipv4.ip_forward = 0 : sans impact sur des postes + # clients. Ne pas importer ce module sur pxe-server/configuration.nix + # (a besoin du forwarding inverse). + security.anssi = { + enable = true; + level = "intermediary"; + category = "client"; + + # R8 (mitigations CPU) coupe l'hyperthreading via "mds=full,nosmt" : + # trop coûteux sur le matériel bas de gamme du parc. Désactivé via + # exception plutôt que contourné en silence ; réappliqué ci-dessous + # sans le "nosmt". + exceptions.R8.rationale = "SMT conservé : impact perf trop lourd sur le parc (matériel bas de gamme, parfois 4 Go de RAM). Mitigations réappliquées ci-dessous sans 'nosmt'."; + }; + + # R8 (modules/anssi/kernel-options.nix), sauf mds=full,nosmt -> mds=full. + boot.kernelParams = [ + "l1tf=full,force" + "page_poison=on" + "pti=on" + "slab_nomerge=yes" + "slub_debug=FZP" + "spec_store_bypass_disable=seccomp" + "spectre_v2=on" + "mds=full" # sans ",nosmt" : hyperthreading conservé + "mce=0" + "page_alloc.shuffle=1" + "rng_core.default_quality=500" + ]; + + # Pas couvert par le module ANSSI (R45 en exception : AppArmor + # partiellement supporté sur NixOS). + systemd.coredump.enable = false; + security.apparmor.packages = [ pkgs.apparmor-profiles ]; + security.apparmor.enableCache = true; + + # Bluetooth (même config que le profil oreo) : pas d'allumage auto au + # boot, blueman pour la gestion depuis Cinnamon. + hardware.bluetooth = { + enable = true; + powerOnBoot = false; + }; + services.blueman.enable = true; + + time.timeZone = "Europe/Paris"; + i18n.defaultLocale = "fr_FR.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "fr_FR.UTF-8"; + LC_IDENTIFICATION = "fr_FR.UTF-8"; + LC_MEASUREMENT = "fr_FR.UTF-8"; + LC_MONETARY = "fr_FR.UTF-8"; + LC_NAME = "fr_FR.UTF-8"; + LC_NUMERIC = "fr_FR.UTF-8"; + LC_PAPER = "fr_FR.UTF-8"; + LC_TELEPHONE = "fr_FR.UTF-8"; + LC_TIME = "fr_FR.UTF-8"; + }; + services.xserver.xkb = { + layout = "fr"; + variant = ""; + }; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.systemd-boot.configurationLimit = 10; + + services.openssh.enable = true; + networking.firewall.enable = true; + + # Swap compressé en RAM : couvre le bas du parc (4 Go, desktop complet). + zramSwap = { + enable = true; + memoryPercent = 50; + }; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + nixpkgs.config.allowUnfree = true; + + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + + # Convergence automatique depuis le repo public, sans netrc. Cadence + # weekly (même format que oreo, plutôt que daily). + system.autoUpgrade = { + enable = true; + dates = "weekly"; + flake = "git+https://gitea.miniclic.net/Damien/Nixos_Fleet.git#usagers"; + }; + + # Compte admin de la flotte : root, mot de passe "nixos" STABLE (pas + # d'expiration forcée) -- machines génériques/partagées, un mot de + # passe connu et constant sur tout le parc est voulu pour + # l'administration courante. `initialPassword` n'est appliqué qu'à la + # création du compte : un rebuild/auto-upgrade ultérieur ne le réécrit + # jamais, mais on ne force pas non plus de changement -- "nixos" doit + # rester valide indéfiniment sur la flotte. Login root direct autorisé + # en local (console/tty) ; SSH reste sur le défaut NixOS (clé + # uniquement), ce mot de passe n'ouvre pas la porte à distance. + users.mutableUsers = true; + users.users.root.initialPassword = "nixos"; + + # --- Bureau Cinnamon + Firefox -------------------------------------- + services.xserver.enable = true; + services.xserver.displayManager.lightdm.enable = true; + services.xserver.displayManager.lightdm.background = "/etc/nixos/hosts/common/wallpaper/Nix/13977413.png"; + services.xserver.desktopManager.cinnamon.enable = true; + services.accounts-daemon.enable = true; + + environment.cinnamon.excludePackages = with pkgs; [ + celluloid + warpinator + ]; + + # Fond d'écran par défaut (logo NixOS, pas la galerie perso de + # nixos_cinnamon). Suppose la config installée sur /etc/nixos (voir + # installer/install.sh). + environment.etc."dconf/db/local.d/00-background".text = '' + [org/cinnamon/desktop/background] + picture-uri='file:///etc/nixos/hosts/common/wallpaper/Nix/13977413.png' + ''; + system.activationScripts.dconfUpdate.text = "${pkgs.dconf}/bin/dconf update"; + + # Confidentialité générique (pas de SearXNG/DNS perso : repo public). + programs.firefox = { + enable = true; + languagePacks = [ "fr" ]; + + preferences = { + "privacy.resistFingerprinting" = true; + "browser.newtabpage.activity-stream.showSponsored" = false; + "browser.search.suggest.enabled" = false; + "dom.security.https_only_mode" = true; + "media.peerconnection.enabled" = false; + "geo.enabled" = false; + "network.captive-portal-service.enabled" = false; + # Do Not Track : plus d'UI depuis les versions récentes de Firefox, + # mais le pref existe encore et envoie bien l'en-tête DNT=1. + "privacy.donottrackheader.enabled" = true; + }; + + policies = { + DisableTelemetry = true; + DisablePocket = true; + DisableFirefoxStudies = true; + OfferToSaveLogins = false; + DontCheckDefaultBrowser = true; + EnableTrackingProtection = { + Value = true; + Locked = true; + }; + + # DuckDuckGo est un moteur intégré à Firefox, pas besoin de l'Add. + SearchEngines.Default = "DuckDuckGo"; + + # Pubs/contenu sponsorisé sur le nouvel onglet et la barre d'adresse. + FirefoxHome = { + SponsoredTopSites = false; + SponsoredPocket = false; + Locked = true; + }; + FirefoxSuggest.SponsoredSuggestions = false; + + ExtensionSettings = { + "uBlock0@raymondhill.net" = { + install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"; + installation_mode = "force_installed"; + }; + "jid1-MnnxcxisBPnSXQ@jetpack" = { + install_url = "https://addons.mozilla.org/firefox/downloads/latest/privacy-badger17/latest.xpi"; + installation_mode = "force_installed"; + }; + }; + }; + }; + + environment.systemPackages = with pkgs; [ + git + curl + wget + htop + nixfmt + + # === Office/Notes === + libreoffice + pdfarranger + simple-scan + + # === System tools === + btop + unzip + screenfetch + tmux + fwupd + fwupd-efi + ncdu + gdu + hplip + gutenprint + cups + inxi + ntfs3g + + # === Communication/Media === + thunderbird + ffmpeg + vlc + mpv + strawberry + ]; + + # Flatpak + services.flatpak.enable = true; + xdg.portal.enable = true; + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + + systemd.services.flatpak-repo = { + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + path = [ pkgs.flatpak ]; + script = '' + flatpak remote-add --if-not-exists flathub \ + https://dl.flathub.org/repo/flathub.flatpakrepo + ''; + }; + + systemd.services.flatpak-install = { + wantedBy = [ "multi-user.target" ]; + after = [ + "flatpak-repo.service" + "network-online.target" + ]; + wants = [ "network-online.target" ]; + requires = [ "flatpak-repo.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + path = [ pkgs.flatpak ]; + script = '' + flatpak install -y flathub \ + net.waterfox.waterfox \ + eu.betterbird.Betterbird + ''; + }; + + systemd.services.flatpak-update = { + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.flatpak ]; + script = '' + flatpak update -y + ''; + }; + + programs.appimage = { + enable = true; + binfmt = true; + }; + + system.stateVersion = "26.05"; +} diff --git a/hosts/common/desktop.nix b/hosts/common/desktop.nix deleted file mode 100644 index 955bb79..0000000 --- a/hosts/common/desktop.nix +++ /dev/null @@ -1,161 +0,0 @@ -# Bureau Cinnamon générique pour la flotte. Adapté (pas importé) depuis -# nixos_cinnamon/hosts/cinnamon/desktop-cinnamon.nix : les deux repos -# restent indépendants au `git pull`. -{ pkgs, ... }: - -{ - services.xserver.enable = true; - services.xserver.displayManager.lightdm.enable = true; - services.xserver.displayManager.lightdm.background = "/etc/nixos/hosts/common/wallpaper/Nix/13977413.png"; - services.xserver.desktopManager.cinnamon.enable = true; - services.accounts-daemon.enable = true; - - environment.cinnamon.excludePackages = with pkgs; [ - celluloid - warpinator - ]; - - # Fond d'écran par défaut (logo NixOS, pas la galerie perso de - # nixos_cinnamon). Suppose la config installée sur /etc/nixos (voir - # installer/install.sh). - environment.etc."dconf/db/local.d/00-background".text = '' - [org/cinnamon/desktop/background] - picture-uri='file:///etc/nixos/hosts/common/wallpaper/Nix/13977413.png' - ''; - system.activationScripts.dconfUpdate.text = "${pkgs.dconf}/bin/dconf update"; - - # Confidentialité générique (pas de SearXNG/DNS perso : repo public). - programs.firefox = { - enable = true; - languagePacks = [ "fr" ]; - - preferences = { - "privacy.resistFingerprinting" = true; - "browser.newtabpage.activity-stream.showSponsored" = false; - "browser.search.suggest.enabled" = false; - "dom.security.https_only_mode" = true; - "media.peerconnection.enabled" = false; - "geo.enabled" = false; - "network.captive-portal-service.enabled" = false; - # Do Not Track : plus d'UI depuis les versions récentes de Firefox, - # mais le pref existe encore et envoie bien l'en-tête DNT=1. - "privacy.donottrackheader.enabled" = true; - }; - - policies = { - DisableTelemetry = true; - DisablePocket = true; - DisableFirefoxStudies = true; - OfferToSaveLogins = false; - DontCheckDefaultBrowser = true; - EnableTrackingProtection = { - Value = true; - Locked = true; - }; - - # DuckDuckGo est un moteur intégré à Firefox, pas besoin de l'Add. - SearchEngines.Default = "DuckDuckGo"; - - # Pubs/contenu sponsorisé sur le nouvel onglet et la barre d'adresse. - FirefoxHome = { - SponsoredTopSites = false; - SponsoredPocket = false; - Locked = true; - }; - FirefoxSuggest.SponsoredSuggestions = false; - - ExtensionSettings = { - "uBlock0@raymondhill.net" = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"; - installation_mode = "force_installed"; - }; - "jid1-MnnxcxisBPnSXQ@jetpack" = { - install_url = "https://addons.mozilla.org/firefox/downloads/latest/privacy-badger17/latest.xpi"; - installation_mode = "force_installed"; - }; - }; - }; - }; - - environment.systemPackages = with pkgs; [ - # === Office/Notes === - libreoffice - pdfarranger - simple-scan - - # === System tools === - btop - unzip - screenfetch - tmux - fwupd - fwupd-efi - ncdu - gdu - hplip - gutenprint - cups - inxi - ntfs3g - - # === Communication/Media === - thunderbird - ffmpeg - vlc - mpv - strawberry - ]; - - # Flatpak - services.flatpak.enable = true; - xdg.portal.enable = true; - xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - - systemd.services.flatpak-repo = { - wantedBy = [ "multi-user.target" ]; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - path = [ pkgs.flatpak ]; - script = '' - flatpak remote-add --if-not-exists flathub \ - https://dl.flathub.org/repo/flathub.flatpakrepo - ''; - }; - - systemd.services.flatpak-install = { - wantedBy = [ "multi-user.target" ]; - after = [ - "flatpak-repo.service" - "network-online.target" - ]; - wants = [ "network-online.target" ]; - requires = [ "flatpak-repo.service" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - path = [ pkgs.flatpak ]; - script = '' - flatpak install -y flathub \ - net.waterfox.waterfox \ - eu.betterbird.Betterbird - ''; - }; - - systemd.services.flatpak-update = { - wantedBy = [ "multi-user.target" ]; - path = [ pkgs.flatpak ]; - script = '' - flatpak update -y - ''; - }; - - programs.appimage = { - enable = true; - binfmt = true; - }; -} diff --git a/hosts/usagers/configuration.nix b/hosts/usagers/configuration.nix index 916cebf..e7fe528 100644 --- a/hosts/usagers/configuration.nix +++ b/hosts/usagers/configuration.nix @@ -3,14 +3,12 @@ { imports = [ - ../common/base.nix - ../common/accounts.nix - ../common/desktop.nix + ../common ../../diskos/plain.nix ]; # Compte de session non-nominatif, mot de passe "nixos" stable, sans - # expiration forcée (voir hosts/common/accounts.nix). + # expiration forcée (voir hosts/common). users.users.usagers = { isNormalUser = true; description = "Usagers";