- Nix 100%
NixOS WSL #
Overview #
This repository provides a pre-configured NixOS development environment for WSL2, tailored for AIMMS platform development. It includes:
- NixOS 26.05 with flakes enabled
- Home Manager for user-level configuration management
- Development tools: Neovim (default editor), Git, and direnv with automatic shell activation
- Container support: Podman for containerized workflows
- Security tools: sops and age for secrets management
- nix-ld: For running non-NixOS binaries
- Automated development shells: Using direnv and flake-based environments
This configuration provides a reproducible, declarative development environment that can be version-controlled and shared across teams.
Table of Contents #
Prerequisites #
Before using this configuration, you need WSL2 and NixOS-WSL installed on your Windows machine.
Installing WSL on Windows #
Requirements:
- Windows 10 version 2004 or higher (Build 19041 or higher) or Windows 11
- Administrator access to your Windows machine
Installation Steps:
Method 1: Simplified Installation (Recommended) #
-
Open PowerShell or Command Prompt as Administrator
- Right-click the Start button
- Select "Windows PowerShell (Admin)" or "Terminal (Admin)"
-
Install WSL with the default Ubuntu distribution
wsl --install -
Restart your computer when prompted
Method 2: Manual Installation #
If you need more control or the simple method doesn't work:
-
Enable WSL feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -
Enable Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart -
Restart your computer
-
Download and install the WSL2 Linux kernel update package
- Download from: https://aka.ms/wsl2kernel
- Run the downloaded installer
-
Set WSL2 as the default version
wsl --set-default-version 2
Verification #
To verify WSL is installed correctly:
wsl --list --verbose
This should show your installed Linux distributions and their WSL version.
Installing NixOS-WSL #
NixOS-WSL is a port of NixOS for WSL that provides a fully functional NixOS distribution under WSL.
Requirements:
- WSL2 must be installed and enabled (see above)
- Windows 10 version 2004+ or Windows 11
Installation Steps:
Option 1: Using Pre-built Releases (Recommended) #
-
Download the latest release
- Go to NixOS-WSL Releases
- Download the
nixos-wsl.tar.gzfile from the latest release
-
Import the tarball into WSL
Open PowerShell and run:
wsl --import NixOS .\NixOS\ nixos-wsl.tar.gz --version 2Replace
.\NixOS\with your desired installation path. -
Launch NixOS
wsl -d NixOS
Option 2: Building from Source #
If you want to customize your installation or use the latest development version:
-
Clone the repository (in an existing Linux WSL distribution or on Linux):
git clone https://github.com/nix-community/NixOS-WSL.git cd NixOS-WSL -
Build the tarball
nix-build -A system -
Import into WSL (from PowerShell):
wsl --import NixOS .\NixOS\ result\tarball\nixos-wsl.tar.gz --version 2
Setting as Default Distribution (Optional) #
To make NixOS your default WSL distribution:
wsl --set-default NixOS
Using This Configuration #
Once you have NixOS-WSL installed, you can apply this repository's configuration to set up your development environment.
Quick Start #
-
Clone this repository
Inside your NixOS-WSL terminal:
git clone https://gitlab.aimms.com/aimms/platform/nix-wsl.git cd nix-wsl -
Apply the configuration
From the cloned repository directory:
nixos-rebuild switch --option extra-experimental-features pipe-operators --flake .# --sudoThis will:
- Build the NixOS configuration with all specified packages
- Set up home-manager for user configuration
- Enable flakes and experimental Nix features
- Configure direnv for automatic development shell activation
-
Start using your environment
Open a new terminal or source your bashrc:
source ~/.bashrc -
Register the MCP server with Claude Code (one-time)
Register the NixOS MCP server with Claude Code:
claude mcp add --scope user nixos mcp-nixosRegister the codebase-memory-mcp server globally with Claude Code:
claude mcp add --scope user codebase-memory-mcp codebase-memory-mcpRegister the Playwright MCP server globally with Claude Code:
claude mcp add --scope user playwright playwright-mcp-fixed(
playwright-mcp-fixed, not bareplaywright-mcp— the bare binary crashes on every browser call; seeCLAUDE.md→ "Playwright MCP Server" for why.) Verify inside Claude Code with/mcp— thenixos,codebase-memory-mcp, andplaywrightserver should appear connected.
What Gets Installed #
After applying this configuration, your system will have:
- Editor: Neovim (with vi/vim aliases, Node.js, Python, Ruby support)
- Containers: Podman with default network and DNS
- Shell tools: Bash with direnv integration
- Development: Git, wget, sops, age
- Nix features: Flakes, recursive-nix, nix-ld for binary compatibility
- AI tooling: mcp-nixos — MCP server for real-time NixOS package/option queries in Claude Code; codebase-memory-mcp — MCP server for codebase knowledge-graph queries in Claude Code; playwright-mcp — MCP server for browser automation in Claude Code
Configuration Files #
You can customize this configuration by editing:
-
configuration.nix: System-level settings
- Podman configuration
- Neovim and other system programs
- nix-ld for binary compatibility
- Experimental Nix features
-
home.nix: User-level settings (via Home Manager)
- User packages (wget, sops, age)
- Git and Bash configuration
- direnv integration
-
flake.nix: Flake configuration
- NixOS and package versions (nixos-26.05)
- Home Manager integration
- Development shell with project tools (cocogitto)
After making changes, reapply the configuration:
nixos-rebuild switch --flake .# --sudo
Automated Development Shell Activation #
This repository includes automated development shell activation using direnv. When you enter the nix-wsl directory, the development environment defined in flake.nix is automatically loaded.
How It Works #
-
direnv integration: Configured in
home.nix, direnv is automatically installed and hooked into bash. -
.envrcfile: Containsuse flaketo load the development shell. -
Development shell: Defined in
flake.nix, includes tools likecocogittofor conventional commits in this project. Other projects may define different tools in their development shell definitions inflake.nix.
Verification #
After applying the configuration with
nixos-rebuild switch --flake .# --sudo
Open a new terminal or source your bashrc
source ~/.bashrc
When you enter the nix-wsl directory, direnv will automatically load the development environment. You can verify it's working:
Check direnv status
direnv status
Verify development tools are available
type -a cog
The cog command from cocogitto should be available without manual activation.
First Time Setup #
If this is your first time using direnv in this directory, you may need to allow it:
direnv allow
After this, the environment will load automatically whenever you enter the directory.
Reference #
Troubleshooting #
- If NixOS won't start: Try
wsl --shutdownand restart - Reset installation: Remove with
wsl --unregister NixOSand reimport - Check logs: Use
journalctl -xeinside NixOS-WSL
Useful WSL Commands #
- List installed distributions:
wsl --list --verbose - Set default distribution:
wsl --set-default <DistributionName> - Shutdown WSL:
wsl --shutdown - Update WSL:
wsl --update - Check WSL version:
wsl --version