Hello! I am encountering an error when attempting to go back to the channel based system of NixOS. Upon trying to rebuild after commenting out nix.settings.experimental-features = [ "nix-command" "flakes" ]; from my configuration, and editing the config otherwise so that it would be compatible with a non-flake setup, I receive the following error upon running sudo nixos-rebuild switch:
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
warning: could not build a newer version of nixos-rebuild, using current version
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
building the system configuration...
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel --no-out-link' returned non-zero exit status 1.
Passing --extra-experimental-features flakes to sudo nixos-rebuild switch tells me that this argument is unrecognized. I have deleted my flake.nix and flake.lock files.
How can I go back to using channel-based NixOS, and entirely remove Flake functionality, going forward?
Running nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel --no-out-link --extra-experimental-features flakes gives me a different error now:
error:
… while evaluating the attribute 'config'
at /nix/store/jc3mfa7ybzh32bkvdj5xiib1vkx8jy6x-source/lib/modules.nix:361:9:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
… while calling the 'seq' builtin
at /nix/store/jc3mfa7ybzh32bkvdj5xiib1vkx8jy6x-source/lib/modules.nix:361:18:
360| options = checked options;
361| config = checked (removeAttrs config [ "_module" ]);
| ^
362| _module = checked (config._module);
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)
Unfortunately, it seems I cannot rebuild from just my configuration.nix AT ALL while this is happening, and flakes are seemingly required for a rebuild to succeed now which should not be the case from my understanding.
I assumed too much and gave you an incomplete command, the correct one would look like nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel -I nixos-config=./<your configuration>.nix
Running nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel -I nixos-config=./configuration.nix --extra-experimental-features flakes gave me a promising looking wall of text. ending with a Permission denied error because I forgot to include sudo in my command.
Running it again with sudo spat out: /nix/store/2dxgxshppbb1rz1s6nj2xhd9p85kv7fx-nixos-system-nixos-25.11pre-git
It looks like this build was successful then (not that i fully understand what nix-build does) but unfortunately sudo nixos-rebuild switch still gives me the “flakes is disabled” error at this point.
Is there a way to book into my “newly built” generation from here, assuming the nix-build command successfully created one at /nix/store/2dxgxshppbb1rz1s6nj2xhd9p85kv7fx-nixos-system-nixos-25.11pre-git?
Running nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel -I nixos-config=./configuration.nix --extra-experimental-features flakes gave me a promising looking wall of text. ending with a Permission denied error because I forgot to include sudo in my command.
does it work without extra-experimental-features flakes? If so not, there is something in your nixos config that is using a flake, somehow, and it’s not nixos-rebuild’s fault.
Anyway, since your here, you can switch to the configuration you just built with these two commands:
It unfortunately does not work without extra-experimental-features flakes. I have looked over my config and NOTHING in there references flakes so I am confused.
After running your included commands, then running sudo nixos-rebuild switch, and finally waiting through a several minute long wall of text, it seems to have finally been rebuilt correctly!!!
Thank you for your help!
I will post a follow-up upon restarting to make sure that this is persistent!