NixOS systems config for laptop

This commit is contained in:
2025-12-03 18:06:10 -05:00
commit 1f374d9581
11 changed files with 939 additions and 0 deletions

85
hosts/default.nix Normal file
View File

@@ -0,0 +1,85 @@
{ inputs, hostName, system ? "x86_64-linux" }:
let
nixpkgs = inputs.nixpkgs;
home-manager = inputs.home-manager;
disko = inputs.disko;
lib = nixpkgs.lib;
commonModules = [
../boot.nix
../net.nix
../sw.nix
../users
home-manager.nixosModules.home-manager
disko.nixosModules.disko
({ ... }: {
disko.enableConfig = true;
disko.devices = {
disk.main = {
type = "disk";
device = lib.mkDefault "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
ESP = {
name = "ESP";
label = "BOOT";
size = "1024MiB";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
extraArgs = [ "-n" "BOOT" ];
};
};
swap = {
name = "swap";
label = "swap";
size = "34GiB";
content = {
type = "swap";
};
};
root = {
name = "root";
label = "root";
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
extraArgs = [ "-L" "ROOT" ];
};
};
};
};
};
};
})
];
# Map hostnames to their per-host module
hostModules = {
nix-laptop1 = ./nix-laptop1.nix;
};
in
lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; };
modules =
commonModules
++ [ (hostModules.${hostName} or (throw "Unknown host '${hostName}' in hosts/default.nix")) ]
++ [
{ networking.hostName = hostName; }
];
}

15
hosts/nix-laptop1.nix Normal file
View File

@@ -0,0 +1,15 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}