Jump to content

Nix (command): Difference between revisions

From NixOS Wiki
imported>Mic92
imported>Mic92
make page links for every subcommand
Line 20: Line 20:
== Main commands ==
== Main commands ==


=== [[Nix_command/build|nix build]] ===
=== [[Nix_command/build|nix build]] ===


Build a derivation or fetch a store path.
Build a derivation or fetch a store path.


=== [[Nix_command/develop|nix develop]] ===
=== [[Nix_command/develop|nix develop]] ===


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


=== [[Nix_command/flake|nix flake]] ===
=== [[Nix_command/flake|nix flake]] ===


Manage Nix flakes.
Manage Nix flakes.


=== [[Nix_command/profile|nix profile]] ===
=== [[Nix_command/profile|nix profile]] ===
=== <code>nix profile</code> ===


manage Nix profiles
manage Nix profiles


=== <code>nix repl</code> ===
=== [[Nix_command/repl|nix repl]] ===


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


=== <code>nix run</code> ===
=== [[Nix_command/run|nix run]] ===


run a Nix application
run a Nix application


=== <code>nix search</code> ===
=== [[Nix_command/search|nix search]] ===


query available packages
query available packages


=== <code>nix shell</code> ===
=== [[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
Line 55: Line 54:
== Infrequently used commands ==
== Infrequently used commands ==


=== <code>nix copy</code> ===
=== [[Nix_command/copy|nix copy]] ===
 
copy paths between Nix stores
copy paths between Nix stores


=== <code>nix edit</code> ===
=== [[Nix_command/edit|nix edit]] ===


open the Nix expression of a Nix package in $EDITOR
open the Nix expression of a Nix package in $EDITOR


=== <code>nix eval</code> ===
=== [[Nix_command/eval|nix eval]] ===


evaluate a Nix expression
evaluate a Nix expression


=== <code>nix log</code> ===
=== [[Nix_command/log|nix log]] ===


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


=== <code>nix path-info</code> ===
=== [[Nix_command/path-info|nix path-info]] ===


query information about store paths
query information about store paths


=== <code>nix registry</code> ===
=== [[Nix_command/registry|nix registry]] ===


manage the flake registry
manage the flake registry


=== <code>nix verify</code> ===
=== [[Nix_command/verify|nix verify]] ===


verify the integrity of store paths
verify the integrity of store paths


=== <code>nix why-depends</code> ===
=== [[Nix_command/why-depends|nix why-depends]] ===


show why a package has another package in its closure
show why a package has another package in its closure
Line 89: Line 88:
== Utility/scripting commands ==
== Utility/scripting commands ==


=== <code>nix add-to-store</code> ===  
=== [[Nix_command/add-to-store|nix add-to-store]] ===


add a path to the Nix store
add a path to the Nix store


=== <code>nix cat-nar</code> ===
=== [[Nix_command/cat-nar|nix cat-nar]] ===


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


=== <code>nix cat-store</code> ===
=== [[Nix_command/cat-store|nix cat-store]] ===


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


=== <code>nix copy-sigs</code> ===
=== [[Nix_command/copy-sigs|nix copy-sigs]] ===


copy path signatures from substituters (like binary caches)
copy path signatures from substituters (like binary caches)


=== <code>nix dump-path</code> ===
=== [[Nix_command/dump-path|nix dump-path]] ===


dump a store path to stdout (in NAR format)
dump a store path to stdout (in NAR format)


=== <code>nix hash-file</code> ===
=== [[Nix_command/hash-file|nix hash-file]] ===


print cryptographic hash of the NAR serialisation of a path
print cryptographic hash of the NAR serialisation of a path


=== <code>nix hash-path</code> ===
=== [[Nix_command/hash-path|nix hash-path]] ===


print cryptographic hash of the NAR serialisation of a path
print cryptographic hash of the NAR serialisation of a path


=== <code>ls-nar</code> ===
=== [[Nix_command/ls-nar|nix ls-nar]] ===


show information about a path inside a NAR file
show information about a path inside a NAR file


=== <code>nix ls-store</code> ===
=== [[Nix_command/ls-store|nix ls-store]] ===


show information about a path in the Nix store
show information about a path in the Nix store


=== <code>nix make-content-addressable</code> ===
=== [[Nix_command/make-content-addressable|nix make-content-addressable]] ===


rewrite a path or closure to content-addressable form
rewrite a path or closure to content-addressable form


=== <code>nix optimise-store</code> ===
=== [[Nix_command/optimize-store|nix optimize-store]] ===


replace identical files in the store by hard links
replace identical files in the store by hard links


=== <code>nix ping-store</code> ===
=== [[Nix_command/ping-store|nix ping-store]] ===


test whether a store can be opened
test whether a store can be opened


=== <code>nix print-dev-env</code> ===
=== [[Nix_command/print-dev-env|nix print-dev-env]] ===


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


=== <code>nix show-config</code> ===
=== [[Nix_command/show-config|nix show-config]] ===


show the Nix configuration
show the Nix configuration


=== <code>nix show-derivation</code> ===
=== [[Nix_command/show-derivation|nix show-derivation]] ===


show the contents of a store derivation
show the contents of a store derivation


=== <code>nix sign-paths</code> ===
=== [[Nix_command/sign-paths|nix sign-paths]] ===


sign the specified paths
sign the specified paths


=== <code>nix to-base16</code> ===
=== [[Nix_command/to-base16|nix to-base16]] ===


convert a hash to base-16 representation
convert a hash to base-16 representation


=== <code>nix to-base32</code> ===
=== [[Nix_command/to-base32|nix to-base32]] ===


convert a hash to base-32 representation
convert a hash to base-32 representation


=== <code>nix to-base64</code> ===
=== [[Nix_command/to-base64|nix to-base64]] ===


convert a hash to base-64 representation
convert a hash to base-64 representation


=== <code>nix to-sri</code> ===
=== [[Nix_command/to-sri|nix to-sri]] ===


convert a hash to SRI representation
convert a hash to SRI representation

Revision as of 06:56, 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

Build a derivation or fetch a store path.

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

Manage Nix flakes.

manage Nix profiles

start an interactive environment for evaluating Nix expressions

run a Nix application

query available packages

run a shell in which the specified packages are available

Infrequently used commands

copy paths between Nix stores

open the Nix expression of a Nix package in $EDITOR

evaluate a Nix expression

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

query information about store paths

manage the flake registry

verify the integrity of store paths

show why a package has another package in its closure

Utility/scripting commands

add a path to the Nix store

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

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

copy path signatures from substituters (like binary caches)

dump a store path to stdout (in NAR format)

print cryptographic hash of the NAR serialisation of a path

print cryptographic hash of the NAR serialisation of a path

show information about a path inside a NAR file

show information about a path in the Nix store

rewrite a path or closure to content-addressable form

replace identical files in the store by hard links

test whether a store can be opened

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

show the Nix configuration

show the contents of a store derivation

sign the specified paths

convert a hash to base-16 representation

convert a hash to base-32 representation

convert a hash to base-64 representation

convert a hash to SRI representation