nix-store.3
Manage files in the Nix store
TLDR
Collect garbage, i.e. remove unused paths to reduce space usage
Hard-link identical files together to reduce space usage
Delete a specific store path (most be unused)
List a contents of the store path, on a remote store
Show the differences in versions between two store paths, with their respective dependencies
SYNOPSIS
nix-store option...
PARAMETERS
--add-fixed algo hash path
Add a file to the store and associate it with a fixed-output derivation. algo must be `sha256`, `sha512`, `sha1`, `md5`, or `none`. `hash` is the expected hash of the file, and `path` is the path to the file. Used in fixed-output derivations.
--add-indirect path
Add a file to the store indirectly (without hashing it, useful for large immutable files).
--check-validity path...
Check if the given store paths are valid (i.e., exist in the store).
--copy path... --to machine
Copy the specified store paths to another machine. machine must be a valid remote specification, such as `ssh://user@host`.
--delete path...
Delete the specified store paths from the store. Dangerous operation!
--dump-db
Dump the contents of the Nix store database to standard output. Useful for debugging.
--gc
Perform garbage collection on the Nix store, removing unreferenced store paths.
--help
Show help message.
--import path
Import a store from a binary cache or another store.
--inspect attribute path
Inspect the attribute of given store path. attribute can be 'refs', 'deriver', 'signatures', 'trust', 'ca', 'size' , 'registration-time'.
--query what path...
Query information about store paths. Possible values for what include: 'path-info', 'references', 'referrers', 'derivation', 'validity', 'size', 'registration-time', 'narinfo', 'ca', 'hash', 'outputs', 'log', 'type', 'signatures', 'trust', 'ultimate'.
--realise path...
Realize the specified derivations, i.e., build them. It forces the execution of the nix build process.
--verify-path path...
Check whether given path is valid and whether the path can be built and if hash matches.
DESCRIPTION
The `nix-store` command is a fundamental tool in the Nix package manager ecosystem. It provides a low-level interface for interacting directly with the Nix store, the central repository where all packages and dependencies are stored. It allows users to query information about store paths, realize derivations (build packages), copy store paths between machines, and perform other store-related operations.
Its operations are quite varied, and it is mainly used by nix internals like the nix daemon and nix build. Most user's won't use it directly except for specific niche cases. It is essential to understand that misuse can corrupt the Nix store, so caution is advised.
CAVEATS
Using `nix-store` incorrectly can corrupt your Nix store, leading to broken builds and other issues. Exercise caution, especially when deleting store paths.
NIX STORE PATHS
Nix store paths are unique identifiers for files or directories stored in the Nix store. They are typically `/nix/store/
SEE ALSO
nix(1), nix-build(1), nix-collect-garbage(1)