I’m currently running nix 2.8.1 on an intel macOS with nix-darwin set up to use the nix-command and flakes.
I’m expecting to be able to use commands like ‘nix develop’ ‘nix shell’ ‘nix build’ but I keep getting errors that seem to suggest the flake isn’t setting certain attributes when to me it seems like one of them is definitely explicitly set in the flake output.
shell> nix develop
error: flake 'git+file:///Users/$USER/Documents/Workspace/hello' does not provide attribute 'devShells.x86-64-darwin.default', 'devShell.x86-64-darwin', 'packages.x86-64-darwin.default' or 'defaultPackage.x86-64-darwin'
Did you mean x86_64-darwin?
error: flake 'git+file:///Users/ashwinmathi/Documents/Workspace/broken-nix-flake' does not provide attribute 'packages.x86-64-darwin.default' or 'defaultPackage.x86-64-darwin'
Did you mean x86_64-darwin?
nix build produces this output
error: flake 'git+file:///Users/ashwinmathi/Documents/Workspace/broken-nix-flake' does not provide attribute 'packages.x86-64-darwin.default' or 'defaultPackage.x86-64-darwin'
Did you mean x86_64-darwin?
Edit:
I’m definitely just mad confused cuz especially in those last few commands from my perspective I’ve defined both of those things, and in the case of nix develop the manual seems to imply that any one of the items in that error message’s list would be acceptable.
I am a bit confused because it seems to suggest that you’re typoing: x86-64-darwin vs x86_64-darwin, see the first dash/underscore. But afaik _is correct.
Could you try nix shell .#packages.x86_64-darwin.default to confirm? Maybe this is a very new nix version doing things I’ve not yet become aware of.
nix shell .#packages.x86_64-darwin.default runs with no error but doesn’t launch a new environment or anything, just puts me back to the normal shell. I’m not sure what the expected behavior of nix shell should be but I’m guessing it’s at least a little similar to what nix-shell would have looked like?
When I do nix develop .#packages.x86_64-darwin.default I get a new error
error (ignored): error: flake 'github:NixOS/nixpkgs/d8f2c4d846a2e65ad3f5a5e842b672f0b81588a2' does not provide attribute 'legacyPackages.x86-64-darwin.bashInteractive' or 'bashInteractive'
Did you mean x86_64-darwin?
but it does actually end up putting me into a new environment titled ‘bash-5.1’
I appear to have been mistaken on what nix shell is supposed to do, I guess it isn’t as much of a ‘separate shell environment’ as I’m used to because upon running ‘hello’ and ‘where hello’ it points me to the local nix store and appears to work well!
The correct output should x86_64-darwin. If you get x86-64-darwin, it is likely there is some sort of error in your configuration or something somewhere?
Possibly check in /etc/nix/nix.conf. If you can’t figure it out, I’d suggest completely uninstalling Nix (including ever configuration file you can find), and reinstalling.
Thank you so much for your time and help I can finally go to sleep in peace
The issue was caused by exactly what you said - there was a line loaded by my darwin configuration where I mistakenly set nix.extraOptions.system to x86-64-darwin rather than x86_64-darwin.
Again, I really can’t express my gratitude enough and am excited to pay it forward as soon as I gain some experience with this beast of a tool!