Skip to content

Flakes are still required #429

Closed as duplicate
Closed as duplicate

Description

@toastal

Despite requiring flake-compat as a dependency for both stable & flake users, flakes are still required to run the build.

$ nix-build
unpacking 'https://github.com/NixOS/flake-compat/archive/5edf11c44bc78a0d334f6334cdaf7d60d732daab.tar.gz' into the Git cache...
error:
       … in the left operand of the update (//) operator
         at $XDG_PROJECTS_DIR/nixfmt/default.nix:9:1:
            8| in
            9| result.packages.nixfmt // result
             | ^
           10|

       … while evaluating the attribute 'packages.nixfmt'
         at $XDG_PROJECTS_DIR/nixfmt/main.nix:152:5:
          151|   packages = {
          152|     nixfmt = build;
             |     ^
          153|     nixfmt-static = buildStatic;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

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

Activity

  1. jfly commented on Jul 11, 2026

    @jfly
    Collaborator

    @toastal, I cannot reproduce this (running on 7cad866):

    ╭─ ~/src/github.com/NixOS/nixfmt 11:42:14 (master)
    ╰─❯ nix flake show
    error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
    
    ╭─ ~/src/github.com/NixOS/nixfmt 11:42:15 (master)
    ╰─[1]❯ nix-build
    /nix/store/03ax9bj5vsl5ihg0nxp3pjs8ivld21xm-nixfmt-1.4.0

    Can you provide more instructions to repro?

  2. toastal commented on Jul 11, 2026

    @toastal
    ContributorAuthor

    Like a system config? Not much to say other than

    $ nix --version
    nix (Nix) 2.34.8
    $ which nix
    /run/current-system/sw/bin/nix
    $ realpath $(which nix)
    /nix/store/v0670lgzdj7pcfk044g3hxwyjnk9jvrk-nix-2.34.8/bin/nix
    $ grep "PRETTY" /etc/os-release
    PRETTY_NAME="NixOS 26.11 (Zokor)"
    $ grep "experimental" /etc/nix/nix.conf 
    extra-experimental-features = nix-command fetch-tree blake3-hashes
    $ stat $XDG_CONFIG_HOME/nix/nix.conf
    stat: cannot statx '$XDG_CONFIG_HOME/nix/nix.conf': No such file or directory
  3. jfly commented on Jul 11, 2026

    @jfly
    Collaborator

    I was thinking more like: what's the default.nix file you're running in the OP?

  4. toastal commented on Jul 11, 2026

    @toastal
    Author
  5. toastal commented on Jul 11, 2026

    @toastal
    ContributorAuthor

    Note: nix-build --arg nixpkgs "<nixpkgs>" works… maybe it should be the default nixpkgs ? <nixpkgs> for default.nix?

  6. jfly commented on Jul 11, 2026

    @jfly
    Collaborator

    Ok, so you're just running nix-build at the root of the nixfmt repo? Sorry, I wasn't sure if you were pulling in indirectly through some other project.

    Note: nix-build --arg nixpkgs "" works… maybe it should be the default nixpkgs ? for default.nix?

    I'd like to understand how to reproduce the issue before discussing fixes.

  7. MattSturgeon commented on Jul 11, 2026

    @MattSturgeon
    Contributor

    I can't reproduce with:

    $ nix-build --option experimental-features "" --option extra-experimental-features ""
    /nix/store/03ax9bj5vsl5ihg0nxp3pjs8ivld21xm-nixfmt-1.4.0

    from the root directory of the latest master.

  8. MattSturgeon commented on Jul 11, 2026

    @MattSturgeon
    Contributor
    $ grep "experimental" /etc/nix/nix.conf 
    extra-experimental-features = nix-command fetch-tree blake3-hashes

    But I can with:

    $ nix-build --option experimental-features fetch-tree
    error:
           … in the left operand of the update (//) operator
             at /home/matt/code/nixfmt/default.nix:9:1:
                8| in
                9| result.packages.nixfmt // result
                 | ^
               10|
    
           … while evaluating the attribute 'packages.nixfmt'
             at /home/matt/code/nixfmt/main.nix:152:5:
              151|   packages = {
              152|     nixfmt = build;
                 |     ^
              153|     nixfmt-static = buildStatic;
    
           (stack trace truncated; use '--show-trace' to show the full, detailed trace)
    
           error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it

    It looks like you're running into an upstream bug with builtins.fetchTree: NixOS/nix#5541

    If you don't want to enable flakes, you'll need to disable fetch-tree until that issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions