Skip to content

nix building the default output of a derivation #6661

Description

@ncfavier

With the legacy CLI, running nix-build '<nixpkgs>' -A feh would build and print feh's default output.

With the new CLI (starting from 1ddabe1), nix build nixpkgs#feh --print-out-paths prints feh.man, then feh.out, so if you only want the default output you have to specify it explicitly: nixpkgs#feh^out. This is not ideal as you need to know the name of the default output.

My ideas for solving this, in decreasing order of preference:

  1. only build the default output by default instead of outputsToInstall (i.e. revert 1ddabe1), at least for nix build
  2. extend the ^ syntax to be able to specify only the default output (ideas: feh^, feh^default, feh^0)
  3. make sure the outputs are kept in their original order so that you can just take the first line (and maybe use nlohmann::ordered_json when printing JSON)
  4. in the spirit of nix-env: always print output names in JSON and XML #6242, add an outputName field to the output of nix build --json containing the default output

Crazier ideas that would require big changes to the ecosystem:

  1. enforce the default output to always be out
  2. rethink outputs as "parts of a whole", i.e. when building feh^out,man, merge out and man into a single output path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions