NIX-STORE-VERIFY(1)
๐ nix-store --verify โ check Nix database for consistency ๐
okay bestie, welcome to the nix-store --verify(1) page โ this is the General Commands Manual energy, and we are getting into it ๐
โจ Name โจ
nix-store --verify โ check Nix database for consistency ๐
๐ธ Synopsis ๐ธ
nix-store --verify [--check-contents] [--repair]
๐ Description ๐
okay so the --verify operation does a whole vibe check on your Nix setup, and it's checking two things at once, no cap:
- the internal consistency of the Nix database, and
- the consistency between the Nix database and the Nix store ๐ฆ
and here's the slay part: any inconsistencies it runs into? automatically repaired. it just handles it, periodt.
where do these inconsistencies even come from, you ask? typically they're the result of the Nix store or the database getting modified by non-Nix tools (rude ๐ญ), or from bugs in Nix itself. iykyk.
This operation has the following options:
--check-contentsโ checks that the contents of every valid store path has not been altered by computing a SHA-256 hash of the contents and comparing it with the hash stored in the Nix database at build time ๐ฅ Paths that have been modified are printed out. and listen, for large stores,--check-contentsis obviously quite slow. like, obviously. so be patient bestie ๐ธ--repairโ if any valid path is missing from the store, or (if--check-contentsis given) the contents of a valid path has been modified, then it tries to repair the path by redownloading it โจ Seenix-store --repair-pathfor details.
โญ Options โญ
the following options are allowed for all nix-store operations, but may not always have an effect. (the way that's just how it is ๐)
--add-rootpath โ causes the result of a realisation (--realiseand--force-realise) to be registered as a root of the garbage collector ๐ซถ path will be created as a symlink to the resulting store path. In addition, a uniquely named symlink to path will be created in/nix/var/nix/gcroots/auto/. For instance,
$ nix-store --add-root /home/eelco/bla/result --realise ...
$ ls -l /nix/var/nix/gcroots/auto
lrwxrwxrwx 1 ... 2005-03-13 21:10 dn54lcypm8f8... -> /home/eelco/bla/result
$ ls -l /home/eelco/bla/result
lrwxrwxrwx 1 ... 2005-03-13 21:10 /home/eelco/bla/result -> /nix/store/1r11343n6qd4...-f-spot-0.0.10
Thus, when /home/eelco/bla/result is removed, the GC root in the auto directory becomes a dangling symlink and will be ignored by the collector ๐
Warning โ ๏ธ Note that it is not possible to move or rename GC roots, since the symlink in the auto directory will still point to the old location. so like, don't try it bestie, it will not work ๐
If there are multiple results, then multiple symlinks will be created by sequentially numbering symlinks beyond the first one (e.g., foo, foo-2, foo-3, and so on) ๐
<div align="center">โ part 1 of 3, keep scrolling ๐ โ</div>
โจ COMMON OPTIONS โจ
okay so bestie, most Nix commands speak this same lil language of flags ๐ฌ like they all got together and agreed on a shared vibe, and these are the ones you'll keep bumping into. memorize these and you're basically fluent, no cap ๐ธ
--helpโ prints out a summary of the command syntax and then exits. that's it, that's the whole thing, iconic behaviour honestly ๐--versionโ prints out the Nix version number on standard output and exits. quick lil flex.--verbose,-vโ bumps UP the level of verbosity of diagnostic messages printed on standard error. here's the deal bestie: for each Nix operation, the info printed on standard output is well-defined โ any diagnostic info goes to standard error, never on standard output. so stdout stays clean, stderr is where the yapping lives ๐ฃ๏ธ
this option can be specified repeatedly (so you can stack it like -vv). right now these are the verbosity levels that exist:
0"Errors only" โ only prints messages explaining why the Nix invocation failed ๐ญ1"Informational" โ prints useful messages about what Nix is doing. this one is the default โจ2"Talkative" โ prints more informational messages3"Chatty" โ prints even more informational messages4"Debug" โ prints debug information5"Vomit" โ prints vast amounts of debug information ๐คข (the name is not a joke, it is accurate)
--quietโ turns the verbosity of diagnostic messages on standard error DOWN. this is the inverse option to-v/--verbose. yeah it's the opposite-gender bestie of-v๐ซถ
this option can also be specified repeatedly, and it walks back through those same verbosity levels listed above.
--log-formatformat โ changes the output of the log format, where format is one of:rawโ the raw format, as outputted bynix-buildinternal-jsonโ outputs the logs in a structured manner
โ ๏ธ Warning: while the schema itself is relatively stable, the format of the error-messages (namely of the msg-field) can change between releases. so like... don't hardcode against the vibes of that field, bestie ๐ฌ
barโ only display a progress bar during the buildsbar-with-logsโ display the raw logs, with the progress bar at the bottom โจ
--no-build-output,-Qโ by default, output written by builders to standard output and standard error gets echoed to the Nix command's standard error. this option suppresses that behaviour. note that the builder's standard output and error are always written to a log file inprefix/nix/var/log/nix. so nothing gets lost, it's just not shouted at you ๐--max-jobs,-jnumber โ sets the maximum number of build jobs Nix will do in parallel to number. sayautoto use the number of CPUs in the system ๐ the default is specified by themax-jobsconfiguration setting, which itself defaults to1. a higher value is useful on SMP systems or to exploit I/O latency. setting it to0disallows building on the local machine, which is useful when you want builds to happen only on remote builders ๐ฐ๏ธ--coresโ sets the value of theNIX_BUILD_CORESenvironment variable in the invocation of builders. builders can use this variable at their discretion to control the maximum amount of parallelism. for instance, in Nixpkgs, if the derivation attributeenableParallelBuildingis set totrue, the builder passes the-jNflag to GNU Make ๐๏ธ it defaults to the value of thecoresconfiguration setting, if set, or1otherwise. the value0means the builder should use all available CPU cores in the system ๐ฅ--max-silent-timeโ sets the maximum number of seconds a builder can go without producing any data on standard output or standard error. the default is specified by themax-silent-timeconfiguration setting.0means no time-out โฐ--timeoutโ sets the maximum number of seconds a builder can run. the default is specified by thetimeoutconfiguration setting.0means no timeout โณ--keep-going,-kโ keep going in case of failed builds, to the greatest extent possible. that means if building an input of some derivation fails, Nix will still build the other inputs, but not the derivation itself. without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds) ๐--keep-failed,-Kโ says that in case of a build failure, the temporary directory (usually in/tmp) in which the build takes place should not be deleted. the path of the build directory is printed as an informational message ๐ฉน so you can go investigate the crime scene.--fallbackโ whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation instead.
the most common scenario where this is useful is when we have registered substitutes in order to perform binary distribution from, say, a network repository ๐ if the repository is down, the realisation of the derivation will fail. when this option is specified, Nix will build the derivation instead. so installation from binaries falls back on installation from source. this option is not the default since it's generally not desirable for a transient failure in obtaining the substitutes to lead to a full build from source (with the related consumption of resources). like yes bestie it's a glow-up but it's an expensive one ๐ธ
--readonly-modeโ when this option is used, no attempt is made to open the Nix database. most Nix operations do need database access, so those operations will fail ๐ซ๐๏ธ--argname value โ this option is accepted bynix-env,nix-instantiate,nix-shellandnix-build. when evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. it can automatically call functions for which every argument has a default value (e.g.,{ argName ? defaultValue }: ...).
with --arg, you can also call functions that have arguments without a default value (or override a default value). that is, if the evaluator encounters a function with an argument named name, it will call it with value value.
for instance, the top-level default.nix in Nixpkgs is actually a function:
{ # The system (e.g., `i686-linux') for which to build the packages.
system ? builtins.currentSystem
...
}: ...
so if you call this Nix expression (e.g., when you do nix-env --install --attr pkgname), the function will be called automatically using the value builtins.currentSystem for the system argument. you can override this using --arg, e.g., nix-env --install --attr pkgname --arg system \"i686-freebsd\". (note that since the argument is a Nix string literal, you have to escape the quotes.) ๐ฎโ๐จ
--arg-from-filename path โ pass the contents of file path as the argument name to Nix functions ๐--arg-from-stdinname โ pass the contents of stdin as the argument name to Nix functions ๐ฅ--argstrname value โ this one is like--arg, only the value is not a Nix expression but a string. so instead of--arg system \"i686-linux\"(the outer quotes are there to keep the shell happy) you can just say--argstr system i686-linux๐ so much chiller--attr,-AattrPath โ select an attribute from the top-level Nix expression being evaluated. (nix-env,nix-instantiate,nix-buildandnix-shellonly.) the attribute path attrPath is a sequence of attribute names separated by dots. for instance, given a top-level Nix expression e, the attribute pathxorg.xorgserverwould cause the expressione.xorg.xorgserverto be used. seenix-env --installfor some concrete examples.
in addition to attribute names, you can also specify array indices ๐ for instance, the attribute path foo.3.bar selects the bar attribute of the fourth element of the array in the foo attribute of the top-level expression. (yes bestie, 3 means fourth, that's just how it is, zero-indexed broke the group chat)
--eval-storestore-url โ the URL to the Nix store to use for evaluation, i.e. where to store derivations (.drvfiles) and inputs referenced by them ๐๏ธ--expr,-Eโ interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (nix-instantiate,nix-buildandnix-shellonly.)
for nix-shell, this option is commonly used to give you a shell in which you can build the packages returned by the expression. if you want to get a shell which contain the built packages ready for use, give your expression to the nix-shell --packages convenience flag instead ๐โจ
-I,--includepath โ add an entry to the list of search paths used to resolve lookup paths ๐ this option may be given multiple times. paths added through-Itake precedence over thenix-pathconfiguration setting and theNIX_PATHenvironment variable ๐--impureโ allow access to mutable paths and repositories ๐--optionname value โ set the Nix configuration option name to value. this overrides settings in the Nix configuration file (seenix.conf(5)) โ๏ธ--repairโ fix corrupted or missing store paths by redownloading or rebuilding them ๐ note that this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build. also note the warning undernix-store --repair-pathโ ๏ธ
๐ Note: see man nix.conf for overriding configuration settings with command line flags. iykyk ๐
โจ Common Environment Variables โจ
ok so most Nix commands are out here reading env vars like it's their whole personality, so bestie you need to know them ๐
๐ ๏ธ Configuration environment variables
These cuties control how Nix loads up its configuration. For the full tea, go look at the configuration file documentation. ๐
NIX_CONF_DIRโ overrides where the system configuration directory lives.NIX_USER_CONF_FILESโ overrides where the user configuration files live.NIX_CONFIGโ lets you just... hand Nix its configuration settings inline. no file needed. slay โจ
๐ฌ Store setting environment variables
NIX_IGNORE_SYMLINK_STOREโ okay so normally the Nix store directory (usually/nix/store) is not allowed to have any symlink components in it. why? to stop "impure" builds, periodt. the thing is, builders sometimes "canonicalise" paths by resolving every symlink component, so builds on different machines (where/nix/storeresolves to different places) could give you different results ๐ญ. normally that's whatever, EXCEPT when builds get deployed to machines where/nix/storeresolves differently. if you're 100% sure you're never gonna do that, setNIX_IGNORE_SYMLINK_STOREto1.
also heads up: if you're symlinking the Nix store to shove it on a different filesystem than root, on Linux you're way better off using bind mount points, like:
$ mkdir /nix
$ mount -o bind /mnt/otherdisk/nix /nix
go read the mount 8 manual page for the details, bestie.
NIX_STORE_DIRโ overrides where the Nix store lives. on Unix the default is/nix/store, and it's set at compile time by thelibstore:store-dirbuild option. on Windows there's no compile-time setting at all; the default is%PROGRAMDATA%\nix\store, figured out at runtime using the%PROGRAMDATA%Known Folder. ๐ช
also go peek at the Store Types chapter โ every store has a store setting that links back to this as its default.
NIX_LOG_DIRโ overrides where the Nix log directory lives. on Unix the default is/nix/var/log/nix, set at compile time by thelog-dirbuild option. on Windows, again, no compile-time setting; the default is%PROGRAMDATA%\nix\log, determined at runtime via the%PROGRAMDATA%Known Folder.
the Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted all have per-store settings that override this. ๐
NIX_STATE_DIRโ overrides where the Nix state directory lives. on Unix the default is${localstatedir}/nix, wherelocalstatediris a compile-time build option that defaults to/nix/var. on Windows there's no compile-time setting; the default is%PROGRAMDATA%\nix\state, determined at runtime using the%PROGRAMDATA%Known Folder.
same deal as above: the Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted have per-store settings that override this. ๐
NIX_DAEMON_SOCKET_PATHโ overrides the path to the Unix domain socket that talks to the Nix daemon. defaults todaemon-socket/socketinside the state directory (seeNIX_STATE_DIR).
check the Local Daemon Store documentation for how the socket path actually gets resolved. ๐
TMPDIRโ use this directory for temporary files. yes, this includes temporary build directories, and those can eat substantial amounts of disk space, no cap. default is/tmp.NIX_REMOTEโ overrides the store setting.
๐ง Nix language evaluator settings
NIX_SHOW_STATSโ set it to1and Nix prints out some evaluation statistics, like how many values got allocated. numbers go brrr ๐NIX_COUNT_CALLSโ set it to1and Nix tells you how often functions got called during Nix expression evaluation. genuinely so useful for profiling your Nix expressions.GC_INITIAL_HEAP_SIZEโ if Nix was configured to use the Boehm garbage collector, this sets the initial heap size in bytes. default is384 MiB. setting it low = less memory used but longer runtime, because garbage collection overhead is always lurking ๐NIX_PATHโ a colon-separated list of search path entries used to resolve lookup paths.
this env var overrides whatever the nix-path configuration setting says.
you can also extend it with the -I option. ๐ซถ
Example $ export NIX_PATH=/home/eelco/Dev:nixos-config=/etc/nixos
and if NIX_PATH is set to an empty string, resolving search paths will always fail. iconic, honestly.
Example $ NIX_PATH= nix-instantiate --eval '<nixpkgs>' error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
๐ User Directories
Nix does per-user configuration, state, and cache directories, and these env vars let you override where each one goes:
- user configuration directory:
NIX_CONFIG_HOME - user state directory:
NIX_STATE_HOME - user cache directory:
NIX_CACHE_HOME
when you don't set them, the defaults depend on your platform:
- on Unix, it's the XDG base directories:
$XDG_CONFIG_HOME/nix,$XDG_STATE_HOME/nix,$XDG_CACHE_HOME/nix - on Windows, it's the Windows Known Folders:
%APPDATA%\nix\config,%LOCALAPPDATA%\nix\state,%LOCALAPPDATA%\nix\cache
for backwards compatibility though, legacy Nix commands (hi nix-env, hi nix-channel ๐) use dotfiles in $HOME instead of these directories โ unless use-xdg-base-directories is enabled. the new Nix commands (experimental) just use the proper directories by default. glow up โจ
when use-xdg-base-directories is enabled, the configuration directory gets resolved like this:
$NIX_CONFIG_HOME, if it's defined- otherwise, the platform default (like
$XDG_CONFIG_HOME/nixon Unix)
and it's literally the same story for the state and cache directories. ๐ซ
๐ Miscellaneous environment variables
IN_NIX_SHELLโ an indicator that tells you whether the current environment was set up bynix-shell. it can have the valuespureorimpure. โจ
๐ Appendix: OS-specific conventions ๐
just so you know, none of this is Nix-specific โ it's just stuff that got referenced up above. ๐
๐ง Unix: XDG Base Directories
the XDG Base Directory Specification defines the standard locations for user-specific configuration, state, and cache files on Unix systems. ๐
these are the env vars in play:
XDG_CONFIG_HOME(default~/.config)XDG_STATE_HOME(default~/.local/state)XDG_CACHE_HOME(default~/.cache)XDG_CONFIG_DIRS(default/etc/xdg) โ a colon-separated list of additional configuration base directories, searched afterXDG_CONFIG_HOME
๐ช Windows: Known Folders
on Windows, Known Folders give you the standard locations for application data. the relevant ones are:
%APPDATA%โ per-user roaming application data%LOCALAPPDATA%โ per-user local application data%PROGRAMDATA%โ system-wide application data
and that's the whole page bestie, we ate that ๐๐ this was the nix-store --verify(1) manual, and yeah โ the footer's got the source and version plus a date stamp down there, so if you ever need to cite exactly which build of the docs you read, that's where the receipts live. go forth and verify, queen ๐๐ธ
๐ฆ where this page comes from
- fedora 44: nix-legacy 2.35.3-2.fc44 ยท LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms