Skip to content

Get up to speed with NixOS on WSL2 with the VSCode Nix IDE.

License

Notifications You must be signed in to change notification settings

erwinkramer/xnos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS VSCode Speedrun 🏁

CC BY-NC-SA 4.0 GitHub commit activity

xnos

Introduction

Get up to speed with NixOS on WSL2 with the VSCode Nix IDE.

In principle very similar to nixos-wsl-starter, but this one is focused on VSCode development.

Basics

🏃 Clone this repo.

🏃 Download the WSL compatible tar.gz at NixOS-WSL to the root of the cloned repo.

🏃 Install WSL (if not installed yet):

wsl --install

🏃 Import the tar.gz into the OS folder in this repo:

wsl --import NixOS ./OS nixos-wsl.tar.gz --version 2

🏃 Set as default distro and get the shell:

wsl -s NixOS #default distribution
wsl -d NixOS #get a shell

🏃 Rebuild with the included flake (using this path notation to support git integration):

sudo nixos-rebuild --flake path://$PWD/Config/.#myhostyolo switch -L

The first time you rebuild you get a Error: Failed to open dbus connection message because it actually upgraded NixOS as well, this is expected.

🏃 Enter your IDE environment in NixOS with Command Palette: WSL: Reopen Folder in WSL and select NixOS.

🏃 Install the recommended VSCode extensions as requested in the pop-up message. (this is a one time install, it actually preserves the extensions on reboot/rebuilds)

🏁🏁🏁 You're done (or ready for action) ! 🏁🏁🏁

🏃 Go back with Command Palette: WSL: Reopen Folder in Windows.

🏃 Clean up old generations and artifacts:

sudo nix-collect-garbage --delete-old

🏃 Complete teardown:

wsl --unregister NixOS

Arion

Arion is a tool for building and running applications that consist of multiple docker containers using NixOS modules.

🏃 Configure WSL globally to free up port 53 (DNS), use the following configuration:

[wsl2]
localhostForwarding = true
networkingMode = NAT
dnsProxy = true
firewall = true
dnsTunneling = false

🏃 Reboot NixOS and start the container(s):

cd ./config
sudo arion up -d
sudo arion logs -f

🏃 Open dozzle:

http://127.0.0.1:8080/

🏃 Use CoreDNS via TCP, since UDP traffic isn't supported on WSL2. Run this on your host:

nslookup -vc nu.locali 127.0.0.1

This should return the following, as specified by the Corefile:

Name:    nu.locali
Address:  127.0.0.1

To Azure

🏃 Get the WSL2 shell again:

wsl -d NixOS #get a shell

🏃 Clone erwinkramer/nixos-on-azure, this repo is forked from rudesome/nixos-on-azure but I added Arion as a NixOS module with dozzle.

🏃 Follow the steps specified in the README of nixos-on-azure.

🏃 Now manage your fleet! Try:

Considerations

VSCode extensions ideally should be installed via NixOS itself, but no native way is found. Please see discussion @ discourse.nixos.org as well.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

About

Get up to speed with NixOS on WSL2 with the VSCode Nix IDE.

Topics

Resources

License

Stars

Watchers

Forks

Languages