From 73ac2fd227fa1ae40e843ca24a14b02be9b96393 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Fri, 17 May 2024 21:28:09 +0400 Subject: [PATCH] Refactor everything towards a desktop config Signed-off-by: Brian McGillion --- targets/lenovo-x1/everything.nix | 59 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/targets/lenovo-x1/everything.nix b/targets/lenovo-x1/everything.nix index ed706caf3..b28de5a6e 100644 --- a/targets/lenovo-x1/everything.nix +++ b/targets/lenovo-x1/everything.nix @@ -23,16 +23,33 @@ self.nixosModules.lanzaboote self.nixosModules.microvm - self.nixosModules.disko-lenovo-x1-basic-v1 - self.nixosModules.hw-lenovo-x1 - ({ pkgs, config, ... }: let powerControl = pkgs.callPackage ../../packages/powercontrol {}; + + # TODO: Move this to a separate function in self.lib + filterDevices = builtins.filter (d: d.vendorId != null && d.productId != null); + mapPciIdsToString = builtins.map (d: "${d.vendorId}:${d.productId}"); + vfioPciIds = mapPciIdsToString (filterDevices ( + config.ghaf.hardware.definition.network.pciDevices + ++ config.ghaf.hardware.definition.gpu.pciDevices + )); in { + boot.kernelParams = [ + "intel_iommu=on,sm_on" + "iommu=pt" + # Prevent i915 module from being accidentally used by host + "module_blacklist=i915" + "acpi_backlight=vendor" + # Enable VFIO for PCI devices + "vfio-pci.ids=${builtins.concatStringsSep "," vfioPciIds}" + ]; + + boot.initrd.availableKernelModules = ["nvme"]; + security.polkit.extraConfig = powerControl.polkitExtraConfig; time.timeZone = "Asia/Dubai"; @@ -96,6 +113,7 @@ configH = config; }; }; + virtualization.microvm.appvm = { enable = true; vms = import ./appvms/default.nix {inherit pkgs lib config;}; @@ -105,38 +123,13 @@ profiles = { applications.enable = false; }; + windows-launcher = { enable = true; spice = true; }; }; }) - - #TODO: how to handle the majority of laptops that need a little - # something extra? - # SEE: https://github.com/NixOS/nixos-hardware/blob/master/flake.nix - # nixos-hardware.nixosModules.lenovo-thinkpad-x1-10th-gen - - ({config, ...}: { - boot.kernelParams = let - filterDevices = builtins.filter (d: d.vendorId != null && d.productId != null); - mapPciIdsToString = builtins.map (d: "${d.vendorId}:${d.productId}"); - vfioPciIds = mapPciIdsToString (filterDevices ( - config.ghaf.hardware.definition.network.pciDevices - ++ config.ghaf.hardware.definition.gpu.pciDevices - )); - in [ - "intel_iommu=on,sm_on" - "iommu=pt" - # Prevent i915 module from being accidentally used by host - "module_blacklist=i915" - "acpi_backlight=vendor" - - "vfio-pci.ids=${builtins.concatStringsSep "," vfioPciIds}" - ]; - - boot.initrd.availableKernelModules = ["nvme"]; - }) ] ++ extraModules; }; @@ -146,8 +139,8 @@ package = hostConfiguration.config.system.build.diskoImages; }; in [ - (lenovo-x1 "gen10" "debug" []) - (lenovo-x1 "gen11" "debug" []) - (lenovo-x1 "gen10" "release" []) - (lenovo-x1 "gen11" "release" []) + (lenovo-x1 "gen10" "debug" [self.nixosModules.disko-lenovo-x1-basic-v1 self.nixosModules.hw-lenovo-x1]) + (lenovo-x1 "gen11" "debug" [self.nixosModules.disko-lenovo-x1-basic-v1 self.nixosModules.hw-lenovo-x1]) + (lenovo-x1 "gen10" "release" [self.nixosModules.disko-lenovo-x1-basic-v1 self.nixosModules.hw-lenovo-x1]) + (lenovo-x1 "gen11" "release" [self.nixosModules.disko-lenovo-x1-basic-v1 self.nixosModules.hw-lenovo-x1]) ]