diff --git a/system/flake.nix b/system/flake.nix index 4896261..850becb 100644 --- a/system/flake.nix +++ b/system/flake.nix @@ -24,7 +24,6 @@ outputs = inputs@{ self, nixpkgs, utils, nixos-hardware, impermanence, nix-gaming, nixos-mailserver, ... }: let - hw = nixos-hardware.nixosModules; # IRL-related stuff I'd rather not put into git priv = if builtins.pathExists ./private.nix then (import ./private.nix) @@ -32,18 +31,19 @@ else { }; getPriv = hostname: with builtins; if hasAttr hostname priv then getAttr hostname priv else { }; common = hostname: [ (getPriv hostname) ]; - extraArgs = { - inherit nixpkgs; - }; lib = nixpkgs.lib // { quoteListenAddr = addr: if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr; }; - specialArgs = { - inherit lib; - }; mkHost = args @ { system ? "x86_64-linux", modules, ... }: { - inherit system extraArgs specialArgs; + inherit system; + extraArgs = { + inherit nixpkgs; + }; + specialArgs = { + inherit lib; + hardware = nixos-hardware.nixosModules; + }; } // args; in utils.lib.mkFlake { inherit self inputs; @@ -54,24 +54,19 @@ ./modules/common.nix impermanence.nixosModule ]; - hosts = { - nixmsi = mkHost { + hosts = builtins.mapAttrs (_: mkHost) { + nixmsi = { modules = [ - ./hosts/nixmsi.nix nix-gaming.nixosModules.pipewireLowLatency - hw.common-pc-ssd # enables fstrim - hw.common-cpu-amd # microcode - hw.common-cpu-amd-pstate # amd-pstate - hw.common-gpu-amd # configures drivers - hw.common-pc-laptop # enables tlp + ./hardware/msi_delta_15.nix + ./hosts/nixmsi.nix ] ++ common "nixmsi"; }; - nixserver = mkHost { + nixserver = { modules = [ - ./hosts/nixserver nixos-mailserver.nixosModules.default - hw.common-pc-hdd - hw.common-cpu-intel + ./hardware/hp_probook_g0.nix + ./hosts/nixserver ] ++ common "nixserver"; }; }; diff --git a/system/hardware/hp_probook_g0.nix b/system/hardware/hp_probook_g0.nix new file mode 100644 index 0000000..1313ff3 --- /dev/null +++ b/system/hardware/hp_probook_g0.nix @@ -0,0 +1,17 @@ +{ hardware +, ... }: + +{ + imports = with hardware; [ + common-pc-hdd + common-cpu-intel + common-gpu-amd + common-pc-laptop + ]; + boot = { + initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" "rtsx_pci_sdmmc" ]; + kernelModules = [ "kvm-intel" ]; + common.resolution = "1366x768"; + vfio.intelCpu = true; + }; +} diff --git a/system/hardware/msi_delta_15.nix b/system/hardware/msi_delta_15.nix new file mode 100644 index 0000000..22148d1 --- /dev/null +++ b/system/hardware/msi_delta_15.nix @@ -0,0 +1,24 @@ +{ hardware +, ... }: + +{ + imports = with hardware; [ + common-pc-ssd # enables fstrim + common-cpu-amd # microcode + common-cpu-amd-pstate # amd-pstate + common-gpu-amd # configures drivers + common-pc-laptop # enables tlp + ]; + common.resolution = "1920x1080"; + vfio.pciIDs = [ "1002:73df" "1002:ab28" ]; + boot = { + initrd.availableKernelModules = [ "nvme" "xhci_pci" ]; + kernelParams = [ + # disable PSR to *hopefully* avoid random hangs + # this one didnt help + "amdgpu.dcdebugmask=0x10" + # maybe this one will? + "amdgpu.noretry=0" + ]; + }; +} diff --git a/system/hosts/nixmsi.nix b/system/hosts/nixmsi.nix index 8bf0e46..7a56e8f 100644 --- a/system/hosts/nixmsi.nix +++ b/system/hosts/nixmsi.nix @@ -1,4 +1,8 @@ -{ lib, pkgs, ... }: +{ lib +, pkgs +, config +, ... }: + let efiPart = "/dev/disk/by-uuid/D77D-8CE0"; @@ -37,7 +41,6 @@ in { boot = { initrd = { - availableKernelModules = [ "nvme" "xhci_pci" ]; # insert crypto_keyfile into initrd so that grub can tell the kernel the # encryption key once I unlock the /boot partition secrets."/crypto_keyfile.bin" = "/boot/initrd/crypto_keyfile.bin"; @@ -64,12 +67,6 @@ in { "resume=/@swap/swapfile" # resume_offset = $(btrfs inspect-internal map-swapfile -r path/to/swapfile) "resume_offset=533760" - "fbcon=font:TER16x32" - # disable PSR to *hopefully* avoid random hangs - # this one didnt help - "amdgpu.dcdebugmask=0x10" - # maybe this one will? - "amdgpu.noretry=0" ]; loader = { grub = { @@ -78,8 +75,6 @@ in { efiSupport = true; # nodev = disable bios support device = "nodev"; - gfxmodeEfi = "1920x1080"; - gfxmodeBios = "1920x1080"; }; efi.canTouchEfiVariables = true; efi.efiSysMountPoint = "/boot/efi"; @@ -114,8 +109,7 @@ in { # see modules/vfio.nix vfio.enable = true; - vfio.pciIDs = [ "1002:73df" "1002:ab28" ]; - vfio.libvirtdGroup = [ "user" ]; + vfio.libvirtdGroup = [ config.common.mainUsername ]; # because libvirtd's nat is broken for some reason... networking.nat = { @@ -224,7 +218,7 @@ in { # programs.firejail.enable = true; # doesn't work: # programs.wireshark.enable = true; - # users.groups.wireshark.members = [ "user "]; + # users.groups.wireshark.members = [ config.common.mainUsername"]; services.printing.enable = true; # from nix-gaming services.pipewire.lowLatency = { diff --git a/system/hosts/nixserver/default.nix b/system/hosts/nixserver/default.nix index d953cb9..72c089b 100644 --- a/system/hosts/nixserver/default.nix +++ b/system/hosts/nixserver/default.nix @@ -40,10 +40,6 @@ in { system.stateVersion = "22.11"; boot = { - initrd = { - availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" "rtsx_pci_sdmmc" ]; - }; - kernelModules = [ "kvm-intel" ]; loader = { grub = { enable = true; @@ -51,8 +47,6 @@ in { version = 2; efiSupport = true; efiInstallAsRemovable = true; - gfxmodeEfi = "1920x1080"; - gfxmodeBios = "1920x1080"; }; efi.efiSysMountPoint = "/boot/efi"; }; @@ -71,6 +65,7 @@ in { }; zramSwap.enable = true; swapDevices = [ ]; + services.tlp.enable = false; impermanence = { enable = true; path = /persist; diff --git a/system/modules/common.nix b/system/modules/common.nix index 1a88092..a9691cc 100644 --- a/system/modules/common.nix +++ b/system/modules/common.nix @@ -22,6 +22,11 @@ default = false; description = "make getty autologin to the main user"; }; + resolution = mkOption { + type = with types; nullOr str; + default = null; + description = "resolution (none/1280x720/1920x1080)"; + }; }; }; default = { }; @@ -49,9 +54,15 @@ linkInputs = true; }; systemd.services.nix-daemon.serviceConfig.LimitSTACKSoft = "infinity"; - boot.kernelParams = [ + boot.kernelParams = lib.optionals (cfg.resolution != null) [ "consoleblank=60" - ]; + ] ++ (lib.optionals (cfg.resolution == "1920x1080") [ + "fbcon=font:TER16x32" + ]); + boot.loader.grub = lib.mkIf (cfg.resolution != null) { + gfxmodeEfi = cfg.resolution; + gfxmodeBios = cfg.resolution; + }; nixpkgs.overlays = [ (self: super: import ../pkgs { pkgs = super; inherit lib; }) ]; hardware.enableRedistributableFirmware = true; @@ -92,7 +103,8 @@ isNormalUser = true; extraGroups = [ "wheel" ]; }; - services.xserver.libinput.enable = lib.mkIf cfg.workstation true; + # nixos-hardware uses mkDefault here, so we use slightly higher priority + services.xserver.libinput.enable = lib.mkOverride 999 cfg.workstation; /* services.xserver = { enable = true; diff --git a/system/modules/vfio.nix b/system/modules/vfio.nix index 2a211e5..228d8cd 100644 --- a/system/modules/vfio.nix +++ b/system/modules/vfio.nix @@ -36,7 +36,7 @@ in { }; pciIDs = mkOption { type = with types; listOf str; - default = []; + default = [ ]; description = "PCI passthrough IDs"; }; lookingGlass = mkOption {