LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix-why-depends

shows why a package depends on another

TLDR

Show a dependency path from one package to another
$ nix why-depends nixpkgs#[hello] nixpkgs#[glibc]
copy
Show all paths, not just the shortest
$ nix why-depends --all nixpkgs#[package] nixpkgs#[dependency]
copy
Show the files that cause each reference
$ nix why-depends --precise nixpkgs#[package] nixpkgs#[dependency]
copy
Explain a build-time dependency
$ nix why-depends --derivation nixpkgs#[package] nixpkgs#[dependency]
copy
Use store paths directly
$ nix why-depends [/nix/store/...-package] [/nix/store/...-dependency]
copy
Find why the current NixOS system pulls in a package
$ nix why-depends /run/current-system nixpkgs#[package]
copy

SYNOPSIS

nix why-depends [options] package dependency

DESCRIPTION

nix why-depends explains why store path package has dependency in its closure. Nix detects runtime references by scanning outputs for the hash parts of store paths, so an unexpected reference (for example a compiler path left in a binary) bloats the closure.The command prints a shortest chain of references from package to dependency, and for each step a file fragment containing the reference to the next store path. With --derivation it traces build-time dependencies between .drv files instead.

PARAMETERS

PACKAGE

Installable or store path whose closure is inspected.
DEPENDENCY
Installable or store path to find in that closure.
-a, --all
Show all edges in the dependency graph leading from package to dependency, rather than just a shortest path.
--precise
For each edge, show the files in the parent that cause the dependency.
--derivation
Operate on the store derivations (build-time dependencies) rather than their outputs.
--help
Display help information.

INSTALL

sudo apt install nix-bin
copy
sudo dnf install nix
copy
sudo pacman -S nix
copy
sudo apk add nix
copy
sudo zypper install nix
copy
nix profile install nixpkgs#nix
copy

CAVEATS

Part of the experimental new Nix CLI: requires the nix-command experimental feature (and flakes for flake references). Both paths must be built or substituted, which may trigger downloads or builds. If there is no dependency, it only reports that package does not depend on dependency.

HISTORY

nix why-depends was added with the new nix command in Nix 2.0 (2018).

SEE ALSO

RESOURCES

Copied to clipboard
Kai