Nix/src/nix/derivation-show.md
John Ericson edf3ecc497 Document JSON formats
Good to document these formats separately from commands that happen to
use them.

Eventually I would like this and `builtins.derivation` to refer to a
store section on derivations that is authoritative, but that doesn't yet
exist, and will take some time to make. So I think we're just best off
merging this now as is.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2024-01-20 17:03:47 -05:00

1.5 KiB

R""(

Examples

  • Show the store derivation that results from evaluating the Hello package:

    # nix derivation show nixpkgs#hello
    {
      "/nix/store/s6rn4jz1sin56rf4qj5b5v8jxjm32hlk-hello-2.10.drv": {
      }
    }
    
  • Show the full derivation graph (if available) that produced your NixOS system:

    # nix derivation show -r /run/current-system
    
  • Print all files fetched using fetchurl by Firefox's dependency graph:

    # 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 derivations to which 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 paths to derivations in the following format:

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

)""