Nix command: Difference between revisions
imported>Mic92 |
imported>Mic92 Add nix flake subcommands |
||
Line 88: | Line 88: | ||
=== <code>nix flake</code> === | === <code>nix flake</code> === | ||
=== Usage: . === | |||
<syntaxHighlight lang=console> | |||
$ nix flake COMMAND FLAGS... ARGS.. | |||
</syntaxHighlight> | |||
=== Description === | |||
Manage Nix flakes | |||
=== <code>nix flake archive</code> === | |||
Copy a flake and all its inputs to a store | |||
=== <code>nix flake check</code> === | |||
Check whether the flake evaluates and run its tests | |||
=== <code>nix flake clone</code> === | |||
Clone flake repository | |||
=== <code>nix flake info</code> === | |||
list info about a given flake | |||
=== <code>nix flake init</code> === | |||
Create a flake in the current directory from a template | |||
=== <code>nix flake list-inputs</code> === | |||
List flake inputs | |||
=== <code>nix flake new</code> === | |||
Create a flake in the specified directory from a template | |||
=== <code>nix flake show</code> === | |||
Show the outputs provided by a flake | |||
=== <code> nix flake update</code> === | |||
Update flake lock file | |||
=== <code>nix profile</code> === | === <code>nix profile</code> === |
Revision as of 23:24, 25 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
Usage
$ nix build FLAGS... INSTALLABLES...
Description
Build a derivation or fetch a store path
Examples
To build and run GNU Hello from NixOS 20.03:
$ nix build -f channel:nixos-20.03 hello; ./result/bin/hello
To build the build.x86_64-linux attribute from release.nix:
$ nix build -f release.nix build.x86_64-linux
To make a profile point at GNU Hello (what is a profile?)
$ nix build --profile /tmp/profile 'nixpkgs#hello'
nix develop
Usage
$ nix develop FLAGS... INSTALLABLE?
Description
run a bash shell that provides the build environment of a derivation.
Examples
To get the build environment of GNU hello:
$ nix develop nixpkgs#hello
To get the build environment of the default package of flake in the current directory:
$ nix develop
To store the build environment in a profile:
$ nix develop --profile /tmp/my-shell nixpkgs#hello
To use a build environment previously recorded in a profile:
$ nix develop /tmp/my-shell
nix flake
Usage: .
$ nix flake COMMAND FLAGS... ARGS..
Description
Manage Nix flakes
nix flake archive
Copy a flake and all its inputs to a store
nix flake check
Check whether the flake evaluates and run its tests
nix flake clone
Clone flake repository
nix flake info
list info about a given flake
nix flake init
Create a flake in the current directory from a template
nix flake list-inputs
List flake inputs
nix flake new
Create a flake in the specified directory from a template
nix flake show
Show the outputs provided by a flake
nix flake update
Update flake lock file
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
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 optimise-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