Skip to content

Instantly share code, notes, and snippets.

@ruandre
Last active August 28, 2023 20:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruandre/2d5618ce5be5123462300c7f418536e2 to your computer and use it in GitHub Desktop.
Save ruandre/2d5618ce5be5123462300c7f418536e2 to your computer and use it in GitHub Desktop.
Nix on WSL Debian/Ubuntu

Nix on WSL Debian/Ubuntu

Prep

Install these if not already available:

sudo apt install curl xz-utils

OR using build-essential (includes gcc, xz-utils, etc.)

sudo apt install curl build-essential

Steps

sudo mkdir /nix
sudo chown username /nix # replace `username` with your own

sh <(curl -L https://nixos.org/nix/install) --no-daemon

nix-env -i hello # install to test
nix-env --uninstall hello # remove test

Tips

# see https://search.nixos.org/packages
nix-env -qa > nix-packages.list

# see https://nixos.org/nix/manual
nix-env -i neovim # example install

# optimise store
nix-store --optimise -v

Auto-optimise store when writing new files to it:

mkdir -p ~/.config/nix

echo "auto-optimise-store = true" >> ~/.config/nix/nix.conf

Aliases

Faster to type:

alias nxi='nix-env -i'  # install
alias nxu='nix-env -u'  # update
alias nxr='nix-env -e'  # remove
alias nxls='nix-env -q' # list
alias nxgc='nix-collect-garbage -d'

Source

https://ariya.io/2020/05/nix-package-manager-on-ubuntu-or-debian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment