Home Explore Blog CI



nix

2nd chunk of `doc/manual/source/release-notes/rl-2.0.md`
206ee7d29bd11dd15b082223b7f459fb17c598fa468d78710000000100000fe9
        arguments.

      - It is self-documenting: `--help` shows all available
        command-line arguments. If `--help` is given after a subcommand,
        it shows examples for that subcommand. `nix
                                                                        --help-config` shows all configuration options.

      - It is much less verbose. By default, it displays a single-line
        progress indicator that shows how many packages are left to be
        built or downloaded, and (if there are running builds) the most
        recent line of builder output. If a build fails, it shows the
        last few lines of builder output. The full build log can be
        retrieved using `nix
                                                                        log`.

      - It
        [provides](https://github.com/NixOS/nix/commit/b8283773bd64d7da6859ed520ee19867742a03ba)
        all `nix.conf` configuration options as command line flags. For
        example, instead of `--option
                                                                        http-connections 100` you can write `--http-connections 100`.
        Boolean options can be written as `--foo` or `--no-foo` (e.g.
        `--no-auto-optimise-store`).

      - Many subcommands have a `--json` flag to write results to stdout
        in JSON format.

    > **Warning**
    >
    > Please note that the `nix` command is a work in progress and the
    > interface is subject to change.

    It provides the following high-level (“porcelain”) subcommands:

      - `nix build` is a replacement for `nix-build`.

      - `nix run` executes a command in an environment in which the
        specified packages are available. It is (roughly) a replacement
        for `nix-shell
                                                                        -p`. Unlike that command, it does not execute the command in a
        shell, and has a flag (`-c`) that specifies the unquoted command
        line to be executed.

        It is particularly useful in conjunction with chroot stores,
        allowing Linux users who do not have permission to install Nix
        in `/nix/store` to still use binary substitutes that assume
        `/nix/store`. For example,

            nix run --store ~/my-nix nixpkgs.hello -c hello --greeting 'Hi everybody!'

        downloads (or if not substitutes are available, builds) the GNU
        Hello package into `~/my-nix/nix/store`, then runs `hello` in a
        mount namespace where `~/my-nix/nix/store` is mounted onto
        `/nix/store`.

      - `nix search` replaces `nix-env
                                                                        -qa`. It searches the available packages for occurrences of a
        search string in the attribute name, package name or
        description. Unlike `nix-env -qa`, it has a cache to speed up
        subsequent searches.

      - `nix copy` copies paths between arbitrary Nix stores,
        generalising `nix-copy-closure` and `nix-push`.

      - `nix repl` replaces the external program `nix-repl`. It provides
        an interactive environment for evaluating and building Nix
        expressions. Note that it uses `linenoise-ng` instead of GNU
        Readline.

      - `nix upgrade-nix` upgrades Nix to the latest stable version.
        This requires that Nix is installed in a profile. (Thus it won’t
        work on NixOS, or if it’s installed outside of the Nix store.)

      - `nix verify` checks whether store paths are unmodified and/or
        “trusted” (see below). It replaces `nix-store --verify` and
        `nix-store
                                                                        --verify-path`.

      - `nix log` shows the build log of a package or path. If the
        build log is not available locally, it will try to obtain it
        from the configured substituters (such as
        [cache.nixos.org](https://cache.nixos.org/), which now
        provides build logs).

      - `nix edit` opens the source code of a package in your editor.

Title: Nix 2.0: New 'nix' Command Features and Subcommands
Summary
The new `nix` command in Nix 2.0 offers self-documentation, reduced verbosity, command-line configuration, and JSON output. It includes subcommands like `nix build` (replaces `nix-build`), `nix run` (replaces `nix-shell -p`), `nix search` (replaces `nix-env -qa`), `nix copy` (generalizes `nix-copy-closure` and `nix-push`), `nix repl` (replaces `nix-repl`), `nix upgrade-nix`, `nix verify` (replaces `nix-store --verify`), `nix log`, and `nix edit`. Note that the `nix` command is a work in progress and its interface may change.