Cannot override flake input of a flake input because the input gets transmuted into a registry indirect input #201

Closed
opened 2024-03-30 00:01:38 +00:00 by jade · 3 comments
Owner

Although the documentation says:

Transitive inputs can be overridden from a `flake.nix` file. For
example, the following overrides the `nixpkgs` input of the `nixops`
input:

inputs.nixops.inputs.nixpkgs = {
  type = "github";
  owner = "my-org";
  repo = "nixpkgs";
};

this is actually an utter lie, as observed by @rbt on real code, and me later on my machine that happens to murder the flake registry with fire. I am unsure if this is a regression or if it simply was never tested properly to begin with.

Consider the following reproduction:

flake.nix:

{
  inputs.unused.url = "github:mercurytechnologies/unused-flake-input";
  inputs.input2 = {
    url = "path:./input2";
    inputs.poetry2nix = {
      # registry indirect because it has no URL, lol
      inputs.nixpkgs.follows = "unused";
    };
  };

  outputs = {...}: {};
}

input2/flake.nix:

{
  inputs.poetry2nix.url = "github:/nix-community/poetry2nix";

  outputs = {...}: {};
}
bug/root » ~/dev/lix/build/src/nix/nix --extra-experimental-features 'nix-command flakes' --flake-registry '' flake lock -vvvvv --debug       
warning: Git tree '/home/jade/dev/lix/bug/root' is dirty
performing daemon worker op: 7
acquiring write lock on '/nix/var/nix/temproots/435858'
locking path '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source'
lock acquired on '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source.lock'
lock released on '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source.lock'
performing daemon worker op: 26
got tree '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source' from 'git+file:///home/jade/dev/lix/bug
/root'
checking access to '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source/flake.nix'
evaluating file '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source/flake.nix'
performing daemon worker op: 19
old lock file: {
  "nodes": {
    "flake-utils": {
      "inputs": {
        "systems": "systems"
      },
      "locked": {
        "lastModified": 1705309234,
        "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "input2": {
      "inputs": {
        "poetry2nix": "poetry2nix"
      },
      "locked": {
        "lastModified": 1,
        "narHash": "sha256-665Hw+OZisPfCkscViuG/hjZe0bbQAnrOszVM96ztE0=",
        "path": "./input2",
        "type": "path"
      },
      "original": {
        "path": "./input2",
        "type": "path"
      }
    },
    "nix-github-actions": {
      "inputs": {
        "nixpkgs": [
          "input2",
          "poetry2nix",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1703863825,
        "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "nix-github-actions",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1708422533,
        "narHash": "sha256-OJxUslyGM/Eni66IOq8WGCjpM3H0vEfdv+fwzUmsOSY=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "e1135102e9ae9f7fe84147f9700a17cf4839f97f",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "master",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "poetry2nix": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nix-github-actions": "nix-github-actions",
        "nixpkgs": "nixpkgs",
        "systems": "systems_2",
        "treefmt-nix": "treefmt-nix"
      },
      "locked": {
        "lastModified": 1708589824,
        "narHash": "sha256-2GOiFTkvs5MtVF65sC78KNVxQSmsxtk0WmV1wJ9V2ck=",
        "owner": "nix-community",
        "repo": "poetry2nix",
        "rev": "3c92540611f42d3fb2d0d084a6c694cd6544b609",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "poetry2nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "input2": "input2",
        "unused": "unused"
      }
    },
    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }
    },
    "systems_2": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },
      "original": {
        "id": "systems",
        "type": "indirect"
      }
    },
    "treefmt-nix": {
      "inputs": {
        "nixpkgs": [
          "input2",
          "poetry2nix",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1708335038,
        "narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=",
        "owner": "numtide",
        "repo": "treefmt-nix",
        "rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "treefmt-nix",
        "type": "github"
      }
    },
    "unused": {
      "locked": {
        "lastModified": 1711740499,
        "narHash": "sha256-aqDoLFCsX0gSuR8HbQq8Qtsq+4KTbnji6XoXBPJITpY=",
        "owner": "mercurytechnologies",
        "repo": "unused-flake-input",
        "rev": "80edad13cab356d2ff6b8e42454c9855fc38de5f",
        "type": "github"
      },
      "original": {
        "owner": "mercurytechnologies",
        "repo": "unused-flake-input",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}
computing lock file node ''
computing input 'input2'
keeping existing input 'input2'
computing lock file node 'input2'
computing input 'input2/poetry2nix'
creating new input 'input2/poetry2nix'
error:
       … while updating the lock file of flake 'git+file:///home/jade/dev/lix/bug/root'

       … while updating the flake input 'input2'

       … while updating the flake input 'input2/poetry2nix'

       error: cannot find flake 'flake:poetry2nix' in the flake registries
Although the documentation says: ``` Transitive inputs can be overridden from a `flake.nix` file. For example, the following overrides the `nixpkgs` input of the `nixops` input: inputs.nixops.inputs.nixpkgs = { type = "github"; owner = "my-org"; repo = "nixpkgs"; }; ``` this is actually an utter lie, as observed by @rbt on real code, and me later on my machine that happens to murder the flake registry with fire. I am unsure if this is a regression or if it simply was never tested properly to begin with. Consider the following reproduction: `flake.nix`: ```nix { inputs.unused.url = "github:mercurytechnologies/unused-flake-input"; inputs.input2 = { url = "path:./input2"; inputs.poetry2nix = { # registry indirect because it has no URL, lol inputs.nixpkgs.follows = "unused"; }; }; outputs = {...}: {}; } ``` `input2/flake.nix`: ```nix { inputs.poetry2nix.url = "github:/nix-community/poetry2nix"; outputs = {...}: {}; } ``` ``` bug/root » ~/dev/lix/build/src/nix/nix --extra-experimental-features 'nix-command flakes' --flake-registry '' flake lock -vvvvv --debug warning: Git tree '/home/jade/dev/lix/bug/root' is dirty performing daemon worker op: 7 acquiring write lock on '/nix/var/nix/temproots/435858' locking path '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source' lock acquired on '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source.lock' lock released on '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source.lock' performing daemon worker op: 26 got tree '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source' from 'git+file:///home/jade/dev/lix/bug /root' checking access to '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source/flake.nix' evaluating file '/nix/store/if5yk4xjxvpik1arjxvqdmynfbxsrhb8-source/flake.nix' performing daemon worker op: 19 old lock file: { "nodes": { "flake-utils": { "inputs": { "systems": "systems" }, "locked": { "lastModified": 1705309234, "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "input2": { "inputs": { "poetry2nix": "poetry2nix" }, "locked": { "lastModified": 1, "narHash": "sha256-665Hw+OZisPfCkscViuG/hjZe0bbQAnrOszVM96ztE0=", "path": "./input2", "type": "path" }, "original": { "path": "./input2", "type": "path" } }, "nix-github-actions": { "inputs": { "nixpkgs": [ "input2", "poetry2nix", "nixpkgs" ] }, "locked": { "lastModified": 1703863825, "narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=", "owner": "nix-community", "repo": "nix-github-actions", "rev": "5163432afc817cf8bd1f031418d1869e4c9d5547", "type": "github" }, "original": { "owner": "nix-community", "repo": "nix-github-actions", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1708422533, "narHash": "sha256-OJxUslyGM/Eni66IOq8WGCjpM3H0vEfdv+fwzUmsOSY=", "owner": "NixOS", "repo": "nixpkgs", "rev": "e1135102e9ae9f7fe84147f9700a17cf4839f97f", "type": "github" }, "original": { "owner": "NixOS", "ref": "master", "repo": "nixpkgs", "type": "github" } }, "poetry2nix": { "inputs": { "flake-utils": "flake-utils", "nix-github-actions": "nix-github-actions", "nixpkgs": "nixpkgs", "systems": "systems_2", "treefmt-nix": "treefmt-nix" }, "locked": { "lastModified": 1708589824, "narHash": "sha256-2GOiFTkvs5MtVF65sC78KNVxQSmsxtk0WmV1wJ9V2ck=", "owner": "nix-community", "repo": "poetry2nix", "rev": "3c92540611f42d3fb2d0d084a6c694cd6544b609", "type": "github" }, "original": { "owner": "nix-community", "repo": "poetry2nix", "type": "github" } }, "root": { "inputs": { "input2": "input2", "unused": "unused" } }, "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } }, "systems_2": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "id": "systems", "type": "indirect" } }, "treefmt-nix": { "inputs": { "nixpkgs": [ "input2", "poetry2nix", "nixpkgs" ] }, "locked": { "lastModified": 1708335038, "narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=", "owner": "numtide", "repo": "treefmt-nix", "rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65", "type": "github" }, "original": { "owner": "numtide", "repo": "treefmt-nix", "type": "github" } }, "unused": { "locked": { "lastModified": 1711740499, "narHash": "sha256-aqDoLFCsX0gSuR8HbQq8Qtsq+4KTbnji6XoXBPJITpY=", "owner": "mercurytechnologies", "repo": "unused-flake-input", "rev": "80edad13cab356d2ff6b8e42454c9855fc38de5f", "type": "github" }, "original": { "owner": "mercurytechnologies", "repo": "unused-flake-input", "type": "github" } } }, "root": "root", "version": 7 } computing lock file node '' computing input 'input2' keeping existing input 'input2' computing lock file node 'input2' computing input 'input2/poetry2nix' creating new input 'input2/poetry2nix' error: … while updating the lock file of flake 'git+file:///home/jade/dev/lix/bug/root' … while updating the flake input 'input2' … while updating the flake input 'input2/poetry2nix' error: cannot find flake 'flake:poetry2nix' in the flake registries ```
jade added the
bug
docs
labels 2024-03-30 00:01:38 +00:00
jade added the
Area/flakes
label 2024-03-30 00:04:22 +00:00
Owner
this one is really fun because [upstream has known about it for years](https://github.com/NixOS/nix/issues/5790), and [fixed it shortly after reporting](https://github.com/NixOS/nix/pull/6621), but then [reverted it in favor of lazy trees](https://github.com/NixOS/nix/issues/5790#issuecomment-1315831247) in a [self-merge without review](https://github.com/NixOS/nix/pull/6983)
Author
Owner

WELL since we're unshipping the original lazy trees we probably could unship the bug too. WAIT did upstream even fix this after??! We originally found this on Nix 2.21... did... did they even fix it after reverting the previous fix?

WELL since we're unshipping the original lazy trees we *probably* could unship the bug too. WAIT did upstream even fix this after??! We originally found this on Nix 2.21... did... did they even fix it after reverting the previous fix?
Owner

nope!

nope!
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#201
No description provided.