synix/docs/tips/dependency-tracing.md
sid 95a533c876
All checks were successful
Deploy docs / build-and-deploy (push) Successful in 3s
initial commit
2026-02-23 20:34:35 +01:00

49 lines
1.4 KiB
Markdown

# Dependency Tracing
Dependency tracing in Nix allows you to understand the relationships between packages in your system configuration.
## Forward Path Tracing
This section answers the question: "*What are the dependencies of an installed package?*"
Print a store path's dependency tree with:
```bash
nix-store --query --tree /nix/store/...
```
Get a package's store path with:
> Replace `YOUR_CONFIG` with the name of your NixOS or Home Manager configuration, and `PACKAGE` with the name of the package you want to analyze.
##### NixOS
```bash
nix path-info ~/.config/nixos#nixosConfigurations.YOUR_CONFIG.pkgs.PACKAGE
```
##### Home Manager
```bash
nix path-info ~/.config/nixos#homeConfigurations.YOUR_CONFIG.pkgs.PACKAGE
```
## Backward Path Tracing
This section answers the question: "*What are parents of an installed package?*" or "*Why is a certain package installed?*"
Print a package's dependency path with:
> Replace `YOUR_CONFIG` with the name of your NixOS or Home Manager configuration, and `PACKAGE` with the name of the package you want to analyze.
##### NixOS
```bash
nix why-depends --derivation ~/.config/nixos#nixosConfigurations.YOUR_CONFIG.config.system.build.toplevel ~/.config/nixos#nixosConfigurations.YOUR_CONFIG.pkgs.PACKAGE
```
##### Home Manager
```bash
nix why-depends --derivation ~/.config/nixos#homeConfigurations.YOUR_CONFIG.activationPackage ~/.config/nixos#homeConfigurations.YOUR_CONFIG.pkgs.PACKAGE
```