How am I meant to use the `nix edit` command?

As I understand it, nix edit is there to view code in $EDITOR

From the man pages:

       nix edit - open the Nix expression of a Nix package in $EDITOR

But when I try to run it

$  nix edit nixpkgs#isync
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'

Is there a particular way I’m supposed to run it?

Nixpkgs exposes its packages through the legacyPackages output - this is because nixpkgs is a traditional nested package set, which is currently unsupported by the flake proposal (reason #2747829 for why flakes aren’t ready yet…).

Apparently that command doesn’t check the legacyPackages output.

That said, I find this strange. The reference docs explicitly show nixpkgs being supported:

# nix edit nixpkgs#hello

Additionally, your output contains this:

… the default* outputs were deprecated… 3, maybe 4 years ago?

Either this command has bitrotted and the docs are lying, or your nix is ancient.

Interesting,

well I am running 24.11.

My nix version is

nix (Nix) 2.24.14

The current nix version for 24.11 is 2.91.1. You should double check that your config is deployed correctly, sounds like your system is 3-4 years out of date in practice. Nope, ignore that, forgot I switched to lix.

This seems like an upstream bug then! Aaaand nope, @NobbZ is definitely correct.

Your shell reads the # as the start of a comment. Disable this feature for interactive prompts or quote/escape it.

2 Likes