NixOS power management help! USB doesn't work

Any help with this would be GREATLY appreciated. Originally I thought that this was a dock issue, but then I found that off the dock, and off of AC, no USB is recognized. So I messed around with TLP, powertop, and the nixos powermanagement flag. I was able to get some shoddy, unreliable USB functionality without AC, but nothing reliable or terribly useful.

I’m running a Lenovo T495, and I’m using a 40AJ docking station. I am struggling to get any TLP or powertop settings to persist beyond reboot, but even still, I’m not sure I’m finding adequate settings with either before reboot.

sudo powertop --html gives me a segfault. :roll_eyes:

This is where things are at the moment:

$ uname -a
Linux nixos 5.4.51 #1-NixOS SMP Thu Jul 9 07:37:57 UTC 2020 x86_64 GNU/Linux
--- TLP 1.2.2 --------------------------------------------

+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
TLP_PERSISTENT_DEFAULT=0
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
CPU_HWP_ON_AC=balance_performance
CPU_HWP_ON_BAT=balance_power
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=power
DISK_DEVICES="nvme0n1 sda"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"
SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
SATA_LINKPWR_ON_BAT="med_power_with_dipm min_power"
AHCI_RUNTIME_PM_TIMEOUT=15
RADEON_POWER_PROFILE_ON_AC=default
RADEON_POWER_PROFILE_ON_BAT=default
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_AC=0
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE="sr0"
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
USB_AUTOSUSPEND=1
USB_BLACKLIST_BTUSB=0
USB_BLACKLIST_PHONE=0
USB_BLACKLIST_PRINTER=1
USB_BLACKLIST_WWAN=0
RESTORE_DEVICE_STATE_ON_STARTUP=0
NATACPI_ENABLE=1
TPACPI_ENABLE=1
TPSMAPI_ENABLE=1
	USB_AUTOSUSPEND=0

+++ System Info
System         = LENOVO ThinkPad T495 20NKS15S00
BIOS           = R12ET55W(1.25 )
Kernel         = 5.4.51 #1-NixOS SMP Thu Jul 9 07:37:57 UTC 2020 x86_64
/proc/cmdline  = initrd=\efi\nixos\z8fyh1ky8cxayrbka0r6ip6v6ggfqps0-initrd-linux-5.4.51-initrd.efi systemConfig=/nix/store/mvg8k8g0j0w7jlwp6w8y2r208n9k7lg7-nixos-system-nixos-20.03.2520.add5529b3ee init=/nix/store/mvg8k8g0j0w7jlwp6w8y2r208n9k7lg7-nixos-system-nixos-20.03.2520.add5529b3ee/init acpi_backlight=native loglevel=4
Init system    = systemd 
Boot mode      = UEFI

+++ TLP Status
State          = enabled
RDW state      = not installed
Last run       = 11:20:06 PM, 302011 sec(s) ago
Mode           = AC
Power source   = AC

+++ Processor
CPU model      = AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu4/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu4/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu4/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu5/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu5/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu5/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu6/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu6/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu6/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu6/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpu7/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu7/cpufreq/scaling_governor  = performance
/sys/devices/system/cpu/cpu7/cpufreq/scaling_available_governors = performance schedutil 
/sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu7/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

/sys/devices/system/cpu/cpufreq/boost                  = 1

x86_energy_perf_policy: unsupported CPU.

/sys/module/workqueue/parameters/power_efficient       = N
/proc/sys/kernel/nmi_watchdog                          = (not available)

+++ Undervolting
PHC kernel not available.

+++ Temperatures
/proc/acpi/ibm/thermal = 63 0 0 0 0 0 0 -128 0 0 66 0 0 0 0 0 [°C]
/proc/acpi/ibm/fan     =  3700 [/min]

+++ File System
/proc/sys/vm/laptop_mode               =     0
/proc/sys/vm/dirty_writeback_centisecs =  1500
/proc/sys/vm/dirty_expire_centisecs    =  1500
/proc/sys/vm/dirty_ratio               =    20
/proc/sys/vm/dirty_background_ratio    =    10

+++ Storage Devices
Devices = nvme0n1 sda

/dev/nvme0n1:
  Type      = NVMe
  Model     = Samsung SSD 970 EVO 1TB                 
  Firmware  = 2B2QEXE7
  Scheduler = [none] mq-deadline kyber (multi queue)

  Runtime PM: control = auto, autosuspend_delay_ms = (not available)

  SMART info:
    Critical Warning:                   0x00
    Temperature:                        48 Celsius
    Available Spare:                    100%
    Available Spare Threshold:          10%
    Percentage Used:                    0%
    Data Units Written:                 8,061,688 [4.12 TB]
    Power Cycles:                       58
    Power On Hours:                     682
    Unsafe Shutdowns:                   12
    Media and Data Integrity Errors:    0

/dev/sda: not present.

+++ AHCI Link Power Management (ALPM)
No AHCI-enabled host controller detected.

+++ Wireless
bluetooth = on
wifi      = on
wwan      = none (no device)

hci0(btusb)                   : bluetooth, not connected
wlp1s0(iwlwifi)               : wifi, connected, power management = off

+++ Audio
/sys/module/snd_hda_intel/parameters/power_save            = 0
/sys/module/snd_hda_intel/parameters/power_save_controller = N

+++ PCIe Active State Power Management
/sys/module/pcie_aspm/parameters/policy = default (using bios preferences)

+++ Runtime Power Management
Device blacklist = (not configured)
Driver blacklist = amdgpu mei_me nouveau nvidia pcieport radeon (default)

/sys/bus/pci/devices/0000:00:00.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:00.2/power/control = on   (0x080600, IOMMU, no driver)
/sys/bus/pci/devices/0000:00:01.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:01.2/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.3/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.4/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.6/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.7/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:08.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:08.1/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:14.0/power/control = on   (0x0c0500, SMBus, piix4_smbus)
/sys/bus/pci/devices/0000:00:14.3/power/control = on   (0x060100, ISA bridge, no driver)
/sys/bus/pci/devices/0000:00:18.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.1/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.2/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.3/power/control = on   (0x060000, Host bridge, k10temp)
/sys/bus/pci/devices/0000:00:18.4/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.5/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.6/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.7/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:01:00.0/power/control = on   (0x028000, Network controller, iwlwifi)
/sys/bus/pci/devices/0000:02:00.0/power/control = on   (0x010802, Non-Volatile memory controller, nvme)
/sys/bus/pci/devices/0000:03:00.0/power/control = on   (0x020000, Ethernet controller, r8169)
/sys/bus/pci/devices/0000:03:00.1/power/control = on   (0x070002, Serial controller, no driver)
/sys/bus/pci/devices/0000:03:00.2/power/control = on   (0x070002, Serial controller, no driver)
/sys/bus/pci/devices/0000:03:00.3/power/control = on   (0x0c0701, IPMI Interface, no driver)
/sys/bus/pci/devices/0000:03:00.4/power/control = on   (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:04:00.0/power/control = on   (0x020000, Ethernet controller, r8169)
/sys/bus/pci/devices/0000:05:00.0/power/control = on   (0x080501, SD Host controller, sdhci-pci)
/sys/bus/pci/devices/0000:06:00.0/power/control = on   (0x030000, VGA compatible controller, amdgpu)
/sys/bus/pci/devices/0000:06:00.1/power/control = on   (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:06:00.2/power/control = on   (0x108000, Encryption controller, no driver)
/sys/bus/pci/devices/0000:06:00.3/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:06:00.4/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:06:00.5/power/control = on   (0x048000, Multimedia controller, no driver)
/sys/bus/pci/devices/0000:06:00.6/power/control = on   (0x040300, Audio device, snd_hda_intel)

+++ USB
Autosuspend         = disabled
Device whitelist    = (not configured)
Device blacklist    = (not configured)
Bluetooth blacklist = disabled
Phone blacklist     = disabled
WWAN blacklist      = disabled

Bus 005 Device 001 ID 1d6b:0003 control = on,   autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 004 Device 004 ID 5986:2113 control = on,   autosuspend_delay_ms = 2000 -- Acer, Inc  (uvcvideo)
Bus 004 Device 003 ID 05e3:0610 control = on,   autosuspend_delay_ms =    0 -- Genesys Logic, Inc. 4-port hub (hub)
Bus 004 Device 002 ID 8087:0025 control = on,   autosuspend_delay_ms = 2000 -- Intel Corp.  (btusb)
Bus 004 Device 001 ID 1d6b:0002 control = on,   autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 003 Device 003 ID 17ef:3070 control = on,   autosuspend_delay_ms =    0 -- Lenovo  (hub)
Bus 003 Device 002 ID 17ef:3070 control = on,   autosuspend_delay_ms =    0 -- Lenovo USB3.1 Hub              (hub)
Bus 003 Device 001 ID 1d6b:0003 control = on,   autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 002 Device 006 ID 17ef:3075 control = on,   autosuspend_delay_ms = 2000 -- Lenovo  (no driver)
Bus 002 Device 005 ID feed:1307 control = on,   autosuspend_delay_ms = 2000 -- <unknown> (usbhid)
Bus 002 Device 008 ID 17ef:306f control = on,   autosuspend_delay_ms = 2000 -- Lenovo USB2.0 Hub              (snd-usb-audio, usbhid)
Bus 002 Device 007 ID 047d:8018 control = on,   autosuspend_delay_ms = 2000 -- Kensington  (usbhid)
Bus 002 Device 004 ID 17ef:3071 control = on,   autosuspend_delay_ms =    0 -- Lenovo  (hub)
Bus 002 Device 003 ID 17ef:3071 control = on,   autosuspend_delay_ms =    0 -- Lenovo USB2.0 Hub              (hub)
Bus 002 Device 002 ID 17ef:3074 control = on,   autosuspend_delay_ms = 2000 -- Lenovo USB Billboard (usbhid)
Bus 002 Device 001 ID 1d6b:0002 control = on,   autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 001 Device 001 ID 1d6b:0002 control = on,   autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = active (data, thresholds)
tpacpi-bat = active (recalibrate)
tp-smapi   = inactive (ThinkPad not supported)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer                   = LGC
/sys/class/power_supply/BAT0/model_name                     = 02DL007
/sys/class/power_supply/BAT0/cycle_count                    =     12
/sys/class/power_supply/BAT0/energy_full_design             =  50500 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  51480 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  49830 [mWh]
/sys/class/power_supply/BAT0/power_now                      =      0 [mW]
/sys/class/power_supply/BAT0/status                         = Unknown (threshold effective)

/sys/class/power_supply/BAT0/charge_start_threshold         =     95 [%]
/sys/class/power_supply/BAT0/charge_stop_threshold          =    100 [%]
tpacpi-bat.BAT0.forceDischarge                              =      0

Charge                                                      =   96.8 [%]
Capacity                                                    =  101.9 [%]
$ cat \etc\nixos\configuration.nix
# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  
    boot = {
    kernelModules = [ "acpi_call" ];
    extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
  };

  # networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # The global useDHCP flag is deprecated, therefore explicitly set to false here.
  # Per-interface useDHCP will be mandatory in the future, so this generated config
  # replicates the default behaviour.
  networking.useDHCP = false;
	networking.interfaces.enp3s0f0.useDHCP = true;
	networking.interfaces.enp4s0.useDHCP = true;
	networking.interfaces.wlp1s0.useDHCP = true;

	networking.wireless.enable = true;
	networking.wireless.networks = {
		AndnowTheLarch = {
			psk = "***";
		};
		AndnowTheLarchPlus = {
			psk = "***";
		};
		Verizon-SM-G965U-B129 = {
			psk = "***";
		};
		"West Street" = {
			psk = "***";
		};
	};

	boot.kernelParams = [ "acpi_backlight=native" ];


  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  # i18n.defaultLocale = "en_US.UTF-8";
  # console = {
  #   font = "Lat2-Terminus16";
  #   keyMap = "us";
  # };

  # Set your time zone.
    time.timeZone = "America/New_York";

  # List packages installed in system profile. To search, run:
  # $ nix search wget
	environment.systemPackages = with pkgs; [
		neovim
		tmux
		rxvt-unicode
		scrot
		rofi
		qutebrowser
		stalonetray
		xmobar
		xclip
		volumeicon
		zsh
		python
		python3
		oh-my-zsh
		python27Packages.pynvim
		python37Packages.pynvim
		git
		steam
		lastpass-cli
		taskwarrior
		gcalcli
		chromium
		neomutt
		obs-studio
		zoom-us
		racket
		dropbox
		inkscape
		# lilypond stuff
		lilypond
		wmctrl 
		timidity
		zathura
		ghostscript
		#
		cowsay
		nextcloud-client
		signal-desktop
		feh
		ranger
		pciutils
		usbutils
		xfce.xfce4-power-manager # T495 -- enable computer brightness keys
		pinentry # gives a full-terminal sign in screen, but doesn't give a popup. not sure if I need/want this
		spotify
		xdotool
		toilet
		imagemagick
		# youtube-dl # more up to date with nix-env
		mpv
		spotify-tui
		plover.dev
		gnumake
		# QMK stuff
		avrdude
		dfu-programmer
		wget
		gcc
		python27Packages.pip
		python37Packages.pip
		python37Packages.pip-tools
		#
		dwarf-fortress
		dwarf-therapist
		htop
		unzip
		gimp
		lua
		powertop
	];

	nixpkgs.config.allowUnfree = true; 
	hardware.opengl.driSupport32Bit = true;

	fonts.fonts = with pkgs; [
		font-awesome_4
	];

	environment.variables.EDITOR = "nvim";
	environment.variables.SUDO_EDITOR = "nvim";

	programs.zsh.enable = true;
	programs.zsh.ohMyZsh.enable = true;

	services.printing.enable = true;
	services.printing.drivers = [ pkgs.gutenprint ];

	# Enable cron service
  services.cron = {
    enable = true;
  #   systemCronJobs = [
  #     "0 2 * * * /home/dot/scripts/telegram_video_nextcloud_to_dropbox.sh"
  #   ];
  };

# t495 power stuff

# powerManagement.powertop.enable = true;
powerManagement.enable = true;
services.tlp.enable = true;
services.tlp.extraConfig = ''
	USB_AUTOSUSPEND=0
'';
# powerManagement.cpuFreqGovernor = "powersave";

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  #   pinentryFlavor = "gnome3";
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
    services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
    sound.enable = true;
    hardware.pulseaudio.enable = true;

  # Enable the X11 windowing system.
  # services.xserver.enable = true;
  # services.xserver.layout = "us";
  # services.xserver.xkbOptions = "eurosign:e";

  # Enable touchpad support.
    services.xserver.libinput.enable = true;

  # Enable the KDE Desktop Environment.
  # services.xserver.displayManager.sddm.enable = true;
  # services.xserver.desktopManager.plasma5.enable = true;
  #
  # Enable xmonad
  services.xserver = {
		enable = true;
		windowManager = {
			xmonad = {
				enable = true;
				enableContribAndExtras = true;
				extraPackages = haskellPackages: [
					haskellPackages.xmonad-contrib
					haskellPackages.xmonad-extras
					haskellPackages.xmonad
					haskellPackages.xmobar
				];
			};	
		};
		displayManager = {
			lightdm.enable = true;
			defaultSession = "none+xmonad";
			startx.enable = false;
		};
	};

  # Define a user account. Don't forget to set a password with ‘passwd’.
	users.users.dot = {
		isNormalUser = true;
		extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
		shell = pkgs.zsh;
	};

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "20.03"; # Did you read the comment?

	services.xserver.displayManager.sessionCommands = ''
		${pkgs.xorg.xrdb}/bin/xrdb -merge <${pkgs.writeText "xresources" ''
						
			!--------------------XDefaults
			URxvt.font:     xft:bitstream vera sans mono:size=12:antialias=true, xft:FreeMono, xft:Symbola
			URxvt.boldFont: xft:bitstream vera sans mono:bold:size=12:antialias=true
			URxvt.italicFont: xft:bitstream vera sans mono:italic:size=12:antialias=true
			URxvt.termName: rxvt-unicode
			URxvt*scrollBar: false
			URxvt*matcher.button: 1
			URxvt.transparent: false
			URxvt.intensityStyles: false
			Xft*dpi: 96
			Xft*antialias: true
			Xft*hinting: true
			Xft*hintstyle: hintfull
			Xft*rgba: rgb
			URxvt*geometry: 85x20
			*internalBorder: 23
			URxvt*fading: 0
			URxvt*tintColor: #ffffff
			URxvt*shading: 0
			URxvt*inheritPixmap: False

			! special
			*.foreground:   #d0d0d0
			*.background:   #000000
			*.cursorColor:  #d0d0d0

			! black
			*.color0:       #000000
			*.color8:       #808080

			! red
			*.color1:       #ff0000
			*.color9:       #ff0000

			! green
			*.color2:       #33ff00
			*.color10:      #33ff00

			! yellow
			*.color3:       #ff0099
			*.color11:      #ff0099

			! blue
			*.color4:       #0066ff
			*.color12:      #0066ff

			! magenta
			*.color5:       #cc00ff
			*.color13:      #cc00ff

			! cyan
			*.color6:       #00ffff
			*.color14:      #00ffff

			! white
			*.color7:       #d0d0d0
			*.color15:      #ffffff


			!! URxvt Appearance
			! URxvt.font: -*-rissole-*
			! URxvt.boldFont: -*-rissole-*
			! URxvt.italicFont: -*-rissole-*
			URxvt.boldItalicfont: -*-rissole-*
			URxvt.letterSpace: 0
			URxvt.lineSpace: 0
			URxvt.geometry: 92x24
			URxvt.internalBorder: 24
			URxvt.cursorBlink: true
			URxvt.cursorUnderline: false
			URxvt.saveline: 2048
			URxvt.scrollBar: false
			URxvt.scrollBar_right: false
			URxvt.urgentOnBell: true
			URxvt.depth: 24
			URxvt.iso14755: false

			! IBeam cursor in urxvt
			URxvt.perl-ext-common: ibeamcursor

				''}
		'';

	}



Updates:

I have removed powertop and disabled powerManagement. But more importantly, I found a rec to blacklist my usb devices from power management in TLP. The only thing is… it’s not doing it? I have it set to blacklist power management, but it simultaneously reads that I have that set, and that power management is enabled:

+++ Runtime Power Management
Device blacklist = 06:00.3 06:00.4
Driver blacklist = amdgpu mei_me nouveau nvidia pcieport radeon (default)

/sys/bus/pci/devices/0000:00:00.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:00.2/power/control = on   (0x080600, IOMMU, no driver)
/sys/bus/pci/devices/0000:00:01.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:01.2/power/control = on   (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.3/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.4/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.6/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:01.7/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:08.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:08.1/power/control = auto (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:14.0/power/control = on   (0x0c0500, SMBus, piix4_smbus)
/sys/bus/pci/devices/0000:00:14.3/power/control = on   (0x060100, ISA bridge, no driver)
/sys/bus/pci/devices/0000:00:18.0/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.1/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.2/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.3/power/control = on   (0x060000, Host bridge, k10temp)
/sys/bus/pci/devices/0000:00:18.4/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.5/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.6/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:18.7/power/control = on   (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:01:00.0/power/control = on   (0x028000, Network controller, iwlwifi)
/sys/bus/pci/devices/0000:02:00.0/power/control = on   (0x010802, Non-Volatile memory controller, nvme)
/sys/bus/pci/devices/0000:03:00.0/power/control = on   (0x020000, Ethernet controller, r8169)
/sys/bus/pci/devices/0000:03:00.1/power/control = on   (0x070002, Serial controller, no driver)
/sys/bus/pci/devices/0000:03:00.2/power/control = on   (0x070002, Serial controller, no driver)
/sys/bus/pci/devices/0000:03:00.3/power/control = on   (0x0c0701, IPMI Interface, no driver)
/sys/bus/pci/devices/0000:03:00.4/power/control = on   (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:04:00.0/power/control = on   (0x020000, Ethernet controller, r8169)
/sys/bus/pci/devices/0000:05:00.0/power/control = on   (0x080501, SD Host controller, sdhci-pci)
/sys/bus/pci/devices/0000:06:00.0/power/control = on   (0x030000, VGA compatible controller, amdgpu)
/sys/bus/pci/devices/0000:06:00.1/power/control = on   (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:06:00.2/power/control = on   (0x108000, Encryption controller, no driver)
/sys/bus/pci/devices/0000:06:00.3/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:06:00.4/power/control = on   (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:06:00.5/power/control = on   (0x048000, Multimedia controller, no driver)
/sys/bus/pci/devices/0000:06:00.6/power/control = on   (0x040300, Audio device, snd_hda_intel)

+++ USB
Autosuspend         = disabled
Device whitelist    = (not configured)
Device blacklist    = (not configured)
Bluetooth blacklist = disabled
Phone blacklist     = disabled
WWAN blacklist      = disabled

Bus 005 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 004 Device 004 ID 5986:2113 control = auto, autosuspend_delay_ms = 2000 -- Acer, Inc  (uvcvideo)
Bus 004 Device 003 ID 05e3:0610 control = auto, autosuspend_delay_ms =    0 -- Genesys Logic, Inc. 4-port hub (hub)
Bus 004 Device 002 ID 8087:0025 control = on,   autosuspend_delay_ms = 2000 -- Intel Corp.  (btusb)
Bus 004 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 003 Device 003 ID 17ef:3070 control = auto, autosuspend_delay_ms =    0 -- Lenovo  (hub)
Bus 003 Device 002 ID 17ef:3070 control = auto, autosuspend_delay_ms =    0 -- Lenovo USB3.1 Hub              (hub)
Bus 003 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 002 Device 007 ID 17ef:3075 control = on,   autosuspend_delay_ms = 2000 -- Lenovo  (no driver)
Bus 002 Device 005 ID feed:1307 control = on,   autosuspend_delay_ms = 2000 -- <unknown> (usbhid)
Bus 002 Device 008 ID 17ef:306f control = on,   autosuspend_delay_ms = 2000 -- Lenovo USB2.0 Hub              (snd-usb-audio, usbhid)
Bus 002 Device 006 ID 047d:8018 control = on,   autosuspend_delay_ms = 2000 -- Kensington  (usbhid)
Bus 002 Device 004 ID 17ef:3071 control = auto, autosuspend_delay_ms =    0 -- Lenovo  (hub)
Bus 002 Device 003 ID 17ef:3071 control = auto, autosuspend_delay_ms =    0 -- Lenovo USB2.0 Hub              (hub)
Bus 002 Device 002 ID 17ef:3074 control = on,   autosuspend_delay_ms = 2000 -- Lenovo USB Billboard (usbhid)
Bus 002 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 001 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)

ugh, so frustrating.

also, I tried to directly edit the power control files to no avail.

$ sudo echo "off" > `realpath /sys/bus/pci/devices/0000:06:00.3/power/control`    
zsh: permission denied: /sys/devices/pci0000:00/0000:00:08.1/0000:06:00.3/power/control

I blacklisted thus in configuration.nix:

services.tlp.extraConfig = ''
USB_AUTOSUSPEND=0
RUNTIME_PM_BLACKLIST="06:00.3 06:00.4"
'';

maybe you’ll notice that USB_AUTOSUSPEND=0 from my configuration.nix is appended to my TLP setup, such that it is after USB_AUTOSUSPEND=1. I wonder if that is causing issues and needs to be rectified. If I edit the TLP config directly, would it get overwritten by nixos? or something else?

sorry for all the replies, I’m new to discourse and I’m just trying to get some of this done before my workday, while I’m having my coffee. Thanks for any help you can provide!!