DEV Community

Michael "notriddle" Howell
Michael "notriddle" Howell

Posted on • Updated on

Installing Nix under WSL1

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
veslav3 profile image
Roy Honders

Damn, this actually worked, thanks! :)

Collapse
 
supersandro2000 profile image
Sandro

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

Collapse
 
brightone profile image
Oleksii Filonenko

Thanks, helped a lot!