Nix command: Difference between revisions

From NixOS Wiki
imported>Mic92
make page links for every subcommand
imported>Mic92
Line 34: Line 34:
=== [[Nix_command/profile|nix profile]] ===
=== [[Nix_command/profile|nix profile]] ===


manage Nix profiles
Manage Nix profiles.


=== [[Nix_command/repl|nix repl]] ===
=== [[Nix_command/repl|nix repl]] ===


start an interactive environment for evaluating Nix expressions
Start an interactive environment for evaluating Nix expressions.


=== [[Nix_command/run|nix run]] ===
=== [[Nix_command/run|nix run]] ===


run a Nix application
Run a Nix application.


=== [[Nix_command/search|nix search]] ===
=== [[Nix_command/search|nix search]] ===


query available packages
Query available packages.


=== [[Nix_command/shell|nix shell]] ===
=== [[Nix_command/shell|nix shell]] ===


run a shell in which the specified packages are available
Run a shell in which the specified packages are available.


== Infrequently used commands ==
== Infrequently used commands ==

Revision as of 07:26, 26 July 2020

This article is about all nix subcommands. Its written for nix 2.4 or newer. Older nix versions might have different commands.

Enabling the nix command

In nix 2.4 the nix command must be enabled explicitly set experimental-features = nix-command in ~/.config/nix/nix.conf or system-wide in /etc/nix/nix.conf. In NixOS the latter one can be also achieved by using:

{ pkgs, ... }: {
   nix.extraOptions = ''
      experimental-features = nix-command
   '';
}

In the following we describe all sub commands of nix:

Main commands

nix build

Build a derivation or fetch a store path.

nix develop

Run a bash shell that provides the build environment of a derivation.

nix flake

Manage Nix flakes.

nix profile

Manage Nix profiles.

nix repl

Start an interactive environment for evaluating Nix expressions.

nix run

Run a Nix application.

nix search

Query available packages.

nix shell

Run a shell in which the specified packages are available.

Infrequently used commands

nix copy

copy paths between Nix stores

nix edit

open the Nix expression of a Nix package in $EDITOR

nix eval

evaluate a Nix expression

nix log

show the build log of the specified packages or paths, if available

nix path-info

query information about store paths

nix registry

manage the flake registry

nix verify

verify the integrity of store paths

nix why-depends

show why a package has another package in its closure

Utility/scripting commands

nix add-to-store

add a path to the Nix store

nix cat-nar

print the contents of a file inside a NAR file on stdout

nix cat-store

print the contents of a file in the Nix store on stdout

nix copy-sigs

copy path signatures from substituters (like binary caches)

nix dump-path

dump a store path to stdout (in NAR format)

nix hash-file

print cryptographic hash of the NAR serialisation of a path

nix hash-path

print cryptographic hash of the NAR serialisation of a path

nix ls-nar

show information about a path inside a NAR file

nix ls-store

show information about a path in the Nix store

nix make-content-addressable

rewrite a path or closure to content-addressable form

nix optimize-store

replace identical files in the store by hard links

nix ping-store

test whether a store can be opened

nix print-dev-env

print shell code that can be sourced by bash to reproduce the build environment of a derivation

nix show-config

show the Nix configuration

nix show-derivation

show the contents of a store derivation

nix sign-paths

sign the specified paths

nix to-base16

convert a hash to base-16 representation

nix to-base32

convert a hash to base-32 representation

nix to-base64

convert a hash to base-64 representation

nix to-sri

convert a hash to SRI representation