typedspace.com: tidbits on software

Nix flakes cheatsheet


Hello brave partaker.

This page aspires to hearten your travels with Nix flakes.

I'm testing these using a single user installation of nix 2.4 release candidate on GNU/Linux.

how do I run a package from the nixpkgs repository?

nix run nixpkgs#rustc -- --version

how do I open up a shell with a given package?

nix shell nixpkgs#nushell
nu --version

how do play with the nix 2.4 release on macOS without sudo?

I do not have root access on my development machine. I can still easily experiment with nix thanks to the superb tool lima. If you do have root access, I recommend installing nix directly on macOS. Otherwise, use lima!

A basic recipe:

  1. brew install lima
  2. Follow lima's getting started documentation to provision a Linux environment
  3. Open a shell in that machine, then install nix
curl -L https://nixos.org/nix/install | sh

If you use an image like alpine you need to add curl and xz:

sudo apk add -U curl xz

You'll also need to bind mount /nix to leverage the host machine's disk. Otherwise /nix/store fills up the default 2GB quickly! See the maintainer's advice here