WSL Ubuntu Nix Setup
Setup Nix and Nix Flakes on Ubuntu WSL
WSL Ubuntu Nix Setup
Introduction
Make sure you have followed WSL Quick Setup Post first.
Nix and Nix flakes makes easier to install tools on Ubuntu. Although, not all of them work perfectly fine (I prefer to keep podman f.e. installed from apt) it makes easier to maintain the environment clean and reproducible.
- nix provides a package-manager with a unique declarative approach. Do not confuse with NixOs which is a Linux Distribution on its own.
- nix flakes provides a standard way to use nix for installing packages easily with nix files.
Install
Install nix multi-user with daemon
1
curl -L https://nixos.org/nix/install | sh -s -- --daemon
Log out, wait at least 8 seconds and log in again
1
2
3
4
5
exit
wsl -t Ubuntu
# wait at least 8 seconds
wsl -d Ubuntu
Enable Flakes
Enable flakes by creating ~/.config/nix/nix.conf
1
2
mkdir -p ~/.config/nix/
touch ~/.config/nix/nix.conf
Add to ~/.config/nix/nix.conf the following (run code ~/.config/nix/nix.conf)
1
experimental-features = nix-command flakes
Check nix flakes works
1
2
3
4
5
nix flake --help
nix run nixpkgs#hello
# Hello, World!
This post is licensed under CC BY 4.0 by the author.
