main
  1{
  2  globals,
  3  inputs,
  4  lib,
  5  pkgs,
  6  ...
  7}:
  8{
  9  imports = [
 10    inputs.disko.nixosModules.disko
 11    (import ./disks.nix { inherit lib; })
 12
 13    # nixos-hardware module for GA402X (AMD GPU)
 14    inputs.nixos-hardware.nixosModules.asus-zephyrus-ga402x-amdgpu
 15
 16    # ASUS battery module (for charge limiting)
 17    inputs.nixos-hardware.nixosModules.asus-battery
 18
 19    # Common modules
 20    ../common/hardware/laptop.nix
 21    ../common/hardware/acpid.nix
 22    ../common/hardware/bluetooth.nix
 23    ../common/services/nfs-mounts.nix
 24  ];
 25
 26  # Hybrid swap strategy for LLM workloads:
 27  # - zram: Fast compressed RAM-based swap (primary tier)
 28  # - disk: Safety net for extreme memory pressure (secondary tier)
 29  # Total effective memory: 32GB RAM + ~48GB zram (compressed) + 16GB disk
 30
 31  # zram swap (compressed, RAM-based)
 32  zramSwap = {
 33    enable = true;
 34    algorithm = "zstd";
 35    memoryPercent = 50; # 16GB of 32GB RAM for zram
 36    priority = 10; # Higher priority than disk swap
 37  };
 38
 39  # Disk swapfile (fallback tier)
 40  swapDevices = [
 41    {
 42      device = "/swapfile";
 43      size = 16 * 1024; # 16GB (increased from 8GB)
 44      priority = 5; # Lower priority than zram
 45    }
 46  ];
 47
 48  hardware = {
 49    enableAllFirmware = true;
 50
 51    # AMD GPU configuration (works for both iGPU and dGPU)
 52    # RADV (Mesa Vulkan) is enabled by default
 53    graphics = {
 54      enable = true;
 55      extraPackages = with pkgs; [
 56        rocmPackages.clr.icd # OpenCL/ROCm support
 57      ];
 58    };
 59
 60    # Battery charge limit (even on AC, good for battery longevity)
 61    asus.battery.chargeUpto = 80;
 62  };
 63
 64  services = {
 65    # ASUS services
 66    asusd = {
 67      enable = true;
 68    };
 69
 70    # supergfxd: GPU switching service
 71    # Will be set to "dedicated" mode for dGPU-only operation
 72    supergfxd.enable = true;
 73
 74    # Power management
 75    power-profiles-daemon.enable = true;
 76
 77    # Firmware updates
 78    fwupd.enable = true;
 79
 80    # Disk monitoring
 81    smartd = {
 82      enable = true;
 83      devices = [ { device = "/dev/nvme0n1"; } ];
 84    };
 85  };
 86
 87  # NFS mounts from globals defaults (rhea + aion)
 88  services.nfs-mounts.hosts = globals.net.nfs.defaultHosts;
 89
 90  # NFS mounts from synodine (NFSv3)
 91  fileSystems."/net/synodine/usbshare" = {
 92    device = "synodine.home:/volumeUSB2/usbshare";
 93    fsType = "nfs";
 94    options = [
 95      "nfsvers=3"
 96      "x-systemd.automount"
 97      "noauto"
 98      "x-systemd.idle-timeout=600"
 99      "soft"
100      "_netdev"
101    ];
102  };
103
104  fileSystems."/net/synodine/downloads" = {
105    device = "synodine.home:/volume1/downloads";
106    fsType = "nfs";
107    options = [
108      "nfsvers=3"
109      "x-systemd.automount"
110      "noauto"
111      "x-systemd.idle-timeout=600"
112      "soft"
113      "_netdev"
114    ];
115  };
116
117  fileSystems."/net/synodine/video" = {
118    device = "synodine.home:/volume1/video";
119    fsType = "nfs";
120    options = [
121      "nfsvers=3"
122      "x-systemd.automount"
123      "noauto"
124      "x-systemd.idle-timeout=600"
125      "soft"
126      "_netdev"
127    ];
128  };
129}