Skip to content

Essential Nix Commands

sh
# Run a package provided in a flake
nix run 'nixpkgs#hello'

# Enter a shell provided by a flake
nix develop 'nixpkgs#hello'

# Show what's inside the flake.nix
nix flake show

# Checking the correctness of a flake
nix flake check
# Run a package provided in a flake
nix run 'nixpkgs#hello'

# Enter a shell provided by a flake
nix develop 'nixpkgs#hello'

# Show what's inside the flake.nix
nix flake show

# Checking the correctness of a flake
nix flake check

nix build

Build derivations from local or remote flakes. To understand how to format these commands read about Nix Installables and Nix Flake References.

sh
# Build a specific derivation from the 'flake.nix' in current directory
nix build ".#derivation-name"

# Build a derivation from a flake in your filesystem
nix build "/home/braden/foo/bar#derivation-name"

# Build a docker image from a flake in a git repo on 'feature-branch'
nix build "git+ssh://gitlab.com/braden/foo/bar.git?ref=feature-branch#docker-image"
# Build a specific derivation from the 'flake.nix' in current directory
nix build ".#derivation-name"

# Build a derivation from a flake in your filesystem
nix build "/home/braden/foo/bar#derivation-name"

# Build a docker image from a flake in a git repo on 'feature-branch'
nix build "git+ssh://gitlab.com/braden/foo/bar.git?ref=feature-branch#docker-image"