dustinlyons / nixos-config

General purpose Nix configuration for macOS / NixOS with starter templates + step-by-step guides ✨
BSD 3-Clause "New" or "Revised" License
1.8k stars 113 forks source link

error: experimental Nix feature 'nix-command' is disabled #56

Closed TheKashe closed 9 months ago

TheKashe commented 9 months ago

Hi,

I'm trying to install the config on nix 2.20.1. on macOS. nix run .#apply fails:

nix run .#apply

error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it

This seems to work:

nix --extra-experimental-features 'nix-command flakes' run .#apply
dustinlyons commented 9 months ago

Hi, curious if you had Nix installed previously or used the Determinate Systems Installer. The Determinate Systems Installer enables flakes and nix commands by default.

Nix experimental commands are enabled a few different ways:

  1. In your /etc/nix/nix.conf file. Mine has this line (from the Determinate Systems installer):

experimental-features = nix-command flakes

  1. At the command line, as you have done.

nix --extra-experimental-features 'nix-command flakes' run .#apply

I used to include the extra long command as part of the README steps, but after moving to the Determinate Systems installer, I dropped it as I felt the verbosity was a little confusing for newcomers.

But curious how you installed Nix, as I may add it back.

jspiers commented 9 months ago

FWIW, when I installed using using the Determinate Systems shell-based installer a few days ago, I didn't run into that problem for nix run .#apply, but I did later on at step 9 when running nix run .#build because I had deleted /etc/nix/nix.conf as instructed in step 9. I also overcame this by manually adding the --extra-experimental-features 'nix-command flakes' option to the command

jspiers commented 9 months ago

Actually I just noticed all of this behavior is well-described in the Nix Flakes wiki. So maybe just add an obvious link to that in the README?

TheKashe commented 9 months ago

I think I used the macOS recommended way:

sh <(curl -L https://nixos.org/nix/install)

Adding

experimental-features = nix-command flakes

to nix.conf resolves it. It would be helpful to mention it in the readme. I guess the problem resurfaces once you rename the config.

dustinlyons commented 9 months ago

Hey @TheKashe and @jspiers, thanks a ton. I've made a few changes to the README based on your report.

  1. Added a section to help users enable Nix experimental commands that either had Nix installed or don't use the Determinate Systems installer

  2. Removed the step to move nix.conf out of the way based on this issue (looks like it's fixed now).

pfeodrippe commented 9 months ago

I'm having this issue as well (M3)

$ nixos-config % nix run .#build-switch
Running build-switch for aarch64-darwin
Starting build...
Switching to new generation...
building the system configuration...
error: Unexpected files in /etc, aborting activation
The following files have unrecognized content and would be overwritten:

  /etc/nix/nix.conf
  /etc/bashrc

Please check there is nothing critical in these files, rename them by adding .before-nix-darwin to the end, and then try again.

Should we move nix.conf or something else?

Great project, BTW, Dustin, thanks!!

dustinlyons commented 9 months ago

Hi @pfeodrippe,

Yes I will add a note to the README. This comes from nix-darwin and helps prevent files you have existing from being overwritten by the Nix config, without your consent.

You basically need to backup those files somewhere and remove them from their existing location . The nix config will replace them with copies from the configuration.

Note, my Nix config uses zsh. So if you need to movebash configuration over, you may want to switch the configuration to enable bash. This is done in the shared home-manager file.

pfeodrippe commented 9 months ago

Hi @pfeodrippe,

Yes I will add a note to the README. This comes from nix-darwin and helps prevent files you have existing from being overwritten by the Nix config, without your consent.

You basically need to backup those files somewhere and remove them from their existing location . The nix config will replace them with copies from the configuration.

Note, my Nix config uses zsh. So if you need to movebash configuration over, you may want to switch the configuration to enable bash. This is done in the shared home-manager file.

Thank you, man \o Appreciate it