Commit b395aea

HPCesia <me@hpcesia.com>
2025-09-30 17:32:27
refactor: migrate kevin's host config
1 parent 6074e74
hosts/chaser-kevin/boot.nix
@@ -1,26 +0,0 @@
-{
-  pkgs,
-  distro-grub-themes,
-  ...
-}: {
-  boot.loader = {
-    grub = rec {
-      enable = true;
-      devices = ["nodev"];
-      efiSupport = true;
-      gfxmodeEfi = "1024x768";
-      useOSProber = true;
-      theme = distro-grub-themes.packages.${pkgs.system}.lenovo-grub-theme;
-      splashImage = "${theme}/splash_image.jpg";
-    };
-    efi = {
-      canTouchEfiVariables = true;
-      efiSysMountPoint = "/boot";
-    };
-  };
-
-  boot.plymouth = {
-    enable = true;
-    logo = "${pkgs.nixos-icons}/share/icons/hicolor/128x128/apps/nix-snowflake.png";
-  };
-}
hosts/chaser-kevin/default.nix
@@ -13,14 +13,8 @@ let
   hostName = "kevin";
 in {
   imports = [
-    nixos-hardware.nixosModules.common-cpu-intel
-    nixos-hardware.nixosModules.common-hidpi
-    nixos-hardware.nixosModules.common-pc-laptop
-    nixos-hardware.nixosModules.common-pc-laptop-ssd
-    ./nvidia.nix
     ./hardware-configuration.nix
     ./miscs.nix
-    ./boot.nix
   ];
 
   modules.currentHost = hostName;
hosts/chaser-kevin/hardware-configuration.nix
@@ -12,57 +12,6 @@
     (modulesPath + "/installer/scan/not-detected.nix")
   ];
 
-  boot.initrd.systemd = {
-    enable = true;
-  };
-  boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "thunderbolt" "usbhid" "sdhci_pci"];
-  boot.initrd.kernelModules = [];
-  boot.kernelPackages = pkgs.linuxPackages_xanmod_stable;
-  boot.kernelModules = ["kvm-intel"];
-  boot.kernelParams = [
-    "mem_sleep_default=deep"
-    # "resume_offset=51651840"
-  ];
-  # boot.resumeDevice = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
-  boot.extraModulePackages = [];
-
-  swapDevices = [
-    {
-      device = "/var/lib/swapfile";
-      size = 48 * 1024; # 48GB in MB
-    }
-  ];
-
-  fileSystems."/" = {
-    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
-    fsType = "btrfs";
-    options = ["subvol=root"];
-  };
-
-  fileSystems."/nix" = {
-    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
-    fsType = "btrfs";
-    options = ["subvol=nix"];
-  };
-
-  fileSystems."/home" = {
-    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
-    fsType = "btrfs";
-    options = ["subvol=home"];
-  };
-
-  fileSystems."/boot" = {
-    device = "/dev/disk/by-uuid/D032-DF36";
-    fsType = "vfat";
-    options = ["fmask=0022" "dmask=0022"];
-  };
-
-  fileSystems."/mnt/share" = {
-    device = "/dev/disk/by-uuid/4200-EC69";
-    fsType = "exfat";
-    options = ["uid=1000" "gid=100"];
-  };
-
   nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
   hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
 }
hosts/chaser-kevin/miscs.nix
@@ -1,37 +1,4 @@
 {
-  lib,
-  pkgs,
-  ...
-}: {
-  # Lid Settings
-  services.logind.settings.Login = {
-    HandleLidSwitch = "hibernate";
-    HandleLidSwitchExternalPower = "lock";
-    HandleLidSwitchDocked = "ignore";
-  };
-
-  # Fingerprint
-  services.fprintd = {
-    enable = true;
-    tod = {
-      enable = true;
-      driver = pkgs.libfprint-2-tod1-goodix;
-    };
-  };
-  systemd.services.fprintd = {
-    wantedBy = ["multi-user.target"];
-    serviceConfig.Type = "simple";
-  };
-
-  # Cooling management
-  services.thermald.enable = lib.mkDefault true;
-
-  # Touchpad
-  services.libinput.enable = true;
-
-  # √(3200² + 2000²) px / 16 in ≃ 235 dpi
-  services.xserver.dpi = 235;
-
   services.kmscon.extraConfig = "font-size=22";
 
   # Mihomo
hosts/chaser-kevin/nvidia.nix
@@ -1,40 +0,0 @@
-{
-  config,
-  lib,
-  nixos-hardware,
-  ...
-}: {
-  imports = [
-    nixos-hardware.nixosModules.common-gpu-nvidia
-  ];
-
-  services.xserver.videoDrivers = [
-    "nvidia"
-    "modesetting" # needed for offload mode
-  ];
-  boot.initrd.kernelModules = ["nvidia"];
-
-  # Nvidia ada lovelace
-  hardware.nvidia = {
-    package = config.boot.kernelPackages.nvidiaPackages.stable;
-    open = true;
-    prime = {
-      intelBusId = "PCI:0:2:0";
-      nvidiaBusId = "PCI:1:0:0";
-    };
-    primeBatterySaverSpecialisation = true;
-    powerManagement = {
-      enable = true;
-      finegrained = true;
-    };
-  };
-
-  hardware.nvidia-container-toolkit.enable = true;
-  hardware.graphics = {
-    enable = true;
-    # # needed by nvidia-docker
-    # enable32Bit = true;
-  };
-
-  # nixpkgs.config.cudaSupport = true;
-}
modules/hosts/chaser-kevin/boot.nix
@@ -0,0 +1,39 @@
+{inputs, ...}: {
+  flake.modules.nixos."hosts/kevin" = {pkgs, ...}: {
+    boot.loader = {
+      grub = rec {
+        enable = true;
+        devices = ["nodev"];
+        efiSupport = true;
+        gfxmodeEfi = "1024x768";
+        useOSProber = true;
+        theme = inputs.distro-grub-themes.packages.${pkgs.system}.lenovo-grub-theme;
+        splashImage = "${theme}/splash_image.jpg";
+      };
+      efi = {
+        canTouchEfiVariables = true;
+        efiSysMountPoint = "/boot";
+      };
+    };
+    boot.plymouth = {
+      enable = true;
+      logo = "${pkgs.nixos-icons}/share/icons/hicolor/128x128/apps/nix-snowflake.png";
+    };
+
+    boot.initrd.systemd = {
+      enable = true;
+    };
+    boot.initrd.kernelModules = ["nvidia"];
+    boot.initrd.availableKernelModules = [
+      "xhci_pci"
+      "nvme"
+      "thunderbolt"
+      "usbhid"
+      "sdhci_pci"
+    ];
+
+    boot.kernelPackages = pkgs.linuxPackages_xanmod_stable;
+    boot.kernelModules = ["kvm_intel"];
+    boot.kernelParams = ["mem_sleep_default=deep"];
+  };
+}
modules/hosts/chaser-kevin/filesystem.nix
@@ -0,0 +1,40 @@
+{
+  flake.modules.nixos."hosts/kevin" = {
+    swapDevices = [
+      {
+        device = "/var/lib/swapfile";
+        size = 48 * 1024; # 48GiB in MiB
+      }
+    ];
+
+    fileSystems."/" = {
+      device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+      fsType = "btrfs";
+      options = ["subvol=root"];
+    };
+
+    fileSystems."/nix" = {
+      device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+      fsType = "btrfs";
+      options = ["subvol=nix"];
+    };
+
+    fileSystems."/home" = {
+      device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+      fsType = "btrfs";
+      options = ["subvol=home"];
+    };
+
+    fileSystems."/boot" = {
+      device = "/dev/disk/by-uuid/D032-DF36";
+      fsType = "vfat";
+      options = ["fmask=0022" "dmask=0022"];
+    };
+
+    fileSystems."/mnt/share" = {
+      device = "/dev/disk/by-uuid/4200-EC69";
+      fsType = "exfat";
+      options = ["uid=1000" "gid=100"];
+    };
+  };
+}
modules/hosts/chaser-kevin/hardware.nix
@@ -0,0 +1,67 @@
+{inputs, ...}: {
+  flake.modules.nixos."hosts/kevin" = {
+    config,
+    pkgs,
+    ...
+  }: {
+    imports = with inputs.nixos-hardware.nixosModules; [
+      common-cpu-intel
+      common-hidpi
+      common-pc-laptop
+      common-pc-laptop-ssd
+    ];
+
+    # NVIDIA
+    hardware.nvidia = {
+      package = config.boot.kernelPackages.nvidiaPackages.stable;
+      open = true;
+      nvidiaSettings = true;
+      prime = {
+        intelBusId = "PCI:0:2:0";
+        nvidiaBusId = "PCI:1:0:0";
+        offload = {
+          enable = true;
+          enableOffloadCmd = true;
+        };
+      };
+      powerManagement = {
+        enable = true;
+        finegrained = true;
+      };
+    };
+    services.xserver.videoDrivers = ["nvidia" "modesetting"];
+    hardware.graphics.enable = true;
+
+    # Thunderbolt
+    services.hardware.bolt.enable = true;
+
+    # Fingerprint
+    services.fprintd = {
+      enable = true;
+      tod = {
+        enable = true;
+        driver = pkgs.libfprint-2-tod1-goodix;
+      };
+    };
+    systemd.services.fprintd = {
+      wantedBy = ["multi-user.target"];
+      serviceConfig.Type = "simple";
+    };
+
+    # Lid Settings
+    services.logind.settings.Login = {
+      HandleLidSwitch = "hibernate";
+      HandleLidSwitchExternalPower = "lock";
+      HandleLidSwitchDocked = "ignore";
+    };
+
+    # Cooling management
+    services.thermald.enable = true;
+
+    # Touchpad
+    services.libinput.enable = true;
+
+    # √(3200² + 2000²) px / 16 in ≃ 235 dpi
+    services.xserver.dpi = 235;
+  };
+}