# ThinkPad NixOS Installation Guide This guide provides step-by-step instructions for installing the NixOS configuration on your ThinkPad laptop. ## Prerequisites - **ThinkPad laptop** (tested models: T480, T490, X1 Carbon) - **USB flash drive** (8GB+ recommended) - **Backup your data** - this will erase everything on the target device - **NixOS ISO** - Download from [nixos.org](https://nixos.org/download.html) - **Internet connection** (wired recommended for initial setup) ## Preparation ### 1. Create NixOS Installation Media ```bash # On another Linux machine or macOS: sudo dd if=nixos-minimal-*.iso of=/dev/sdX bs=4M status=progress oflag=sync # Replace /dev/sdX with your USB device (e.g., /dev/sdb) # WARNING: This will erase the target device completely ``` ### 2. Boot from USB 1. Insert USB drive into ThinkPad 2. Power on and press **F12** to enter boot menu 3. Select the USB drive 4. At GRUB menu, select "NixOS" ## Installation Steps ### 3. Prepare Disks ```bash # Identify your disk (likely /dev/nvme0n1 for NVMe SSDs) lsblk # Partition the disk (adjust for your needs) sudo gdisk /dev/nvme0n1 # Use: o (create new GPT), n (new partition), accept defaults for EFI (512M), then Linux filesystem (rest) # Set type for EFI to EF00, Linux filesystem to 8300 # Write changes with w ``` ### 4. Format Partitions ```bash # Format EFI partition sudo mkfs.fat -F32 /dev/nvme0n1p1 # Format root partition sudo mkfs.ext4 /dev/nvme0n1p2 # Mount partitions sudo mount /dev/nvme0n1p2 /mnt sudo mkdir -p /mnt/boot/efi sudo mount /dev/nvme0n1p1 /mnt/boot/efi ``` ### 5. Generate NixOS Configuration ```bash # Generate initial configuration sudo nixos-generate-config --root /mnt # This creates /mnt/etc/nixos/configuration.nix and hardware-configuration.nix ``` ### 6. Clone Your Nixy Configuration ```bash # Clone your nixy repository sudo nix-shell -p git git clone https://gitea.doomlabs.de/KptltD00M/nixy.git /mnt/etc/nixos/nixy cd /mnt/etc/nixos/nixy # Copy hardware configuration sudo cp /mnt/etc/nixos/hardware-configuration.nix hosts/laptop/hardware-configuration.nix ``` ### 7. Install NixOS ```bash # Switch to your laptop configuration sudo nixos-install --flake /mnt/etc/nixos/nixy#laptop # When prompted, set a root password ``` ### 8. Post-Installation ```bash # After reboot, log in as root # Clone your configuration to your user git clone https://gitea.doomlabs.de/KptltD00M/nixy.git ~/nixy cd ~/nixy # Switch to your user configuration nix run nixpkgs#home-manager -- switch --flake .#andi@laptop # Reboot reboot ``` ## ThinkPad-Specific Configuration ### 1. Trackpad Configuration The configuration includes touchpad settings optimized for ThinkPad hardware. If you need to adjust: ```nix # Edit hosts/laptop/home.nix programs.hyprland = { touchpad = { naturalScroll = true; tap-to-click = true; disableWhileTyping = false; }; }; ``` ### 2. Keyboard Backlight ```bash # Enable keyboard backlight control sudo nix-env -iA nixos.hid-tools sudo systemctl enable --now thinkpad-keyboard-backlight.service ``` ### 3. Power Management ```bash # Install TLP for better power management sudo nix-env -iA nixos.tlp sudo systemctl enable --now tlp ``` ## Troubleshooting ### Common Issues **1. WiFi not working:** ```bash # Install firmware for your WiFi card sudo nix-env -iA nixos.firmware ``` **2. Suspend/resume issues:** ```bash # Edit hardware-configuration.nix boot.kernelPackages = pkgs.linuxPackages_latest; ``` **3. Screen tearing:** ```bash # Enable TearFree in hosts/laptop/configuration.nix services.xserver.videoDrivers = [ "modesetting" ]; ``` ### Debugging Commands ```bash # Check hardware detection sudo dmesg | grep -i thinkpad # Check battery status upower -i /org/freedesktop/UPower/devices/battery_BAT0 # Check display configuration hyprctl monitors ``` ## Maintenance ### Updating Your System ```bash # Update flake inputs nix flake update # Rebuild system sudo nixos-rebuild switch --flake ~/nixy#laptop # Rebuild home configuration nix run nixpkgs#home-manager -- switch --flake ~/nixy#andi@laptop ``` ### Backup Configuration ```bash # Backup your hardware configuration cp /etc/nixos/hardware-configuration.nix ~/nixy/hosts/laptop/ # Commit changes cd ~/nixy git add . git commit -m "Update hardware config for ThinkPad" git push ``` ## Additional Resources - [NixOS Manual](https://nixos.org/manual/nixos/stable/) - [ThinkPad Wiki](https://www.thinkwiki.org/) - [NixOS Discourse](https://discourse.nixos.org/) ## Notes - **ThinkPad T480/X1 Carbon specific:** These models have excellent Linux support. The configuration includes: - Trackpoint acceleration settings - Keyboard backlight control - Power management profiles - Display brightness controls - Suspend/resume fixes - **Encryption:** If you enabled encryption during install, use: ```bash sudo cryptsetup luksOpen /dev/nvme0n1p2 cryptroot sudo mount /dev/mapper/cryptroot /mnt ``` - **Multi-boot:** If dual-booting with Windows, ensure Secure Boot is disabled in BIOS.