Skip to content

Add nix-run v2 command - #15662

Open
KiaraGrouwstra wants to merge 1 commit into
NixOS:masterfrom
KiaraGrouwstra:nix-run-cmd
Open

KiaraGrouwstra wants to merge 1 commit into
NixOS:masterfrom
KiaraGrouwstra:nix-run-cmd

Conversation

@KiaraGrouwstra

@KiaraGrouwstra KiaraGrouwstra commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Adds a v2-CLI-style nix-run that evaluates a Nix expression and executes the selected derivation's main program, using the same getExe-like semantics as nix run: prefer meta.mainProgram, then pname, then the parsed derivation name.

Usage: nix-run [FILE] [-A ATTR] [-E] [-- ARGS...]

FILE defaults to ./default.nix. Arguments after the first positional (or after a literal --) are forwarded verbatim to the program.

Motivation

inspired by #14992, tho with fetchTree-powered source-fetching deferred to #15654.

Context

disclaimer i used a coding agent in the creation of this patch.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions Bot added documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Apr 11, 2026
Adds a v1-CLI-style `nix-run` that evaluates a Nix expression and
executes the selected derivation's main program, using the same
`getExe`-like semantics as `nix run`: prefer `meta.mainProgram`, then
`pname`, then the parsed derivation name.

Usage:
    nix-run [FILE] [-A ATTR] [-E] [-- ARGS...]

FILE defaults to `./default.nix`. Arguments after the first positional
(or after a literal `--`) are forwarded verbatim to the program.
@KiaraGrouwstra KiaraGrouwstra changed the title Add nix-run legacy command Add nix-run v2 command Apr 12, 2026
@edolstra

Copy link
Copy Markdown
Member

We definitely don't want to add new top-level commands. We've spent the last couple of years trying to replace nix-* by one nix command! In particular, this command doesn't respect the installables concept of the new CLI, so it goes against the goal of having a unified CLI with consistent behaviour.

If you want commands like nix run to work on non-flake trees, it's probably better to add a new type of installable (e.g. nix run --from-tree github:my/repo attr). Not saying that's a good idea though, since such projects wouldn't be discoverable and wouldn't have hermetic evaluation.

@KiaraGrouwstra

Copy link
Copy Markdown
Contributor Author

it's probably better to add a new type of installable (e.g. nix run --from-tree github:my/repo attr).

right -- that's the idea behind #15654.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants