diff --git a/README.md b/README.md index bc3f737..6f6eb34 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ nixos-config/ ├── hosts/ │ └── laptop/ │ └── configuration.nix # Configuration matérielle spécifique au laptop +│ └── vmgaming/ +│ └── configuration.nix # Configuration matérielle VM Proxmox (VMGaming) └── modules/ ├── laptop/ # Modules spécifiques au laptop │ ├── default.nix # Secrets management (sops-nix) et config de base @@ -112,11 +114,27 @@ cd ~/src/nixos-config nixos-rebuild build --flake .#laptop ``` +### Build et test de la VM gaming (Proxmox) +```bash +cd ~/src/nixos-config +nixos-rebuild build --flake .#VMGaming +``` + ### Activer la configuration ```bash sudo nixos-rebuild switch --flake .#laptop ``` +### Activer la configuration VM gaming +```bash +sudo nixos-rebuild switch --flake .#VMGaming +``` + +### GPU passthrough pour VMGaming +- La configuration `VMGaming` est optimisée pour une VM Proxmox avec GPU passthrough. +- Le profil actuel active les drivers **NVIDIA** dans `configuration-vmgaming.nix`. +- Si tu passes une carte AMD, remplace `services.xserver.videoDrivers = [ "nvidia" ];` par `services.xserver.videoDrivers = [ "amdgpu" ];` et retire le bloc `hardware.nvidia`. + ### Mettre à jour les inputs ```bash nix flake update diff --git a/configuration-vmgaming.nix b/configuration-vmgaming.nix new file mode 100644 index 0000000..1c6fd3c --- /dev/null +++ b/configuration-vmgaming.nix @@ -0,0 +1,71 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./hosts/vmgaming/configuration.nix + + ./modules/nixos/base.nix + ./modules/nixos/desktop-i3.nix + ./modules/nixos/parsec.nix + + ./modules/laptop/users.nix + ./modules/laptop/gaming.nix + ]; + + networking.hostName = "VMGaming"; + networking.useDHCP = lib.mkDefault true; + + # Proxmox VM: boot in UEFI mode without touching host EFI variables. + boot.loader.grub = { + enable = true; + efiSupport = true; + efiInstallAsRemovable = true; + device = "nodev"; + }; + boot.loader.efi.canTouchEfiVariables = false; + + services.spice-vdagentd.enable = true; + services.qemuGuest.enable = true; + + # Gaming VM guest optimizations + programs.gamemode.enable = true; + programs.gamescope.enable = true; + security.rtkit.enable = true; + + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + services.pulseaudio.enable = false; + + hardware.graphics = { + enable = true; + enable32Bit = true; + }; + + # NVIDIA passthrough guest defaults. + # If you pass through an AMD GPU instead, replace with: + # services.xserver.videoDrivers = [ "amdgpu" ]; + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; + + environment.systemPackages = with pkgs; [ + mangohud + goverlay + vkbasalt + gamemode + ]; + + custom.gaming.enable = true; + custom.gaming.enableXpadneo = false; +} diff --git a/flake.nix b/flake.nix index da59d7d..ca175d7 100644 --- a/flake.nix +++ b/flake.nix @@ -52,5 +52,17 @@ claude-desktop = claude-desktop; }; }; + + nixosConfigurations.VMGaming = nixpkgs.lib.nixosSystem { + modules = [ + ./configuration-vmgaming.nix + ]; + + specialArgs = { + inherit customConfig; + parsec-cloud-nix = parsec-cloud-nix; + claude-desktop = claude-desktop; + }; + }; }; } diff --git a/hosts/vmgaming/configuration.nix b/hosts/vmgaming/configuration.nix new file mode 100644 index 0000000..1fbd95d --- /dev/null +++ b/hosts/vmgaming/configuration.nix @@ -0,0 +1,33 @@ +# Do not modify this file directly on every rebuild. It should contain host +# specific hardware/VM configuration for VMGaming (Proxmox guest). +{ lib, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # Update these labels to match your VM disks if they differ. + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/boot"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = [ ]; + + networking.useDHCP = lib.mkDefault true; + services.qemuGuest.enable = true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}