Home Explore Blog CI



nix

src/nix/derivation-show.md
4ee33096b46a07ac81206bce166874eff92002eb95f582a70000000300000610
R""(

# Examples

* Show the [store derivation] that results from evaluating the Hello
  package:

  ```console
  # nix derivation show nixpkgs#hello
  {
    "/nix/store/s6rn4jz1sin56rf4qj5b5v8jxjm32hlk-hello-2.10.drv": {
      …
    }
  }
  ```

* Show the full derivation graph (if available) that produced your
  NixOS system:

  ```console
  # nix derivation show -r /run/current-system
  ```

* Print all files fetched using `fetchurl` by Firefox's dependency
  graph:

  ```console
  # nix derivation show -r nixpkgs#firefox \
    | jq -r '.[] | select(.outputs.out.hash and .env.urls) | .env.urls' \
    | uniq | sort
  ```

  Note that `.outputs.out.hash` selects *fixed-output derivations*
  (derivations that produce output with a specified content hash),
  while `.env.urls` selects derivations with a `urls` attribute.

# Description

This command prints on standard output a JSON representation of the
[store derivation]s to which [*installables*](./nix.md#installables) evaluate.

Store derivations are used internally by Nix. They are store paths with
extension `.drv` that represent the build-time dependency graph to which
a Nix expression evaluates.

By default, this command only shows top-level derivations, but with
`--recursive`, it also shows their dependencies.


`nix derivation show` outputs a JSON map of [store path]s to derivations in the following format:


{{#include ../../protocols/json/derivation.md}}

)""

Chunks
35553da0 (1st chunk of `src/nix/derivation-show.md`)
Title: Using `nix derivation show` to Inspect Derivations
Summary
The `nix derivation show` command is used to display store derivations (files with the `.drv` extension) in JSON format. These derivations represent the build-time dependency graph of Nix expressions. The command can show top-level derivations or, with the `--recursive` flag, the full dependency graph. Examples demonstrate how to use the command to inspect derivations, show the derivation graph for a NixOS system, and print the URLs of files fetched by a package's dependencies. The output is a JSON map of store paths to derivation objects.