Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Removing follows does not respect dependency's flake.lock #14339

@samestep

Description

@samestep

Describe the bug

If I have a flake input with a transitive input constrained via follows, then I remove that follows constraint, the new transitive input version in my flake.lock ignores that dependency's original flake.lock.

Steps To Reproduce

  1. Create a flake.nix with oxalica/rust-overlay@1d1c8a0 as the only input:

    {
      inputs = {
        rust-overlay.url = "github:oxalica/rust-overlay/1d1c8a009adeb4c0561bb1feea8ec7b97749946b";
      };
      outputs = { ... }: { };
    }
  2. Run nix flake lock, observing that the transitive input is NixOS/nixpkgs@18dd725, the same commit as in rust-overlay's flake.lock:

    $ nix flake lock
    • Added input 'rust-overlay':
        'github:oxalica/rust-overlay/1d1c8a009adeb4c0561bb1feea8ec7b97749946b?narHash=sha256-mylLEdzqx4M9TrwFIPc%2Bo0dqabHvFGbNJZGRgE43Ya0%3D' (2025-10-23)
    • Added input 'rust-overlay/nixpkgs':
        'github:NixOS/nixpkgs/18dd725c29603f582cf1900e0d25f9f1063dbf11?narHash=sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38%3D' (2025-04-13)
    
  3. Add a separate input for NixOS/nixpkgs@87848bf:

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/87848bf0cc4f87717fc813a4575f07330c3e743c";
        rust-overlay.url = "github:oxalica/rust-overlay/1d1c8a009adeb4c0561bb1feea8ec7b97749946b";
      };
      outputs = { ... }: { };
    }
  4. Run nix flake lock again:

    $ nix flake lock
    • Added input 'nixpkgs':
        'github:NixOS/nixpkgs/87848bf0cc4f87717fc813a4575f07330c3e743c?narHash=sha256-/oUYsC0lUCBory65VK%2BUHqCCsCspbL1Vgfcf1KUYqVw%3D' (2025-10-20)
    
  5. Constrain rust-overlay's transitive Nixpkgs input to follow our direct Nixpkgs input:

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/87848bf0cc4f87717fc813a4575f07330c3e743c";
        rust-overlay = {
          url = "github:oxalica/rust-overlay/1d1c8a009adeb4c0561bb1feea8ec7b97749946b";
          inputs.nixpkgs.follows = "nixpkgs";
        };
      };
      outputs = { ... }: { };
    }
  6. Run nix flake lock again:

    $ nix flake lock
    • Updated input 'rust-overlay/nixpkgs':
        'github:NixOS/nixpkgs/18dd725c29603f582cf1900e0d25f9f1063dbf11?narHash=sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38%3D' (2025-04-13)
      → follows 'nixpkgs'
    
  7. Remove that constraint:

    {
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/87848bf0cc4f87717fc813a4575f07330c3e743c";
        rust-overlay.url = "github:oxalica/rust-overlay/1d1c8a009adeb4c0561bb1feea8ec7b97749946b";
      };
      outputs = { ... }: { };
    }
  8. Run nix flake lock a final time, observing that rust-overlay's transitive Nixpkgs input is now neither the NixOS/nixpkgs@18dd725 from rust-overlay's flake.lock, nor NixOS/nixpkgs@87848bf from the earlier inputs.nixpkgs.follows, but is instead whatever is the latest nixpkgs-unstable commit at the time the command is run:

    $ nix flake lock
    • Updated input 'rust-overlay/nixpkgs':
        follows 'nixpkgs'
      → 'github:NixOS/nixpkgs/cb82756ecc37fa623f8cf3e88854f9bf7f64af93?narHash=sha256-0JDOal5P7xzzAibvD0yTE3ptyvoVOAL0rcELmDdtSKg%3D' (2025-10-20)
    

Expected behavior

I expected rust-overlay's Nixpkgs input to revert back to NixOS/nixpkgs@18dd725 as specified in its flake.lock.

Metadata

I tested this with the current stable Nix on x86_64-linux:

$ nix-env --version
nix-env (Nix) 2.28.5

I also tested this with the current latest Nix on aarch64-darwin:

$ nix-env --version
nix-env (Determinate Nix 3.11.3) 2.31.2

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions