From 6992836cfe29f94d9b862de3e37572ccc9e1d307 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Sat, 4 Oct 2025 14:59:18 +0200 Subject: [PATCH] Refactoring config preparing for server --- flake.nix | 17 +++-- hosts/{lyes-pc => piaf}/default.nix | 11 ++- hosts/{lyes-pc => piaf}/disko-config.nix | 0 .../hardware-configuration.nix | 0 hosts/{lyes-pc => piaf}/hardware.nix | 0 hosts/{desktop-iso => triforce}/default.nix | 0 hosts/zora/default.nix | 32 +++++++++ hosts/zora/disko-config.nix | 71 +++++++++++++++++++ hosts/zora/hardware-configuration.nix | 25 +++++++ hosts/zora/hardware.nix | 19 +++++ modules/{ => desktop}/gaming/default.nix | 0 modules/{ => desktop}/gnome/default.nix | 0 modules/{ => desktop}/gnome/packages.nix | 0 .../{ => desktop}/specialisations/gaming.nix | 0 .../specialisations/kde-gaming.nix | 0 modules/{ => desktop}/specialisations/kde.nix | 0 .../specialisations/old-kernel.nix | 0 modules/{ => desktop}/sway/default.nix | 0 18 files changed, 165 insertions(+), 10 deletions(-) rename hosts/{lyes-pc => piaf}/default.nix (79%) rename hosts/{lyes-pc => piaf}/disko-config.nix (100%) rename hosts/{lyes-pc => piaf}/hardware-configuration.nix (100%) rename hosts/{lyes-pc => piaf}/hardware.nix (100%) rename hosts/{desktop-iso => triforce}/default.nix (100%) create mode 100644 hosts/zora/default.nix create mode 100644 hosts/zora/disko-config.nix create mode 100644 hosts/zora/hardware-configuration.nix create mode 100644 hosts/zora/hardware.nix rename modules/{ => desktop}/gaming/default.nix (100%) rename modules/{ => desktop}/gnome/default.nix (100%) rename modules/{ => desktop}/gnome/packages.nix (100%) rename modules/{ => desktop}/specialisations/gaming.nix (100%) rename modules/{ => desktop}/specialisations/kde-gaming.nix (100%) rename modules/{ => desktop}/specialisations/kde.nix (100%) rename modules/{ => desktop}/specialisations/old-kernel.nix (100%) rename modules/{ => desktop}/sway/default.nix (100%) diff --git a/flake.nix b/flake.nix index 49ca655..02a2c9a 100644 --- a/flake.nix +++ b/flake.nix @@ -29,16 +29,25 @@ outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations = { - lyes-pc = nixpkgs.lib.nixosSystem { + # Framework Computer + piaf = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = inputs; - modules = [ ./hosts/lyes-pc ]; + modules = [ ./hosts/piaf ]; }; - desktop-iso = nixpkgs.lib.nixosSystem { + # Crans Server + zora = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = inputs; - modules = [ ./hosts/desktop-iso ]; + modules = [ ./hosts/zora ]; + }; + + # Desktop ISO + triforce = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = inputs; + modules = [ ./hosts/triforce ]; }; }; diff --git a/hosts/lyes-pc/default.nix b/hosts/piaf/default.nix similarity index 79% rename from hosts/lyes-pc/default.nix rename to hosts/piaf/default.nix index 290dea2..94573a5 100644 --- a/hosts/lyes-pc/default.nix +++ b/hosts/piaf/default.nix @@ -1,4 +1,4 @@ -{ config, nix-flatpak, nixos-hardware, disko, agenix, ... }: +{ nix-flatpak, nixos-hardware, disko, agenix, ... }: { imports = @@ -13,9 +13,9 @@ ../../modules ../../modules/desktop - ../../modules/gaming - ../../modules/gnome - ../../modules/sway + ../../modules/desktop/gaming + ../../modules/desktop/gnome + ../../modules/desktop/sway nix-flatpak.nixosModules.nix-flatpak nixos-hardware.nixosModules.framework-16-7040-amd @@ -25,7 +25,7 @@ # Networking networking = { - hostName = "lyes-pc"; + hostName = "piaf"; hostId = "ed183b8f"; }; @@ -36,5 +36,4 @@ # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "22.11"; # Did you read the comment? - # home-manager.users.lyes.home.stateVersion = config.system.stateVersion; } diff --git a/hosts/lyes-pc/disko-config.nix b/hosts/piaf/disko-config.nix similarity index 100% rename from hosts/lyes-pc/disko-config.nix rename to hosts/piaf/disko-config.nix diff --git a/hosts/lyes-pc/hardware-configuration.nix b/hosts/piaf/hardware-configuration.nix similarity index 100% rename from hosts/lyes-pc/hardware-configuration.nix rename to hosts/piaf/hardware-configuration.nix diff --git a/hosts/lyes-pc/hardware.nix b/hosts/piaf/hardware.nix similarity index 100% rename from hosts/lyes-pc/hardware.nix rename to hosts/piaf/hardware.nix diff --git a/hosts/desktop-iso/default.nix b/hosts/triforce/default.nix similarity index 100% rename from hosts/desktop-iso/default.nix rename to hosts/triforce/default.nix diff --git a/hosts/zora/default.nix b/hosts/zora/default.nix new file mode 100644 index 0000000..565f909 --- /dev/null +++ b/hosts/zora/default.nix @@ -0,0 +1,32 @@ +{ disko, agenix, ... }: + +{ + imports = + [ + # Hosts + ./hardware-configuration.nix + ./hardware.nix + ./disko-config.nix + + ../../users/lyes + + ../../modules + + disko.nixosModules.disko + agenix.nixosModules.default + ]; + + # Networking + networking = { + hostName = "lyes-pc"; + # hostId = "ed183b8f"; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "25.05"; # Did you read the comment? +} diff --git a/hosts/zora/disko-config.nix b/hosts/zora/disko-config.nix new file mode 100644 index 0000000..bf50979 --- /dev/null +++ b/hosts/zora/disko-config.nix @@ -0,0 +1,71 @@ +{ disks ? [ "/dev/nvme0n1" ], ... }: { + disko.devices = { + disk = { + main = { + type = "disk"; + device = builtins.elemAt disks 0; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "nofail" ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + rootFsOptions = { + mountpoint = "none"; + compression = "zstd"; + acltype = "posixacl"; + xattr = "sa"; + "com.sun:auto-snapshot" = "false"; + }; + options.ashift = "12"; + datasets = { + "root" = { + type = "zfs_fs"; + options = { + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + keylocation = "prompt"; + }; + mountpoint = "/"; + + }; + "root/home" = { + type = "zfs_fs"; + options."com.sun:auto-snapshot" = "true"; + mountpoint = "/home"; + }; + "root/var" = { + type = "zfs_fs"; + mountpoint = "/var"; + }; + "root/nix" = { + type = "zfs_fs"; + options.mountpoint = "/nix"; + mountpoint = "/nix"; + }; + }; + }; + }; + }; +} diff --git a/hosts/zora/hardware-configuration.nix b/hosts/zora/hardware-configuration.nix new file mode 100644 index 0000000..706a299 --- /dev/null +++ b/hosts/zora/hardware-configuration.nix @@ -0,0 +1,25 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/zora/hardware.nix b/hosts/zora/hardware.nix new file mode 100644 index 0000000..cff96b4 --- /dev/null +++ b/hosts/zora/hardware.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: + +{ + # Kernel + boot.kernelPackages = pkgs.linuxPackages_6_16; + + # Boot + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 10; + # boot.loader.efi.canTouchEfiVariables = true; + # boot.kernelParams = [ "quiet" ]; + boot.initrd.systemd = { + enable = true; + # network.enable = true; + }; + + # Swap + zramSwap.enable = true; +} diff --git a/modules/gaming/default.nix b/modules/desktop/gaming/default.nix similarity index 100% rename from modules/gaming/default.nix rename to modules/desktop/gaming/default.nix diff --git a/modules/gnome/default.nix b/modules/desktop/gnome/default.nix similarity index 100% rename from modules/gnome/default.nix rename to modules/desktop/gnome/default.nix diff --git a/modules/gnome/packages.nix b/modules/desktop/gnome/packages.nix similarity index 100% rename from modules/gnome/packages.nix rename to modules/desktop/gnome/packages.nix diff --git a/modules/specialisations/gaming.nix b/modules/desktop/specialisations/gaming.nix similarity index 100% rename from modules/specialisations/gaming.nix rename to modules/desktop/specialisations/gaming.nix diff --git a/modules/specialisations/kde-gaming.nix b/modules/desktop/specialisations/kde-gaming.nix similarity index 100% rename from modules/specialisations/kde-gaming.nix rename to modules/desktop/specialisations/kde-gaming.nix diff --git a/modules/specialisations/kde.nix b/modules/desktop/specialisations/kde.nix similarity index 100% rename from modules/specialisations/kde.nix rename to modules/desktop/specialisations/kde.nix diff --git a/modules/specialisations/old-kernel.nix b/modules/desktop/specialisations/old-kernel.nix similarity index 100% rename from modules/specialisations/old-kernel.nix rename to modules/desktop/specialisations/old-kernel.nix diff --git a/modules/sway/default.nix b/modules/desktop/sway/default.nix similarity index 100% rename from modules/sway/default.nix rename to modules/desktop/sway/default.nix