Jump to content

Nix (command): Difference between revisions

From NixOS Wiki
imported>Mic92
imported>Mic92
Line 56: Line 56:
=== [[Nix_command/copy|nix copy]] ===
=== [[Nix_command/copy|nix copy]] ===


copy paths between Nix stores
Copy paths between Nix stores.


=== [[Nix_command/edit|nix edit]] ===
=== [[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.


=== [[Nix_command/eval|nix eval]] ===
=== [[Nix_command/eval|nix eval]] ===


evaluate a Nix expression
Evaluate a Nix expression.


=== [[Nix_command/log|nix log]] ===
=== [[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.


=== [[Nix_command/path-info|nix path-info]] ===
=== [[Nix_command/path-info|nix path-info]] ===


query information about store paths
Query information about store paths.


=== [[Nix_command/registry|nix registry]] ===
=== [[Nix_command/registry|nix registry]] ===


manage the flake registry
Manage the flake registry.


=== [[Nix_command/verify|nix verify]] ===
=== [[Nix_command/verify|nix verify]] ===


verify the integrity of store paths
Verify the integrity of store paths.


=== [[Nix_command/why-depends|nix why-depends]] ===
=== [[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.


== Utility/scripting commands ==
== Utility/scripting commands ==

Revision as of 07:34, 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