Nix configurations for my homelab
1{
2 lib,
3 pkgs,
4 modulesPath,
5 ...
6}:
7{
8 imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
9
10 boot = {
11 initrd = {
12 availableKernelModules = [
13 "xhci_pci"
14 "ahci"
15 "nvme"
16 "usbhid"
17 "usb_storage"
18 "sd_mod"
19 ];
20 kernelModules = [ ];
21 };
22 kernel = {
23 sysctl."vm.max_map_count" = 2147483642;
24 sysfs.module.zswap.parameters = {
25 accept_threshold_percent = 90;
26 compressor = "zstd";
27 enabled = "Y";
28 max_pool_percent = 50;
29 shrinker_enabled = "N";
30 zpool = "zsmalloc";
31 };
32 };
33 kernelModules = [ "kvm-intel" ];
34 kernelPackages = pkgs.linuxPackages_latest;
35 kernelParams = [ "preempt=full" ];
36 kernelPatches = [ ];
37 loader = {
38 efi.canTouchEfiVariables = true;
39 systemd-boot = {
40 configurationLimit = 50;
41 consoleMode = "auto";
42 enable = true;
43 };
44 timeout = 0;
45 };
46 supportedFilesystems = [ "ntfs" ];
47 tmp.useTmpfs = true;
48 };
49
50 fileSystems =
51 let
52 disk-uuid = "/dev/disk/by-uuid/7bf830d4-189d-4e9b-bcb0-565f4ac69e67";
53 in
54 {
55 "/" = {
56 device = "none";
57 fsType = "tmpfs";
58 options = [
59 "defaults"
60 "mode=755"
61 ];
62 };
63 "/data" = {
64 device = disk-uuid;
65 fsType = "btrfs";
66 options = [
67 "subvol=@nixos/data"
68 "compress=zstd"
69 "discard=async"
70 ];
71 neededForBoot = true;
72 };
73 "/nix" = {
74 device = disk-uuid;
75 fsType = "btrfs";
76 options = [
77 "subvol=@nixos/nix"
78 "compress=zstd"
79 "discard=async"
80 ];
81 };
82 "/config" = {
83 device = disk-uuid;
84 fsType = "btrfs";
85 options = [
86 "subvol=@nixos/config"
87 "compress=zstd"
88 "discard=async"
89 ];
90 };
91 "/swap" = {
92 device = disk-uuid;
93 fsType = "btrfs";
94 options = [ "subvol=@swap" ];
95 };
96 "/boot" = {
97 device = "/dev/disk/by-uuid/862D-85DB";
98 fsType = "vfat";
99 options = [
100 "fmask=0077"
101 "dmask=0077"
102 "defaults"
103 ];
104 };
105 };
106
107 swapDevices = [ { device = "/swap/swapfile"; } ];
108
109 nixpkgs.config.rocmSupport = true;
110 hardware = {
111 amdgpu.opencl.enable = true;
112 block.defaultScheduler = "kyber";
113 bluetooth = {
114 enable = true;
115 powerOnBoot = false;
116 };
117 cpu.intel.updateMicrocode = true;
118 enableRedistributableFirmware = true;
119 uinput.enable = true;
120 graphics = {
121 enable = true;
122 enable32Bit = true;
123 extraPackages = with pkgs; [
124 intel-compute-runtime
125 intel-media-driver
126 vpl-gpu-rt
127 ];
128 };
129 };
130
131 powerManagement.cpuFreqGovernor = "performance";
132 networking.useDHCP = lib.mkDefault true;
133 nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
134}