loading...

Installing Nix under WSL

notriddle profile image Michael "notriddle" Howell Updated on ・1 min read

I'm administering Linux servers while using Windows as my desktop, and am working on a test deployment using NixOS. I ran into a few problems trying to run it locally.

Before trying to run the Nix Package Manager installer script, make a directory /etc/nix and write the following text into /etc/nix/nix.conf:

# Work around missing cgroups support https://github.com/Microsoft/WSL/issues/994
sandbox = false
# Work around incorrect file locking https://github.com/Microsoft/WSL/issues/2395
use-sqlite-wal = false

Work around missing cgroups support

The Nix sandbox relies on container functionality that Windows doesn't implement yet for the Linux personality. If you don't turn off the sandbox, you'll get this error.

error: cloning builder process: Invalid argument
error: unable to start build process

Work around incorrect file locking

The lock handling in Windows NT doesn't perfectly match Linux's. While SQLite works fine under the Win32 personality, it produces deadlocks when you try to install Nix, producing this infinite warning loop:

warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)

Posted on by:

Discussion

markdown guide
 

Damn, this actually worked, thanks! :)

 

Windows 10 20.04 Supports sandboxing and it is required to install some packages like bash-language-server.