Home Explore Blog CI



nix

2nd chunk of `doc/manual/source/release-notes/rl-2.4.md`
6777b2beef5a7225a42f37ea1014fabdd1a2b1d318edc75c0000000100000fb2
    * It can run specific phases directly. For instance, `nix develop
      --build` runs `buildPhase`.

    - It allows dependencies in the Nix store to be "redirected" to
      arbitrary directories using the `--redirect` flag. This is
      useful if you want to hack on a package *and* some of its
      dependencies at the same time.

  - `nix print-dev-env` prints the environment variables and bash
    functions defined by a derivation. This is useful for users of
    other shells than bash (especially with `--json`).

  - `nix shell` was previously named `nix run` and is intended to
    replace `nix-shell -p`, but without the `stdenv` overhead. It
    simply starts a shell where some packages have been added to
    `$PATH`.

  - `nix run` (not to be confused with the old subcommand that has
    been renamed to `nix shell`) runs an "app", a flake output that
    specifies a command to run, or an eponymous program from a
    package. For example, `nix run nixpkgs#hello` runs the `hello`
    program from the `hello` package in `nixpkgs`.

  - `nix flake` is the container for flake-related operations, such as
    creating a new flake, querying the contents of a flake or updating
    flake lock files.

  - `nix registry` allows you to query and update the flake registry,
    which maps identifiers such as `nixpkgs` to concrete flake URLs.

  - `nix profile` is intended to replace `nix-env`. Its main advantage
    is that it keeps track of the provenance of installed packages
    (e.g. exactly which flake version a package came from). It also
    has some helpful subcommands:

    * `nix profile history` shows what packages were added, upgraded
      or removed between each version of a profile.

    * `nix profile diff-closures` shows the changes between the
      closures of each version of a profile. This allows you to
      discover the addition or removal of dependencies or size
      changes.

    **Warning**: after a profile has been updated using `nix profile`,
    it is no longer usable with `nix-env`.

  - `nix store diff-closures` shows the differences between the
    closures of two store paths in terms of the versions and sizes of
    dependencies in the closures.

  - `nix store make-content-addressable` rewrites an arbitrary closure
    to make it content-addressed. Such paths can be copied into other
    stores without requiring signatures.

  - `nix bundle` uses the [`nix-bundle`
    program](https://github.com/matthewbauer/nix-bundle) to convert a
    closure into a self-extracting executable.

  - Various other replacements for the old CLI, e.g. `nix store gc`,
    `nix store delete`, `nix store repair`, `nix nar dump-path`, `nix
    store prefetch-file`, `nix store prefetch-tarball`, `nix key` and
    `nix daemon`.

* Nix now has an **evaluation cache** for flake outputs. For example,
  a second invocation of the command `nix run nixpkgs#firefox` will
  not need to evaluate the `firefox` attribute because it's already in
  the evaluation cache. This is made possible by the hermetic
  evaluation model of flakes.

  Intermediate results are not cached.

* The new `--offline` flag disables substituters and causes all
  locally cached tarballs and repositories to be considered
  up-to-date.

* The new `--refresh` flag causes all locally cached tarballs and
  repositories to be considered out-of-date.

* Many `nix` subcommands now have a `--json` option to produce
  machine-readable output.

* `nix repl` has a new `:doc` command to show documentation about
  builtin functions (e.g. `:doc builtins.map`).

* Binary cache stores now have an option `index-debug-info` to create
  an index of DWARF debuginfo files for use by
  [`dwarffs`](https://github.com/edolstra/dwarffs).

* To support flakes, Nix now has an extensible mechanism for fetching
  source trees. Currently it has the following backends:

  * Git repositories

  * Mercurial repositories

  * GitHub and GitLab repositories (an optimisation for faster
    fetching than Git)

Title: Nix 2.4: Detailed Overview of New Subcommands, Evaluation Cache, and Source Fetching Improvements
Summary
This section details the new 'nix' subcommands in Nix 2.4, including 'nix develop' for enhanced development environments, 'nix print-dev-env' for displaying derivation environment variables, 'nix shell' and 'nix run' for running packages and applications, 'nix flake' and 'nix registry' for managing flakes, and 'nix profile' for package provenance tracking. Additionally, it covers 'nix store' commands for closure differences, content addressing, and self-extracting executables. It also highlights the introduction of an evaluation cache for flake outputs, the `--offline` and `--refresh` flags, JSON output options, a `:doc` command in 'nix repl', binary cache options for debuginfo, and an extensible mechanism for fetching source trees.