anchor.diff:      };
     };
   
  -  config = mkIf enabled {
  +  config = let
  +      igpuDriver = if pCfg.intelBusId != "" then "modesetting" else "amdgpu";
  +      igpuBusId = if pCfg.intelBusId != "" then pCfg.intelBusId else pCfg.amdgpuBusId;
  +  in mkIf enabled {
       assertions = [
         {
           assertion = with config.services.xserver.displayManager; gdm.nvidiaWayland -> cfg.modesetting.enable;
  
positive.code:     #   "nvidia" driver, in order to allow the X server to start without any outputs.
      # - Add a separate Device section for the Intel GPU, using the "modesetting"
      #   driver and with the configured BusID.
      # - Reference that Device section from the ServerLayout section as an inactive
      #   device.
      # - Configure the display manager to run specific `xrandr` commands which will
      #   configure/enable displays connected to the Intel GPU.
  
      services.xserver.useGlamor = mkDefault offloadCfg.enable;
  
      services.xserver.drivers = optional primeEnabled {
        name = "modesetting";
        display = offloadCfg.enable;
        deviceSection = ''
          BusID "${pCfg.intelBusId}"
          ${optionalString syncCfg.enable ''Option "AccelMethod" "none"''}
        '';
      } ++ singleton {
  
negative.code:     };
  
      services.xserver.serverLayoutSection = optionalString syncCfg.enable ''
        Inactive "Device-${igpuDriver}[0]"
      '' + optionalString offloadCfg.enable ''
        Option "AllowNVIDIAGPUScreens"
      '';
  
      services.xserver.displayManager.setupCommands = optionalString syncCfg.enable ''
        # Added by nvidia configuration module for Optimus/PRIME.
        ${pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource ${igpuDriver} NVIDIA-0
        ${pkgs.xorg.xrandr}/bin/xrandr --auto
      '';
  
  