Jump to content

Nix (command): Difference between revisions

From NixOS Wiki
imported>Mic92
imported>Mic92
Line 92: Line 92:
=== [[Nix_command/add-to-store|nix add-to-store]] ===
=== [[Nix_command/add-to-store|nix add-to-store]] ===


add a path to the Nix store
Add a path to the Nix store.


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


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


=== [[Nix_command/copy-sigs|nix copy-sigs]] ===
=== [[Nix_command/copy-sigs|nix copy-sigs]] ===


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


=== [[Nix_command/dump-path|nix dump-path]] ===
=== [[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).


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


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


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


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


=== [[Nix_command/make-content-addressable|nix make-content-addressable]] ===
=== [[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.


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


=== [[Nix_command/ping-store|nix ping-store]] ===
=== [[Nix_command/ping-store|nix ping-store]] ===


test whether a store can be opened
Test whether a store can be opened.


=== [[Nix_command/print-dev-env|nix print-dev-env]] ===
=== [[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.


=== [[Nix_command/show-config|nix show-config]] ===
=== [[Nix_command/show-config|nix show-config]] ===


show the Nix configuration
Show the Nix configuration.


=== [[Nix_command/show-derivation|nix show-derivation]] ===
=== [[Nix_command/show-derivation|nix show-derivation]] ===


show the contents of a store derivation
Show the contents of a store derivation.


=== [[Nix_command/sign-paths|nix sign-paths]] ===
=== [[Nix_command/sign-paths|nix sign-paths]] ===


sign the specified paths
Sign the specified paths.


=== [[Nix_command/to-base16|nix to-base16]] ===
=== [[Nix_command/to-base16|nix to-base16]] ===


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


=== [[Nix_command/to-base32|nix to-base32]] ===
=== [[Nix_command/to-base32|nix to-base32]] ===


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


=== [[Nix_command/to-base64|nix to-base64]] ===
=== [[Nix_command/to-base64|nix to-base64]] ===


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


=== [[Nix_command/to-sri|nix to-sri]] ===
=== [[Nix_command/to-sri|nix to-sri]] ===


convert a hash to SRI representation
Convert a hash to SRI representation.

Revision as of 08:20, 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
   '';
   # this is required until nix 2.4 is released
   nix.package = pkgs.nixUnstable;
}

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.