Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro-exp-03-25-grounding· GoogleHugging Face LMArena Search Arena 24K

What line do I have to write to enable flakes in nixos?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Perplexitysonar’s answer.
  1. User

    What line do I have to write to enable flakes in nixos?

  2. Gemini Assistant

    To enable flakes permanently in NixOS, you need to add the following line to your system configuration file, typically located at /etc/nixos/configuration.nix:

    nix.settings.experimental-features = [ "nix-command" "flakes" ];
    

    Here's how to do it:

    1. Edit your configuration file: Open /etc/nixos/configuration.nix with a text editor (you'll likely need sudo).
    2. Add the line: Place the nix.settings.experimental-features = [ "nix-command" "flakes" ]; line within the main configuration set (inside the { [1]... }: block)[4][5].
    3. Rebuild your system: After saving the file, run the command sudo nixos-rebuild switch to apply the changes and activate the flakes feature[7].

    Example context within configuration.nix:

    { config, pkgs, ... }:
    
    {
      imports =
        [ # Include the results of the hardware scan.
          ./hardware-configuration.nix
        ];
    
      # Bootloader configuration, network settings, etc.
      # ... other system settings ...
    
      # Enable the Flakes feature and the accompanying new nix command-line tool
      nix.settings.experimental-features = [ "nix-command" "flakes" ];
    
      # Add other settings like users, packages, services, etc.
      users.users.your_username = {
        isNormalUser = true;
        # ... other user settings ...
      };
    
      environment.systemPackages = with pkgs; [
        git # Often needed for flakes
        vim # Example package
        wget # Example package
      ];
    
      # ... rest of your configuration ...
    
      system.stateVersion = "23.11"[8]; # Or your appropriate version
    }
    

    Why is this needed?

    Nix Flakes are still considered an experimental feature in the Nix ecosystem, although they are widely used. Enabling this setting explicitly tells Nix to activate support for the nix command-line interface improvements and the flakes feature itself, which provides better reproducibility and dependency management.

    Once enabled, commands like nixos-rebuild switch will look for a /etc/nixos/flake.nix file first before falling back to /etc/nixos/configuration.nix, allowing you to transition your system configuration fully to flakes if desired[5].

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.