Add thinkpad host
This commit is contained in:
parent
bb38eee42f
commit
6595af21c7
6 changed files with 659 additions and 0 deletions
15
flake.nix
15
flake.nix
|
|
@ -53,6 +53,15 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixosConfigurations."thinkpad" = nixpkgs.lib.nixosSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
disko.nixosModules.disko
|
||||||
|
./hosts/nixos/thinkpad/system.nix
|
||||||
|
./hosts/nixos/thinkpad/disk-config.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
"yanlin@imac" = home-manager.lib.homeManagerConfiguration {
|
"yanlin@imac" = home-manager.lib.homeManagerConfiguration {
|
||||||
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
|
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
|
||||||
|
|
@ -77,6 +86,12 @@
|
||||||
modules = [ ./hosts/nixos/vps/home.nix ];
|
modules = [ ./hosts/nixos/vps/home.nix ];
|
||||||
extraSpecialArgs = { inherit claude-code nixvim; };
|
extraSpecialArgs = { inherit claude-code nixvim; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
"yanlin@thinkpad" = home-manager.lib.homeManagerConfiguration {
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
modules = [ ./hosts/nixos/thinkpad/home.nix ];
|
||||||
|
extraSpecialArgs = { inherit claude-code nixvim firefox-addons; };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
249
hosts/nixos/thinkpad/INSTALL.md
Normal file
249
hosts/nixos/thinkpad/INSTALL.md
Normal file
|
|
@ -0,0 +1,249 @@
|
||||||
|
# NixOS Installation Guide for ThinkPad P14s Gen 2
|
||||||
|
|
||||||
|
This guide will walk you through installing NixOS on your Lenovo ThinkPad P14s Gen 2 with Intel i7 and NVIDIA T500 GPU.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- USB drive (4GB or larger)
|
||||||
|
- NixOS ISO image
|
||||||
|
- Ethernet cable or WiFi credentials
|
||||||
|
- This configuration repository
|
||||||
|
|
||||||
|
## Step 1: Prepare Installation Media
|
||||||
|
|
||||||
|
1. Download the latest NixOS ISO (GNOME or Plasma edition recommended for GUI installer):
|
||||||
|
```bash
|
||||||
|
# Download from https://nixos.org/download.html
|
||||||
|
# Choose the 64-bit Intel/AMD ISO
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Write the ISO to USB drive:
|
||||||
|
```bash
|
||||||
|
# On Linux/macOS:
|
||||||
|
sudo dd if=nixos-24.05-x86_64.iso of=/dev/sdX bs=4M status=progress
|
||||||
|
|
||||||
|
# On Windows: Use Rufus or Etcher
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 2: Boot from USB
|
||||||
|
|
||||||
|
1. Insert the USB drive into your ThinkPad
|
||||||
|
2. Press F12 during boot to access boot menu
|
||||||
|
3. Select the USB drive
|
||||||
|
4. Choose "NixOS Installer" from the boot menu
|
||||||
|
|
||||||
|
## Step 3: Connect to Internet
|
||||||
|
|
||||||
|
### Option A: Ethernet (Easiest)
|
||||||
|
Simply plug in an ethernet cable.
|
||||||
|
|
||||||
|
### Option B: WiFi
|
||||||
|
```bash
|
||||||
|
# List available networks
|
||||||
|
sudo nmcli device wifi list
|
||||||
|
|
||||||
|
# Connect to WiFi
|
||||||
|
sudo nmcli device wifi connect "YOUR_SSID" password "YOUR_PASSWORD"
|
||||||
|
|
||||||
|
# Verify connection
|
||||||
|
ping -c 3 nixos.org
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 4: Prepare Disk
|
||||||
|
|
||||||
|
### IMPORTANT: Identify Your Disk
|
||||||
|
```bash
|
||||||
|
# List all disks
|
||||||
|
lsblk
|
||||||
|
|
||||||
|
# Your NVMe SSD will likely be /dev/nvme0n1
|
||||||
|
# Verify the size matches your disk
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update Disk Configuration
|
||||||
|
Edit the disk device in your configuration if needed:
|
||||||
|
```bash
|
||||||
|
# If your disk is not /dev/nvme0n1, you'll need to update disk-config.nix
|
||||||
|
# after cloning the repository (see next step)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 5: Clone Configuration Repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install git temporarily
|
||||||
|
nix-shell -p git
|
||||||
|
|
||||||
|
# Clone your configuration
|
||||||
|
git clone https://github.com/Logan-Lin/nix-config.git
|
||||||
|
cd nix-config
|
||||||
|
|
||||||
|
# If needed, update the disk device in hosts/nixos/thinkpad/disk-config.nix
|
||||||
|
nano hosts/nixos/thinkpad/disk-config.nix
|
||||||
|
# Change 'device = "/dev/nvme0n1"' to match your disk
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 6: Partition Disk with Disko
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# This will ERASE your entire disk!
|
||||||
|
# Make sure you have backups of any important data
|
||||||
|
|
||||||
|
# Partition the disk according to disk-config.nix
|
||||||
|
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- \
|
||||||
|
--mode disko \
|
||||||
|
--flake .#thinkpad
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 7: Generate Hardware Configuration
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generate hardware-configuration.nix
|
||||||
|
sudo nixos-generate-config --show-hardware-config > hosts/nixos/thinkpad/hardware-configuration.nix
|
||||||
|
|
||||||
|
# Review the generated file
|
||||||
|
cat hosts/nixos/thinkpad/hardware-configuration.nix
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 8: Find GPU Bus IDs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Find your GPU bus IDs for NVIDIA PRIME
|
||||||
|
lspci | grep -E 'VGA|3D'
|
||||||
|
|
||||||
|
# You should see something like:
|
||||||
|
# 00:02.0 VGA compatible controller: Intel Corporation ...
|
||||||
|
# 01:00.0 3D controller: NVIDIA Corporation T500 ...
|
||||||
|
|
||||||
|
# Update system.nix with correct bus IDs:
|
||||||
|
nano hosts/nixos/thinkpad/system.nix
|
||||||
|
|
||||||
|
# Find and update these lines with your actual values:
|
||||||
|
# intelBusId = "PCI:0:2:0";
|
||||||
|
# nvidiaBusId = "PCI:1:0:0";
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 9: Install NixOS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install NixOS using the flake configuration
|
||||||
|
sudo nixos-install --flake .#thinkpad
|
||||||
|
|
||||||
|
# You will be prompted to set the root password
|
||||||
|
# (You can leave it blank since we use SSH keys and sudo)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 10: Reboot
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Remove the USB drive and reboot
|
||||||
|
sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 11: Post-Installation Setup
|
||||||
|
|
||||||
|
After rebooting into your new NixOS system:
|
||||||
|
|
||||||
|
### Login
|
||||||
|
- Username: `yanlin`
|
||||||
|
- Password: Use the password you know (the hashed one in the config)
|
||||||
|
|
||||||
|
### Apply Home Manager Configuration
|
||||||
|
```bash
|
||||||
|
# Clone the config repo to your home directory
|
||||||
|
cd ~
|
||||||
|
git clone https://github.com/Logan-Lin/nix-config.git .config/nix
|
||||||
|
|
||||||
|
# Apply home-manager configuration
|
||||||
|
home-manager switch --flake ~/.config/nix#yanlin@thinkpad
|
||||||
|
```
|
||||||
|
|
||||||
|
### Verify NVIDIA Setup
|
||||||
|
```bash
|
||||||
|
# Check if NVIDIA driver is loaded
|
||||||
|
lsmod | grep nvidia
|
||||||
|
|
||||||
|
# Test NVIDIA offload
|
||||||
|
nvidia-offload glxgears
|
||||||
|
|
||||||
|
# Check GPU status
|
||||||
|
nvidia-smi
|
||||||
|
```
|
||||||
|
|
||||||
|
### Set Up Power Management
|
||||||
|
```bash
|
||||||
|
# Check TLP status
|
||||||
|
sudo tlp-stat
|
||||||
|
|
||||||
|
# Monitor battery
|
||||||
|
acpi -b
|
||||||
|
|
||||||
|
# Check CPU frequency scaling
|
||||||
|
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### WiFi Not Working
|
||||||
|
- Some ThinkPad models need newer kernel: Already using latest kernel in config
|
||||||
|
- Check if WiFi is blocked: `rfkill list`
|
||||||
|
|
||||||
|
### NVIDIA Issues
|
||||||
|
- If NVIDIA doesn't work, boot with integrated graphics only:
|
||||||
|
- Comment out the nvidia configuration in system.nix
|
||||||
|
- Rebuild: `sudo nixos-rebuild switch --flake ~/.config/nix#thinkpad`
|
||||||
|
|
||||||
|
### Display Manager Not Starting
|
||||||
|
- Switch to TTY (Ctrl+Alt+F2)
|
||||||
|
- Check logs: `journalctl -xeu display-manager`
|
||||||
|
|
||||||
|
### Battery Drain
|
||||||
|
- Ensure TLP is running: `systemctl status tlp`
|
||||||
|
- Check if NVIDIA is always on: `cat /proc/acpi/bbswitch`
|
||||||
|
- Use `powertop` to identify power-hungry processes
|
||||||
|
|
||||||
|
## Useful Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Rebuild system configuration
|
||||||
|
sudo nixos-rebuild switch --flake ~/.config/nix#thinkpad
|
||||||
|
|
||||||
|
# Rebuild home configuration
|
||||||
|
home-manager switch --flake ~/.config/nix#yanlin@thinkpad
|
||||||
|
|
||||||
|
# Update system
|
||||||
|
nix flake update ~/.config/nix
|
||||||
|
sudo nixos-rebuild switch --flake ~/.config/nix#thinkpad
|
||||||
|
|
||||||
|
# Check system health
|
||||||
|
nixos-option system.stateVersion
|
||||||
|
nix-store --verify --check-contents
|
||||||
|
|
||||||
|
# Clean up old generations
|
||||||
|
sudo nix-collect-garbage -d
|
||||||
|
```
|
||||||
|
|
||||||
|
## KDE Plasma Tips
|
||||||
|
|
||||||
|
- **Global Theme**: System Settings → Appearance → Global Theme
|
||||||
|
- **Display Configuration**: System Settings → Display and Monitor
|
||||||
|
- **Power Management**: System Settings → Power Management
|
||||||
|
- **NVIDIA Settings**: Run `nvidia-settings` from terminal or application menu
|
||||||
|
- **Virtual Desktops**: System Settings → Workspace → Virtual Desktops
|
||||||
|
|
||||||
|
## Running Applications with NVIDIA GPU
|
||||||
|
|
||||||
|
To run applications using the discrete NVIDIA GPU:
|
||||||
|
```bash
|
||||||
|
# Use the nvidia-offload command (alias: nvidia-run)
|
||||||
|
nvidia-offload firefox
|
||||||
|
nvidia-offload steam
|
||||||
|
nvidia-run blender
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- The configuration includes Firefox add-ons support for the home-manager setup
|
||||||
|
- Claude Code is available after home-manager installation
|
||||||
|
- The system is configured for maximum battery life with TLP
|
||||||
|
- NVIDIA GPU is set to power-saving offload mode by default
|
||||||
|
- KDE Plasma 6 with Wayland support is configured
|
||||||
50
hosts/nixos/thinkpad/disk-config.nix
Normal file
50
hosts/nixos/thinkpad/disk-config.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
# Disko configuration for ThinkPad P14s Gen 2
|
||||||
|
# Simple single-disk setup with EFI boot and ext4 root partition
|
||||||
|
{
|
||||||
|
disko.devices = {
|
||||||
|
disk = {
|
||||||
|
main = {
|
||||||
|
type = "disk";
|
||||||
|
# Update this to match your actual disk
|
||||||
|
# Use 'lsblk' or 'fdisk -l' to find your disk identifier
|
||||||
|
device = "/dev/nvme0n1"; # Common for NVMe SSDs in laptops
|
||||||
|
content = {
|
||||||
|
type = "gpt";
|
||||||
|
partitions = {
|
||||||
|
# EFI System Partition
|
||||||
|
ESP = {
|
||||||
|
size = "512M";
|
||||||
|
type = "EF00";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "vfat";
|
||||||
|
mountpoint = "/boot";
|
||||||
|
mountOptions = [ "defaults" "umask=0077" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Swap partition (optional, adjust size as needed)
|
||||||
|
swap = {
|
||||||
|
size = "16G"; # Match your RAM size for hibernation support
|
||||||
|
content = {
|
||||||
|
type = "swap";
|
||||||
|
randomEncryption = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Root partition - takes remaining space
|
||||||
|
root = {
|
||||||
|
size = "100%";
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
mountOptions = [ "defaults" "noatime" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
28
hosts/nixos/thinkpad/hardware-configuration.nix
Normal file
28
hosts/nixos/thinkpad/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# This file will be auto-generated by nixos-generate-config during installation
|
||||||
|
# It will contain the hardware scan results specific to your ThinkPad P14s Gen 2
|
||||||
|
#
|
||||||
|
# DO NOT EDIT this file manually before installation!
|
||||||
|
# Run 'nixos-generate-config --show-hardware-config' on the target machine
|
||||||
|
# to generate the actual hardware configuration.
|
||||||
|
|
||||||
|
{ config, lib, pkgs, modulesPath, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
# This will be populated automatically during installation
|
||||||
|
boot.initrd.availableKernelModules = [ ];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Filesystem configuration will be added here by nixos-generate-config
|
||||||
|
# based on your actual disk partitioning
|
||||||
|
|
||||||
|
# Swap configuration (if applicable) will be added here
|
||||||
|
|
||||||
|
# CPU and platform configuration will be detected and added here
|
||||||
|
|
||||||
|
# The NixOS release version will be set here
|
||||||
|
system.stateVersion = "24.05";
|
||||||
|
}
|
||||||
21
hosts/nixos/thinkpad/home.nix
Normal file
21
hosts/nixos/thinkpad/home.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
# Import the common NixOS home configuration
|
||||||
|
imports = [ ../home-default.nix ];
|
||||||
|
|
||||||
|
# Any ThinkPad-specific home configurations can be added here
|
||||||
|
# For example, laptop-specific aliases or scripts
|
||||||
|
|
||||||
|
programs.zsh.shellAliases = {
|
||||||
|
# Battery status alias
|
||||||
|
battery = "acpi -b";
|
||||||
|
|
||||||
|
# NVIDIA offload aliases for running applications on discrete GPU
|
||||||
|
nvidia-run = "nvidia-offload";
|
||||||
|
|
||||||
|
# Brightness control aliases
|
||||||
|
brightness-up = "brightnessctl set +10%";
|
||||||
|
brightness-down = "brightnessctl set 10%-";
|
||||||
|
};
|
||||||
|
}
|
||||||
296
hosts/nixos/thinkpad/system.nix
Normal file
296
hosts/nixos/thinkpad/system.nix
Normal file
|
|
@ -0,0 +1,296 @@
|
||||||
|
{ config, pkgs, lib, ... }: {
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./disk-config.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
# Bootloader - standard UEFI setup
|
||||||
|
boot.loader = {
|
||||||
|
systemd-boot.enable = true;
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
timeout = 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Use latest kernel for better hardware support
|
||||||
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||||
|
|
||||||
|
# Kernel parameters for ThinkPad
|
||||||
|
boot.kernelParams = [
|
||||||
|
# Better power management
|
||||||
|
"i915.enable_psr=1"
|
||||||
|
"i915.enable_fbc=1"
|
||||||
|
# Disable GPU power management debugging
|
||||||
|
"drm.debug=0"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enable firmware updates
|
||||||
|
services.fwupd.enable = true;
|
||||||
|
|
||||||
|
# Hardware support for ThinkPad P14s Gen 2 Intel
|
||||||
|
hardware = {
|
||||||
|
enableRedistributableFirmware = true;
|
||||||
|
cpu.intel.updateMicrocode = true;
|
||||||
|
|
||||||
|
# Graphics configuration
|
||||||
|
graphics = {
|
||||||
|
enable = true;
|
||||||
|
enable32Bit = true;
|
||||||
|
extraPackages = with pkgs; [
|
||||||
|
intel-media-driver # LIBVA_DRIVER_NAME=iHD
|
||||||
|
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but sometimes works better)
|
||||||
|
vaapiVdpau
|
||||||
|
libvdpau-va-gl
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# NVIDIA configuration (T500)
|
||||||
|
nvidia = {
|
||||||
|
# Modesetting is required for PRIME
|
||||||
|
modesetting.enable = true;
|
||||||
|
|
||||||
|
# Power management (experimental but useful for laptops)
|
||||||
|
powerManagement.enable = true;
|
||||||
|
powerManagement.finegrained = true;
|
||||||
|
|
||||||
|
# Use proprietary driver (open source doesn't support T500 well)
|
||||||
|
open = false;
|
||||||
|
|
||||||
|
# Enable nvidia-settings application
|
||||||
|
nvidiaSettings = true;
|
||||||
|
|
||||||
|
# Use production driver (more stable than latest)
|
||||||
|
package = config.boot.kernelPackages.nvidiaPackages.production;
|
||||||
|
|
||||||
|
# PRIME Offload configuration (better battery life)
|
||||||
|
prime = {
|
||||||
|
offload = {
|
||||||
|
enable = true;
|
||||||
|
enableOffloadCmd = true; # Provides nvidia-offload command
|
||||||
|
};
|
||||||
|
|
||||||
|
# Bus IDs - MUST be verified after installation with:
|
||||||
|
# lspci | grep -E 'VGA|3D'
|
||||||
|
# These are typical values but may differ
|
||||||
|
intelBusId = "PCI:0:2:0";
|
||||||
|
nvidiaBusId = "PCI:1:0:0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Bluetooth support
|
||||||
|
bluetooth = {
|
||||||
|
enable = true;
|
||||||
|
powerOnBoot = false; # Save battery
|
||||||
|
settings = {
|
||||||
|
General = {
|
||||||
|
Enable = "Source,Sink,Media,Socket";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Network configuration
|
||||||
|
networking = {
|
||||||
|
hostName = "thinkpad";
|
||||||
|
networkmanager = {
|
||||||
|
enable = true;
|
||||||
|
wifi.powersave = true;
|
||||||
|
};
|
||||||
|
firewall.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Time zone and localization
|
||||||
|
time.timeZone = "Europe/Copenhagen";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
# Sound configuration with PipeWire (better than PulseAudio)
|
||||||
|
hardware.pulseaudio.enable = false;
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
alsa.enable = true;
|
||||||
|
alsa.support32Bit = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
jack.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# KDE Plasma Desktop Environment
|
||||||
|
services.xserver = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
# Video drivers
|
||||||
|
videoDrivers = [ "modesetting" "nvidia" ];
|
||||||
|
|
||||||
|
# Display manager
|
||||||
|
displayManager.sddm = {
|
||||||
|
enable = true;
|
||||||
|
wayland.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Desktop environment
|
||||||
|
desktopManager.plasma6.enable = true;
|
||||||
|
|
||||||
|
# Keyboard layout
|
||||||
|
xkb = {
|
||||||
|
layout = "us";
|
||||||
|
variant = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Touchpad configuration
|
||||||
|
libinput = {
|
||||||
|
enable = true;
|
||||||
|
touchpad = {
|
||||||
|
naturalScrolling = true;
|
||||||
|
tapping = true;
|
||||||
|
disableWhileTyping = true;
|
||||||
|
accelProfile = "adaptive";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Power management for laptops
|
||||||
|
powerManagement = {
|
||||||
|
enable = true;
|
||||||
|
powertop.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# TLP for advanced power management
|
||||||
|
services.power-profiles-daemon.enable = false; # Conflicts with TLP
|
||||||
|
services.tlp = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
# CPU power management
|
||||||
|
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
||||||
|
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
|
||||||
|
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
||||||
|
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
|
||||||
|
|
||||||
|
# Intel GPU power management
|
||||||
|
INTEL_GPU_MIN_FREQ_ON_AC = 300;
|
||||||
|
INTEL_GPU_MIN_FREQ_ON_BAT = 300;
|
||||||
|
INTEL_GPU_MAX_FREQ_ON_AC = 1300;
|
||||||
|
INTEL_GPU_MAX_FREQ_ON_BAT = 900;
|
||||||
|
INTEL_GPU_BOOST_FREQ_ON_AC = 1300;
|
||||||
|
INTEL_GPU_BOOST_FREQ_ON_BAT = 1100;
|
||||||
|
|
||||||
|
# ThinkPad battery charge thresholds (preserve battery health)
|
||||||
|
START_CHARGE_THRESH_BAT0 = 75;
|
||||||
|
STOP_CHARGE_THRESH_BAT0 = 80;
|
||||||
|
|
||||||
|
# PCIe power management
|
||||||
|
RUNTIME_PM_ON_AC = "on";
|
||||||
|
RUNTIME_PM_ON_BAT = "auto";
|
||||||
|
|
||||||
|
# Disable Bluetooth on battery to save power
|
||||||
|
DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Thermal management
|
||||||
|
services.thermald.enable = true;
|
||||||
|
|
||||||
|
# ThinkPad specific: thinkfan for better fan control
|
||||||
|
services.thinkfan = {
|
||||||
|
enable = true;
|
||||||
|
levels = [
|
||||||
|
[0 0 42]
|
||||||
|
[1 40 47]
|
||||||
|
[2 45 52]
|
||||||
|
[3 50 57]
|
||||||
|
[4 55 62]
|
||||||
|
[5 60 72]
|
||||||
|
[7 70 82]
|
||||||
|
[127 80 32767]
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable CUPS for printing
|
||||||
|
services.printing.enable = true;
|
||||||
|
|
||||||
|
# SSH service
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
PermitRootLogin = "no";
|
||||||
|
PasswordAuthentication = false;
|
||||||
|
KbdInteractiveAuthentication = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# User account
|
||||||
|
users.users.yanlin = {
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "yanlin";
|
||||||
|
extraGroups = [ "networkmanager" "wheel" "video" "audio" "input" ];
|
||||||
|
shell = pkgs.zsh;
|
||||||
|
hashedPassword = "$6$8NUV0JK33hs3XBYe$osnYKzENDLYHQEpj8Z5F6ECpLdc8Y3RZcVGxQ0bc/6DepTwugAkfX8h6ItI01dJyk8RstiGsWVVCKGwXaL.sN.";
|
||||||
|
openssh.authorizedKeys.keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG35m0DgTrEOAM+1wAlYZ8mvLelNTcx65cFccGPQcxmo yanlin@imac"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enable sudo for wheel group
|
||||||
|
security.sudo.wheelNeedsPassword = false;
|
||||||
|
|
||||||
|
# System packages
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
# Essential tools
|
||||||
|
vim
|
||||||
|
git
|
||||||
|
wget
|
||||||
|
curl
|
||||||
|
htop
|
||||||
|
btop
|
||||||
|
neofetch
|
||||||
|
tree
|
||||||
|
unzip
|
||||||
|
|
||||||
|
# Development tools
|
||||||
|
tmux
|
||||||
|
zsh
|
||||||
|
home-manager
|
||||||
|
|
||||||
|
# KDE/Plasma utilities
|
||||||
|
kate
|
||||||
|
konsole
|
||||||
|
spectacle
|
||||||
|
filelight
|
||||||
|
ark
|
||||||
|
|
||||||
|
# System utilities
|
||||||
|
pciutils
|
||||||
|
usbutils
|
||||||
|
lshw
|
||||||
|
inxi
|
||||||
|
|
||||||
|
# GPU monitoring
|
||||||
|
nvtopPackages.nvidia
|
||||||
|
intel-gpu-tools
|
||||||
|
|
||||||
|
# Laptop utilities
|
||||||
|
brightnessctl
|
||||||
|
acpi
|
||||||
|
powertop
|
||||||
|
s-tui # Stress test and monitoring
|
||||||
|
|
||||||
|
# ThinkPad specific
|
||||||
|
lm_sensors # Temperature monitoring
|
||||||
|
];
|
||||||
|
|
||||||
|
# Enable zsh
|
||||||
|
programs.zsh.enable = true;
|
||||||
|
|
||||||
|
# Enable experimental features
|
||||||
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
|
||||||
|
# Allow unfree packages (needed for NVIDIA drivers)
|
||||||
|
nixpkgs.config.allowUnfree = true;
|
||||||
|
|
||||||
|
# Laptop-specific services
|
||||||
|
services.acpid.enable = true;
|
||||||
|
services.upower.enable = true;
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
system.stateVersion = "24.05";
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue