"nix run" on 2.4 - feedback


I read the announcement of Nix 2.4 RC1 a couple of days ago and decided to give it a try today.
I’ll describe my experience with this here - not sure any of this qualifies as bugs, but the overall first impression upgrading from 2.3 was pretty bad for me tbh.

I’m on NixOS, firstly I had to spend a bit of time to figure out that the right package to use for this is:

nix.package = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/f7a1df955530f4e190db017c242b96d4abddf0a6.tar.gz") {}).nix_2_4;

It would be nice to include some instructions like this for NixOS users in future release candidate announcements.

After making that change and rebuilding, I try running nix run nixpkgs.jq which shows this error:

error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override

Error message isn’t great tbh… I look up the release notes and it says “The old nix run has been renamed to nix shell (and there is a new nix run that does something else, as described above).”

Ok, that’s a bizarre decision I think, but fair enough at least it’s documented.
So I try nix shell nixpkgs.jq but I get the exact same error “experimental Nix feature ‘nix-command’ is disabled”.
Release notes also mention “The nix command is now marked as an experimental feature”. This is a bit unclear to me, I kinda had to guess that it was related to this in any way.
Anyway I define experimental-features = nix-command in extraOptions (again, it would be nice to include a short description on how to do this for NixOS).

I try nix shell nixpkgs.jq again but I get a different error this time:

error: getting status of '/home/mauricio/nixpkgs.jq': No such file or directory

No idea what this is even trying to do now but it’s pretty clear that the release notes are incorrect saying that “‘nix run’ has been renamed to ‘nix shell’”.
Plus these error messages aren’t great tbh.

I’ll be going back to 2.3 for now.
I don’t usually expect this kind of breaking changes upgrading any software from version 2.3 to 2.4.
Also it just seems that there are undocumented breaking changes and people lose confidence in software when that happens.

I’m aware that 2.4 includes flakes now and the new way to do what I just wanted to do is nix run nixpkgs#jq but currently the documentation / release notes / error messages just aren’t pointing users in the right direction I don’t think.

I just realised that this message is a bit long and has a rather negative feel to it so I’d like to finish by saying that I appreciate everyone’s hard work on Nix 2.4 and Nix/NixOS in general, I really do think that Nix is heading in the right direction with flakes and things are generally getting much better :slightly_smiling_face:


The old nix command was never stable.

$ nix --version
nix (Nix) 2.3.15
$ nix --help
Usage: nix <COMMAND> <FLAGS>... <ARGS>...


Note: this program is EXPERIMENTAL and subject to change

Still, when they said that 2.4 will include the experimental-features setting, I assumed, that 2.4 with all experimental-features disabled, will just be like 2.3. And not that it will basically force everyone into flakes, as that is exactly what happens in the error about '/home/mauricio/nixpkgs.jq' beeing inexistent.


Nix 2.4 with experimental features disabled is exactly like Nix 2.3 and all the non-experimental parts like nix-build, nix-shell, nix-store, etc. continue to work as expected.

Not to mention that the old nix command was inherently broken and had big problems with cache invalidation (which is fixed by Flakes).


“nix run” has been around since Nix 2.0 I think? So it’s been part of stable releases nearly for the last 4 years.

At this point it largely doesn’t matter much that it’s flagged “experimental” or not. People are using it and depending on it. Google “nix run” and you’ll see loads of articles… there are also lots of references in nixos.wiki, etc.

Just to sum up my points again:

  1. I think it’s a bad idea to make so many breaking changes going from 2.3 to 2.4.
    IMHO 3.0 would better convey the dimension of the changes and improvements.
  2. Regardless of the previous point, docs / release notes need to describe in excruciating detail all the breaking changes, even for “experimental” features like “nix run”.
  3. Release notes should mention how to upgrade in NixOS.
  4. Error messages for these breaking changes aren’t great. This is particularly important in this case because people don’t usually read release notes when it’s a minor version upgrade (point 1)

Just to be super clear, I think these are issues of documentation / communication more than technical problems.
Sure I disagree on the technical decision to make “nix run” mean something completely different (I still don’t know what’s the equivalent in 2.4 without flakes?) but I also know that ship has probably sailed at this point.
However it’s not too late to communicate these breaking changes appropriately.


It’s the same as in Nix 2.3:

nix-shell -p hello

(unless you are using a diverted store, I don’t think that is available)

Just to clarify why this is broken, the new Nix uses a different syntax so it would actually be nix run nixpkgs#jq. This may or may not required the flakes experimental feature to be enabled as well though.


With no experimental features, I’d probably do

$ nix-shell -p jq --run "jq"

Is there a way to use the 2.4 CLI without enabling flakes?

If not, it should be straight 3.0


The Nix 2.4 CLI is the same as the Nix 2.3 CLI or do you mean “How to use experimental-features = nix-command without using Flakes?”

If it was the same, this thread wouldn’t exist.


Well, it is the same with the exception of the experimental nix command which isn’t even documented in the manual. Introduction

There are at least examples of nix store and nix ping-store

Also, run, build and repl in the nixpkgs manual.

Either way, it’s long enough there and used throughout the net, the issue tracker, discourse, wiki to be considered “stable”.

Yes it had the warning about beeing experimental and is subject to change, though I hadn’t expected that it basically gets removed for everyone who isn’t into flakes yet.

If there just was a way to use the 2.x/experimental interface against channels.

PS: personally I’m using flakes for everything for about a year now, so this change doesn’t affect me as a user of nix, so there is coming a lot of work towards us to teach people to use nix-shell -p again over nix run, when we told them for 2 or more years, that the hyphenated commands are a thing from the past and mostly there for compatibility reasons.


True, there is an example with nix ping-store. The commands nix run and nix repl are only mentioned in the changelog without any meaningful docs. The nix store example might be a typo of nix-store:

$ nix store --help
error: 'store' is not a recognised command
Try '/nix/var/nix/profiles/default/bin/nix --help' for more information.

Something similar applies to the nix build example which is neither a valid invocation with the new nor with the old interface.

Pretty ugly, but possible:

nix shell --impure --file '<nixpkgs>' hello
1 Like

Each command has a man page and a corresponded markdown file in repo. For example, you can run man nix3-run to get docs on nix run.

It seems there’s only one person here that apparently disagrees with my initial post, and many that agree?

However a thread on Discourse is probably not the best way to reach the people that actually decide these things. What’s the process here? A github issue on https://github.com/NixOS/nix ?

I’m aware of some criticism of flakes but I don’t have the time to keep up, maybe this has already been discussed?


I really don’t understand the decision to change nix-shell's interface at all. I’ve been playing with it for a while, and afaict there’s no way to still use it with channels, it only looks at nixpkgs from NIX_PATH, or expects flake fragments.

Why? Why was this done? I don’t get it. I don’t like channels… but this really, really frustrating. This just feels like fully unnecessary fuel that will feed anti-flake sentiments even though there’s zero reason why flakes would’ve required breaking the legacy nix-shell interface.

Seems like filing a bug would be a good way to go, I’d +1 it.


nix-shell hasn’t changed at all. You can still use it like before. Did you mean nix shell?

1 Like

Ok, how do you use nix-shell with channels? The only example I’ve seen or that I’ve been able to reproduce was only implicitly using nixpkgs from NIX_PATH. Any constructs that worked previously using channels… well, I can’t get them to work.

nix-shell -p hello --run hello.

This resolves through NIX_PATH, which will eventually use nixpkgs from channels, as I have no other nixpkgs in the NIX_PATH. Thats how it always worked since I am using nix…

Hosted by Flying Circus.