I switched to flakes following the manual page and this guide: Introduction to Flakes | NixOS & Flakes Book
My configuration is being created from flake.nix and I’m building using
nixos-rebuild switch --flake 'path:.#desktop'
My flake.nix contains
{
description = "Tom's Desktop";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url ="github:nix-community/impermanence/master";
};
outputs = { self, nixpkgs, home-manager, impermanence, nur, ... }@inputs:
let
globals = import ./globals.nix;
in {
users.mutableUsers = false;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nixosConfigurations.desktop = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hardware
./system
home-manager.nixosModules.home-manager
impermanence.nixosModules.impermanence
./users/root
./users/${globals.user}
{
_module.args = { inherit inputs globals; };
}
];
};
};
}
But when I run nix flake init
I get
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
I can run it with --extra-experimental-features nix-command
as suggested and it works but the manual suggests that the nix.settings.experimental-features
is permanent and the argument shouldn’t be required.
The problem is, that other tools which rely on the setting e.g.
nixos-container create foo --config '
services.httpd.enable = true;
'
breaks with the same error about flakes not being enabled yet doesn’t support the --extra-experimental-features
argument directly.
It looks like nix.settings.experimental-features
enables the feature for nixos-rebuild
but not system wide