# NixOS-WSL Configuration for pan This is a flake-based NixOS-WSL configuration ported from the standalone Home Manager setup. It provides a declarative, reproducible system configuration with integrated Home Manager and access to the latest unstable packages. ## Structure ``` nixos/ ├── flake.nix # Flake with nixos-unstable, nixos-wsl, home-manager ├── flake.lock # Locked dependency versions (auto-generated) ├── configuration.nix # System-level NixOS-WSL configuration ├── home.nix # Home Manager user configuration ├── modules/ # User-level module configurations │ ├── sh.nix # Shell (Zsh with Prezto, fzf, zoxide) │ ├── tmux.nix # Tmux configuration │ ├── git.nix # Git, Lazygit, Jujutsu │ ├── nvim.nix # Neovim with 40+ plugins │ ├── dev.nix # Development tools │ └── task.nix # Taskwarrior, Timewarrior ├── README.md # This file ├── TODO.md # Known issues and future work ├── SUMMARY.md # Implementation overview └── MIGRATION.md # Guide for migrating from channels to flakes ``` ## Installation ### 1. Test the Configuration (Recommended First Step) Before applying, validate and test build: ```bash cd /home/pan/dev/config/dot/nix/nixos # Validate flake syntax nix flake check --impure # Test build without activating sudo nixos-rebuild build --flake .#nix --impure ``` The `--impure` flag is needed for NIX_LD settings in the home configuration. ### 2. Customize Configuration (Optional) Edit `configuration.nix` to adjust: - **Hostname**: Change `networking.hostName` (current: "nix") - **Timezone**: Change `time.timeZone` (current: "Europe/Berlin") - **WSL user**: Change `wsl.defaultUser` (current: "pan") The current settings should work for your NixOS-WSL setup. ### 3. Apply Configuration Apply the flake configuration: ```bash sudo nixos-rebuild switch --flake /home/pan/dev/config/dot/nix/nixos#nix --impure ``` Or from inside the directory: ```bash cd /home/pan/dev/config/dot/nix/nixos sudo nixos-rebuild switch --flake .#nix --impure ``` ### 4. Verify Installation After applying, verify everything works: ```bash # Check system nixos-version # Check flake info nix flake metadata /home/pan/dev/config/dot/nix/nixos # Test your tools zsh --version tmux -V nvim --version ``` ## Updating the Configuration After making changes to any configuration file: ```bash sudo nixos-rebuild switch --flake /home/pan/dev/config/dot/nix/nixos#nix --impure ``` ## Updating System Packages To update all packages to the latest versions from nixos-unstable: ```bash cd /home/pan/dev/config/dot/nix/nixos # Update flake inputs (nixpkgs, home-manager, nixos-wsl) nix flake update # Apply the updates sudo nixos-rebuild switch --flake .#nix --impure ``` View what changed: ```bash git diff flake.lock # See version bumps ``` ## Rollback ### Rollback to Previous Generation If something breaks after an update: ```bash sudo nixos-rebuild switch --rollback ``` ### List All Generations ```bash sudo nix-env --list-generations --profile /nix/var/nix/profiles/system ``` ### Switch to Specific Generation ```bash sudo nixos-rebuild switch --switch-generation ``` ### Rollback from Boot Menu At boot time, select "NixOS - All configurations" to see all previous generations and boot into any of them. ## Differences from Original Ubuntu Configuration ### Removed Features - **macOS/Darwin support**: All nix-darwin references removed - **WSL-specific paths**: Hard-coded Windows paths in tmux configuration removed - **Platform conditionals**: Darwin and Windows checks cleaned up ### System-Level Changes - **User management**: User `pan` is now defined at the system level - **Boot configuration**: Bootloader settings added - **Networking**: NetworkManager enabled for network management - **Zsh**: Enabled system-wide (configured via Home Manager) ### Custom Packages Status The following custom packages from the original configuration are currently commented out in `modules/dev.nix`: - `claude-code` - `opencode` - `gemini-cli` See [TODO.md](TODO.md) for information on integrating these packages. ## Verification After Installation ### Test Shell Environment ```bash # Verify zsh is running echo $SHELL # Test fzf (Ctrl+R for history search) # Test zoxide z /path/to/directory # Test lsd, bat lsd bat some-file ``` ### Test Tmux ```bash # Start tmux tmux new -s test # Test custom keybindings: # Alt+L/H - Next/previous window # Alt+J/K - Next/previous session # Ctrl+a + Ctrl+g - Lazygit popup ``` ### Test Neovim ```bash nvim test.nix # Inside nvim: # :LspInfo - Check LSP status # :checkhealth - Check overall health ``` ### Test Git & VCS ```bash git config --get user.name # Should be "Martin Pander" git config --get user.email # Should be "martin.pander@knowtion.de" lazygit --version jj --version ``` ### Test Taskwarrior ```bash task --version # Should be 3.x tt # taskwarrior-tui timew --version ``` ### Test Development Tools ```bash direnv --version visidata --version ``` ## Common Tasks ### Add a New Package Edit `home.nix` or the appropriate module file, then rebuild: ```bash sudo nixos-rebuild switch --flake .#nixos ``` ### Enable a System Service Edit `configuration.nix` to add the service, then rebuild: ```bash sudo nixos-rebuild switch --flake .#nixos ``` ### Cleanup Old Generations Remove old generations to free up disk space: ```bash # Delete generations older than 30 days sudo nix-collect-garbage --delete-older-than 30d # Or delete all old generations except current sudo nix-collect-garbage -d ``` ## Troubleshooting ### Build Fails Check for syntax errors: ```bash nix flake check ``` ### Services Don't Start Check service status: ```bash systemctl status journalctl -u ``` ### Home Manager Issues Rebuild Home Manager separately: ```bash home-manager switch --flake .#pan ``` ### NIX_LD Issues If you encounter issues running non-Nix binaries, check that NIX_LD variables are set: ```bash echo $NIX_LD echo $NIX_LD_LIBRARY_PATH ``` ## Resources - [NixOS Manual](https://nixos.org/manual/nixos/stable/) - [Home Manager Manual](https://nix-community.github.io/home-manager/) - [Nixpkgs Search](https://search.nixos.org/packages) - [NixOS Discourse](https://discourse.nixos.org/) ## Support For issues specific to this configuration, see the TODO.md file for known limitations and planned improvements.