Dear all,
I am somewhat stuck using ‘nix build’ to build a cloned git-repository. Maybe (even most likely) it’s something dumb, but I really don’t know what the CLI tries to tell me .
First some context:
I would like to use a nix flake to build a project written in C++ on Ubuntu 20.04 with KDE (looks like Kubuntu, but KDE was installed after I figured that Gnome is to slow). I used this tutorial here:
Tested the hello-world package, everything works fine - so off to building the cloned repo.
Running the command ‘nix --extra-experimental-features nix-build [repo folder]’, I get
'warning: unknown experimental feature ‘nix-build’
If I now run the command ‘nix build’ (which is listed if I run “nix --help” under the headline ‘Main commands’) I get the error message:
‘error: experimental Nix feature ‘nix-command’ is disabled; use ‘–extra-experimental-features nix-command’ to override’
I would suspect, that I have not activated the experimental features yet, but I could not find a solution online either. Could you please point me the right direction on what to put into the command line? I really appreciate your help :).
Yeah, it’s a bit confusing, but you are meant to append literally --extra-experimental-features nix-command and not--extra-experimental-features nix-command, where command=build.
The reason for this “weirdness” is that the official command is still nix-build, which will be replaced in the future by nix build, but this command is not considered stable yet. By adding all that it should make people aware that they shall not yet assume this is how the CLI will look in the end.
Hej,
thanks a lot for the fast answer and explaining the rationale behind it . Final command resulted to nix --extra-experimental-features nix-command build [folder]
Then I got the error. ‘error: experimental Nix feature ‘flakes’ is disabled; use ‘–extra-experimental-features flakes’ to override’.
So the command: nix --extra-experimental-features nix-command --extra-experimental-features flakes build [folder]
finally did the job!
Which exact values to add or which experimental features are available is not documented in either.
You need to discover them, and their interdependencies on your own, as you try to do things…
The most common to be used today are nix-command and flakes, though there are also ca-derivations (content addressed derivations), impure-derivations and recursive-nix (allows nix being used in a derivation). Perhaps there are even more, but those are the ones I have seen being discussed or used in the wild.
Worth noting that these days nix will loudly complain to you if the settings are missing, and explain exactly what to put in your nix.conf to enable the experimental features you were trying to use in the error message.
I think he means it’s especially difficult to figure out what the correct command is, made difficult by the confusing error messages. To illustrate the practically user-hostile flow, a command mentioned simply as “nix search” in the automatically generated default config for every first NixOS build is apparently supposed to be nix --extra-experimental-features nix-command search if one happens to understand that first error correctly. And, after running this with the confidence of cathartic clarity, it errors again. My mistake, the correct form of “nix search” is nix --extra-experimental-features nix-command --extra-experimental-features flakes search. Wait, that doesn’t work.