Warning
This program is experimental and its interface is subject to change.
Name
nix why-depends - show why a package has another package in its closure
Synopsis
nix why-depends [option...] package dependency
Examples
-
Show one path through the dependency graph leading from Hello to Glibc:
# nix why-depends nixpkgs#hello nixpkgs#glibc /nix/store/v5sv61sszx301i0x6xysaqzla09nksnd-hello-2.10 └───bin/hello: …...................../nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/ld-linux-x86-64.… → /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32 -
Show all files and paths in the dependency graph leading from Thunderbird to libX11:
# nix why-depends --all nixpkgs#thunderbird nixpkgs#xorg.libX11 /nix/store/qfc8729nzpdln1h0hvi1ziclsl3m84sr-thunderbird-78.5.1 ├───lib/thunderbird/libxul.so: …6wrw-libxcb-1.14/lib:/nix/store/adzfjjh8w25vdr0xdx9x16ah4f5rqrw5-libX11-1.7.0/lib:/nix/store/ssf… │ → /nix/store/adzfjjh8w25vdr0xdx9x16ah4f5rqrw5-libX11-1.7.0 ├───lib/thunderbird/libxul.so: …pxyc-libXt-1.2.0/lib:/nix/store/1qj29ipxl2fyi2b13l39hdircq17gnk0-libXdamage-1.1.5/lib:/nix/store… │ → /nix/store/1qj29ipxl2fyi2b13l39hdircq17gnk0-libXdamage-1.1.5 │ ├───lib/libXdamage.so.1.1.0: …-libXfixes-5.0.3/lib:/nix/store/adzfjjh8w25vdr0xdx9x16ah4f5rqrw5-libX11-1.7.0/lib:/nix/store/9l0… │ │ → /nix/store/adzfjjh8w25vdr0xdx9x16ah4f5rqrw5-libX11-1.7.0 … -
Show why Glibc depends on itself:
# nix why-depends nixpkgs#glibc nixpkgs#glibc /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31 └───lib/ld-2.31.so: …che Do not use /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31/etc/ld.so.cache. --… → /nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31 -
Show why Geeqie has a build-time dependency on
systemd:# nix why-depends --derivation nixpkgs#geeqie nixpkgs#systemd /nix/store/drrpq2fqlrbj98bmazrnww7hm1in3wgj-geeqie-1.4.drv └───/: …atch.drv",["out"]),("/nix/store/qzh8dyq3lfbk3i1acbp7x9wh3il2imiv-gtk+3-3.24.21.drv",["dev"]),("/… → /nix/store/qzh8dyq3lfbk3i1acbp7x9wh3il2imiv-gtk+3-3.24.21.drv └───/: …16.0.drv",["dev"]),("/nix/store/8kp79fyslf3z4m3dpvlh6w46iaadz5c2-cups-2.3.3.drv",["dev"]),("/nix… → /nix/store/8kp79fyslf3z4m3dpvlh6w46iaadz5c2-cups-2.3.3.drv └───/: ….3.1.drv",["out"]),("/nix/store/yd3ihapyi5wbz1kjacq9dbkaq5v5hqjg-systemd-246.4.drv",["dev"]),("/… → /nix/store/yd3ihapyi5wbz1kjacq9dbkaq5v5hqjg-systemd-246.4.drv
Description
Nix automatically determines potential runtime dependencies between
store paths by scanning for the hash parts of store paths. For
instance, if there exists a store path
/nix/store/9df65igwjmf2wbw0gbrrgair6piqjgmi-glibc-2.31, and a file
inside another store path contains the string 9df65igw…, then the
latter store path refers to the former, and thus might need it at
runtime. Nix always maintains the existence of the transitive closure
of a store path under the references relationship; it is therefore not
possible to install a store path without having all of its references
present.
Sometimes Nix packages end up with unexpected runtime dependencies; for instance, a reference to a compiler might accidentally end up in a binary, causing the former to be in the latter's closure. This kind of closure size bloat is undesirable.
nix why-depends allows you to diagnose the cause of such issues. It
shows why the store path package depends on the store path
dependency, by showing a shortest sequence in the references graph
from the former to the latter. Also, for each node along this path, it
shows a file fragment containing a reference to the next store path in
the sequence.
To show why derivation package has a build-time rather than runtime
dependency on derivation dependency, use --derivation.
Options
-
--all/-aShow all edges in the dependency graph leading from package to dependency, rather than just a shortest path.
-
--preciseFor each edge in the dependency graph, show the files in the parent that cause the dependency.
Common evaluation options:
-
--argname exprPass the value expr as the argument name to Nix functions.
-
--argstrname stringPass the string string as the argument name to Nix functions.
-
--debuggerStart an interactive environment if evaluation fails.
-
--eval-storestore-urlThe URL of the Nix store to use for evaluation, i.e. to store derivations (
.drvfiles) and inputs referenced by them. -
--impureAllow access to mutable paths and repositories.
-
--include/-IpathAdd path to the Nix search path. The Nix search path is initialized from the colon-separated
NIX_PATHenvironment variable, and is used to look up the location of Nix expressions using paths enclosed in angle brackets (i.e.,<nixpkgs>).For instance, passing
-I /home/eelco/Dev -I /etc/nixoswill cause Nix to look for paths relative to
/home/eelco/Devand/etc/nixos, in that order. This is equivalent to setting theNIX_PATHenvironment variable to/home/eelco/Dev:/etc/nixosIt is also possible to match paths against a prefix. For example, passing
-I nixpkgs=/home/eelco/Dev/nixpkgs-branch -I /etc/nixoswill cause Nix to search for
<nixpkgs/path>in/home/eelco/Dev/nixpkgs-branch/pathand/etc/nixos/nixpkgs/path.If a path in the Nix search path starts with
http://orhttps://, it is interpreted as the URL of a tarball that will be downloaded and unpacked to a temporary location. The tarball must consist of a single top-level directory. For example, passing-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gztells Nix to download and use the current contents of the
masterbranch in thenixpkgsrepository.The URLs of the tarballs from the official
nixos.orgchannels (see the manual page fornix-channel) can be abbreviated aschannel:<channel-name>. For instance, the following two flags are equivalent:-I nixpkgs=channel:nixos-21.05 -I nixpkgs=https://nixos.org/channels/nixos-21.05/nixexprs.tar.xzYou can also fetch source trees using flake URLs and add them to the search path. For instance,
-I nixpkgs=flake:nixpkgsspecifies that the prefix
nixpkgsshall refer to the source tree downloaded from thenixpkgsentry in the flake registry. Similarly,-I nixpkgs=flake:github:NixOS/nixpkgs/nixos-22.05makes
<nixpkgs>refer to a particular branch of theNixOS/nixpkgsrepository on GitHub. -
--override-flakeoriginal-ref resolved-refOverride the flake registries, redirecting original-ref to resolved-ref.
Common flake-related options:
-
--commit-lock-fileCommit changes to the flake's lock file.
-
--inputs-fromflake-urlUse the inputs of the specified flake as registry entries.
-
--no-registriesDon't allow lookups in the flake registries. This option is deprecated; use
--no-use-registries. -
--no-update-lock-fileDo not allow any updates to the flake's lock file.
-
--no-write-lock-fileDo not write the flake's newly generated lock file.
-
--output-lock-fileflake-lock-pathWrite the given lock file instead of
flake.lockwithin the top-level flake. -
--override-inputinput-path flake-urlOverride a specific flake input (e.g.
dwarffs/nixpkgs). This implies--no-write-lock-file. -
--recreate-lock-fileRecreate the flake's lock file from scratch.
-
--reference-lock-fileflake-lock-pathRead the given lock file instead of
flake.lockwithin the top-level flake. -
--update-inputinput-pathUpdate a specific flake input (ignoring its previous entry in the lock file).
Logging-related options:
-
--debugSet the logging verbosity level to 'debug'.
-
--log-formatformatSet the format of log output; one of
raw,internal-json,barorbar-with-logs. -
--print-build-logs/-LPrint full build logs on standard error.
-
--quietDecrease the logging verbosity level.
-
--verbose/-vIncrease the logging verbosity level.
Miscellaneous global options:
-
--helpShow usage information.
-
--offlineDisable substituters and consider all previously downloaded files up-to-date.
-
--optionname valueSet the Nix configuration setting name to value (overriding
nix.conf). -
--refreshConsider all previously downloaded files out-of-date.
-
--repairDuring evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
-
--versionShow version information.
Options that change the interpretation of installables:
-
--derivationOperate on the store derivation rather than its outputs.
-
--exprexprInterpret installables as attribute paths relative to the Nix expression expr.
-
--file/-ffileInterpret installables as attribute paths relative to the Nix expression stored in file. If file is the character -, then a Nix expression will be read from standard input. Implies
--impure.
Options to override configuration settings:
-
--accept-flake-configEnable the
accept-flake-configsetting. -
--access-tokensvalueSet the
access-tokenssetting. -
--allow-dirtyEnable the
allow-dirtysetting. -
--allow-import-from-derivationEnable the
allow-import-from-derivationsetting. -
--allow-new-privilegesEnable the
allow-new-privilegessetting. -
--allow-symlinked-storeEnable the
allow-symlinked-storesetting. -
--allow-unsafe-native-code-during-evaluationEnable the
allow-unsafe-native-code-during-evaluationsetting. -
--allowed-impure-host-depsvalueSet the
allowed-impure-host-depssetting. -
--allowed-urisvalueSet the
allowed-urissetting. -
--allowed-usersvalueSet the
allowed-userssetting. -
--auto-allocate-uidsEnable the
auto-allocate-uidssetting. -
--auto-optimise-storeEnable the
auto-optimise-storesetting. -
--bash-promptvalueSet the
bash-promptsetting. -
--bash-prompt-prefixvalueSet the
bash-prompt-prefixsetting. -
--bash-prompt-suffixvalueSet the
bash-prompt-suffixsetting. -
--build-hookvalueSet the
build-hooksetting. -
--build-poll-intervalvalueSet the
build-poll-intervalsetting. -
--build-users-groupvalueSet the
build-users-groupsetting. -
--buildersvalueSet the
builderssetting. -
--builders-use-substitutesEnable the
builders-use-substitutessetting. -
--commit-lockfile-summaryvalueSet the
commit-lockfile-summarysetting. -
--compress-build-logEnable the
compress-build-logsetting. -
--connect-timeoutvalueSet the
connect-timeoutsetting. -
--coresvalueSet the
coressetting. -
--diff-hookvalueSet the
diff-hooksetting. -
--download-attemptsvalueSet the
download-attemptssetting. -
--download-speedvalueSet the
download-speedsetting. -
--eval-cacheEnable the
eval-cachesetting. -
--experimental-featuresvalueSet the
experimental-featuressetting. -
--extra-access-tokensvalueAppend to the
access-tokenssetting. -
--extra-allowed-impure-host-depsvalueAppend to the
allowed-impure-host-depssetting. -
--extra-allowed-urisvalueAppend to the
allowed-urissetting. -
--extra-allowed-usersvalueAppend to the
allowed-userssetting. -
--extra-experimental-featuresvalueAppend to the
experimental-featuressetting. -
--extra-extra-platformsvalueAppend to the
extra-platformssetting. -
--extra-hashed-mirrorsvalueAppend to the
hashed-mirrorssetting. -
--extra-ignored-aclsvalueAppend to the
ignored-aclssetting. -
--extra-nix-pathvalueAppend to the
nix-pathsetting. -
--extra-platformsvalueSet the
extra-platformssetting. -
--extra-plugin-filesvalueAppend to the
plugin-filessetting. -
--extra-sandbox-pathsvalueAppend to the
sandbox-pathssetting. -
--extra-secret-key-filesvalueAppend to the
secret-key-filessetting. -
--extra-substitutersvalueAppend to the
substituterssetting. -
--extra-system-featuresvalueAppend to the
system-featuressetting. -
--extra-trusted-public-keysvalueAppend to the
trusted-public-keyssetting. -
--extra-trusted-substitutersvalueAppend to the
trusted-substituterssetting. -
--extra-trusted-usersvalueAppend to the
trusted-userssetting. -
--fallbackEnable the
fallbacksetting. -
--filter-syscallsEnable the
filter-syscallssetting. -
--flake-registryvalueSet the
flake-registrysetting. -
--fsync-metadataEnable the
fsync-metadatasetting. -
--gc-reserved-spacevalueSet the
gc-reserved-spacesetting. -
--hashed-mirrorsvalueSet the
hashed-mirrorssetting. -
--http-connectionsvalueSet the
http-connectionssetting. -
--http2Enable the
http2setting. -
--id-countvalueSet the
id-countsetting. -
--ignore-tryEnable the
ignore-trysetting. -
--ignored-aclsvalueSet the
ignored-aclssetting. -
--impersonate-linux-26Enable the
impersonate-linux-26setting. -
--keep-build-logEnable the
keep-build-logsetting. -
--keep-derivationsEnable the
keep-derivationssetting. -
--keep-env-derivationsEnable the
keep-env-derivationssetting. -
--keep-failedEnable the
keep-failedsetting. -
--keep-goingEnable the
keep-goingsetting. -
--keep-outputsEnable the
keep-outputssetting. -
--log-linesvalueSet the
log-linessetting. -
--max-build-log-sizevalueSet the
max-build-log-sizesetting. -
--max-freevalueSet the
max-freesetting. -
--max-jobsvalueSet the
max-jobssetting. -
--max-silent-timevalueSet the
max-silent-timesetting. -
--max-substitution-jobsvalueSet the
max-substitution-jobssetting. -
--min-freevalueSet the
min-freesetting. -
--min-free-check-intervalvalueSet the
min-free-check-intervalsetting. -
--nar-buffer-sizevalueSet the
nar-buffer-sizesetting. -
--narinfo-cache-negative-ttlvalueSet the
narinfo-cache-negative-ttlsetting. -
--narinfo-cache-positive-ttlvalueSet the
narinfo-cache-positive-ttlsetting. -
--netrc-filevalueSet the
netrc-filesetting. -
--nix-pathvalueSet the
nix-pathsetting. -
--no-accept-flake-configDisable the
accept-flake-configsetting. -
--no-allow-dirtyDisable the
allow-dirtysetting. -
--no-allow-import-from-derivationDisable the
allow-import-from-derivationsetting. -
--no-allow-new-privilegesDisable the
allow-new-privilegessetting. -
--no-allow-symlinked-storeDisable the
allow-symlinked-storesetting. -
--no-allow-unsafe-native-code-during-evaluationDisable the
allow-unsafe-native-code-during-evaluationsetting. -
--no-auto-allocate-uidsDisable the
auto-allocate-uidssetting. -
--no-auto-optimise-storeDisable the
auto-optimise-storesetting. -
--no-builders-use-substitutesDisable the
builders-use-substitutessetting. -
--no-compress-build-logDisable the
compress-build-logsetting. -
--no-eval-cacheDisable the
eval-cachesetting. -
--no-fallbackDisable the
fallbacksetting. -
--no-filter-syscallsDisable the
filter-syscallssetting. -
--no-fsync-metadataDisable the
fsync-metadatasetting. -
--no-http2Disable the
http2setting. -
--no-ignore-tryDisable the
ignore-trysetting. -
--no-impersonate-linux-26Disable the
impersonate-linux-26setting. -
--no-keep-build-logDisable the
keep-build-logsetting. -
--no-keep-derivationsDisable the
keep-derivationssetting. -
--no-keep-env-derivationsDisable the
keep-env-derivationssetting. -
--no-keep-failedDisable the
keep-failedsetting. -
--no-keep-goingDisable the
keep-goingsetting. -
--no-keep-outputsDisable the
keep-outputssetting. -
--no-preallocate-contentsDisable the
preallocate-contentssetting. -
--no-print-missingDisable the
print-missingsetting. -
--no-pure-evalDisable the
pure-evalsetting. -
--no-require-sigsDisable the
require-sigssetting. -
--no-restrict-evalDisable the
restrict-evalsetting. -
--no-run-diff-hookDisable the
run-diff-hooksetting. -
--no-sandboxDisable sandboxing.
-
--no-sandbox-fallbackDisable the
sandbox-fallbacksetting. -
--no-show-traceDisable the
show-tracesetting. -
--no-substituteDisable the
substitutesetting. -
--no-sync-before-registeringDisable the
sync-before-registeringsetting. -
--no-trace-function-callsDisable the
trace-function-callssetting. -
--no-trace-verboseDisable the
trace-verbosesetting. -
--no-use-case-hackDisable the
use-case-hacksetting. -
--no-use-cgroupsDisable the
use-cgroupssetting. -
--no-use-registriesDisable the
use-registriessetting. -
--no-use-sqlite-walDisable the
use-sqlite-walsetting. -
--no-use-xdg-base-directoriesDisable the
use-xdg-base-directoriessetting. -
--no-warn-dirtyDisable the
warn-dirtysetting. -
--plugin-filesvalueSet the
plugin-filessetting. -
--post-build-hookvalueSet the
post-build-hooksetting. -
--pre-build-hookvalueSet the
pre-build-hooksetting. -
--preallocate-contentsEnable the
preallocate-contentssetting. -
--print-missingEnable the
print-missingsetting. -
--pure-evalEnable the
pure-evalsetting. -
--relaxed-sandboxEnable sandboxing, but allow builds to disable it.
-
--require-sigsEnable the
require-sigssetting. -
--restrict-evalEnable the
restrict-evalsetting. -
--run-diff-hookEnable the
run-diff-hooksetting. -
--sandboxEnable sandboxing.
-
--sandbox-build-dirvalueSet the
sandbox-build-dirsetting. -
--sandbox-dev-shm-sizevalueSet the
sandbox-dev-shm-sizesetting. -
--sandbox-fallbackEnable the
sandbox-fallbacksetting. -
--sandbox-pathsvalueSet the
sandbox-pathssetting. -
--secret-key-filesvalueSet the
secret-key-filessetting. -
--show-traceEnable the
show-tracesetting. -
--ssl-cert-filevalueSet the
ssl-cert-filesetting. -
--stalled-download-timeoutvalueSet the
stalled-download-timeoutsetting. -
--start-idvalueSet the
start-idsetting. -
--storevalueSet the
storesetting. -
--substituteEnable the
substitutesetting. -
--substitutersvalueSet the
substituterssetting. -
--sync-before-registeringEnable the
sync-before-registeringsetting. -
--systemvalueSet the
systemsetting. -
--system-featuresvalueSet the
system-featuressetting. -
--tarball-ttlvalueSet the
tarball-ttlsetting. -
--timeoutvalueSet the
timeoutsetting. -
--trace-function-callsEnable the
trace-function-callssetting. -
--trace-verboseEnable the
trace-verbosesetting. -
--trusted-public-keysvalueSet the
trusted-public-keyssetting. -
--trusted-substitutersvalueSet the
trusted-substituterssetting. -
--trusted-usersvalueSet the
trusted-userssetting. -
--use-case-hackEnable the
use-case-hacksetting. -
--use-cgroupsEnable the
use-cgroupssetting. -
--use-registriesEnable the
use-registriessetting. -
--use-sqlite-walEnable the
use-sqlite-walsetting. -
--use-xdg-base-directoriesEnable the
use-xdg-base-directoriessetting. -
--user-agent-suffixvalueSet the
user-agent-suffixsetting. -
--warn-dirtyEnable the
warn-dirtysetting.