nix flake lock does not update transitive inputs to the upstream transitive inputs, even if the input itself changed #465

Open
opened 2024-08-13 02:08:40 +00:00 by jade · 1 comment
Owner

Related to #8.

Changing a flake input URL to a newer version and then running nix flake lock incorrectly does not update any of the inputs of that input, even if there is nothing holding them at their current version.

Initial state: URL is set to the one for Lix 2.90.0 as follows:

lock1.json (repro gist commit a8b4606), initial state

flake.nix:

{
  description = "The Lix Installer";

  inputs = {
    lix = {
      # See set_version.py
      # BEGIN GENERATE-URLS
      url = "https://git.lix.systems/lix-project/lix/archive/2.90.0.tar.gz";
      # END GENERATE-URLS
      # Omitting `inputs.nixpkgs.follows = "nixpkgs";` on purpose
    };
  };

  outputs = { self , lix , ... }: {};
}
flake.lock
{
  "nodes": {
    "flake-compat": {
      "flake": false,
      "locked": {
        "lastModified": 1696426674,
        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
        "owner": "edolstra",
        "repo": "flake-compat",
        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
        "type": "github"
      },
      "original": {
        "owner": "edolstra",
        "repo": "flake-compat",
        "type": "github"
      }
    },
    "lix": {
      "inputs": {
        "flake-compat": "flake-compat",
        "nix2container": "nix2container",
        "nixpkgs": "nixpkgs",
        "nixpkgs-regression": "nixpkgs-regression",
        "pre-commit-hooks": "pre-commit-hooks"
      },
      "locked": {
        "lastModified": 1723503926,
        "narHash": "sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s=",
        "rev": "bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2",
        "type": "tarball",
        "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2.tar.gz?rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2"
      },
      "original": {
        "type": "tarball",
        "url": "https://git.lix.systems/lix-project/lix/archive/2.91.0.tar.gz"
      }
    },
    "nix2container": {
      "flake": false,
      "locked": {
        "lastModified": 1720642556,
        "narHash": "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is=",
        "owner": "nlewo",
        "repo": "nix2container",
        "rev": "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4",
        "type": "github"
      },
      "original": {
        "owner": "nlewo",
        "repo": "nix2container",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1721931987,
        "narHash": "sha256-1Zg8LY0T5EfXtv0Kf4M6SFnjH7Eto4VV+EKJ/YSnhiI=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "e21630230c77140bc6478a21cd71e8bb73706fce",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-24.05-small",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-regression": {
      "locked": {
        "lastModified": 1643052045,
        "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
        "type": "github"
      }
    },
    "pre-commit-hooks": {
      "flake": false,
      "locked": {
        "lastModified": 1721042469,
        "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=",
        "owner": "cachix",
        "repo": "git-hooks.nix",
        "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "repo": "git-hooks.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "lix": "lix"
      }
    }
  },
  "root": "root",
  "version": 7
}
/tmp/lixbug » git commit -m 'initial state'
[main (root-commit) a8b4606] initial state
 2 files changed, 126 insertions(+)
 create mode 100644 flake.lock
 create mode 100644 flake.nix

Technically even here the lock file is out of date because of this bug previously affecting the Lix installer. But don't mind that, it would happen even if it were not broken that way.

lock2.json (repro gist commit 54af1e0), clearly broken state

Then we update the 2.90.0 in the URL above to 2.91.0 and run nix flake lock.

/tmp/lixbug » nix flake lock
warning: Git tree '/tmp/lixbug' is dirty
warning: updating lock file '/tmp/lixbug/flake.lock':
• Updated input 'lix':
    'https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a4376be20d70feaa2b0e640c5041fb66ddc67ed.tar.gz?
narHash=sha256-f8k%2BBezKdJfmE%2Bk7zgBJiohtS3VkkriycdXYsKOm3sc%3D' (2024-07-10)
  → 'https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2.tar.gz?
narHash=sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s%3D&rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2' (2024-
08-12)
warning: Git tree '/tmp/lixbug' is dirty

/tmp/lixbug » git add -u
/tmp/lixbug » git commit -m 'on nix flake lock'
[main 54af1e0] on nix flake lock
 2 files changed, 6 insertions(+), 6 deletions(-)
/tmp/lixbug » json-diff lock1.json lock2.json
 {
   nodes: {
     lix: {
       locked: {
-        lastModified: 1720626042
+        lastModified: 1723503926
-        narHash: "sha256-f8k+BezKdJfmE+k7zgBJiohtS3VkkriycdXYsKOm3sc="
+        narHash: "sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s="
-        rev: "2a4376be20d70feaa2b0e640c5041fb66ddc67ed"
+        rev: "bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2"
-        url: "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a4376be20d70feaa2b0e640c5041fb66ddc67
ed.tar.gz"
+        url: "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6b
d2.tar.gz?rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2"
       }
       original: {
-        url: "https://git.lix.systems/lix-project/lix/archive/2.90.0.tar.gz"
+        url: "https://git.lix.systems/lix-project/lix/archive/2.91.0.tar.gz"
       }
     }
   }
 }

This commit describes the broken state.

lock3.json (repro gist commit 35a7298)

From this broken state, we can update the inputs of lix by running nix flake update lix:

Observe that it updates the inputs of Lix in the lock file even though it does not update lix itself.

/tmp/lixbug » nix flake update lix
warning: updating lock file '/tmp/lixbug/flake.lock':
• Updated input 'lix/nix2container':
    'github:nlewo/nix2container/20aad300c925639d5d6cbe30013c8357ce9f2a2e' (2024-04-13)
  → 'github:nlewo/nix2container/3853e5caf9ad24103b13aa6e0e8bcebb47649fe4' (2024-07-10)
• Updated input 'lix/nixpkgs':
    'github:NixOS/nixpkgs/93fbfcd45e966ea1cff043d48bd45d1285082770' (2024-06-14)
  → 'github:NixOS/nixpkgs/e21630230c77140bc6478a21cd71e8bb73706fce' (2024-07-25)
• Updated input 'lix/pre-commit-hooks':
    'github:cachix/git-hooks.nix/e35aed5fda3cc79f88ed7f1795021e559582093a' (2024-04-02)
  → 'github:cachix/git-hooks.nix/f451c19376071a90d8c58ab1a953c6e9840527fd' (2024-07-15)
warning: Git tree '/tmp/lixbug' is dirty

/tmp/lixbug » git add -u
/tmp/lixbug » git commit -m 'after nix flake update'
[main 35a7298] after nix flake update
 1 file changed, 9 insertions(+), 9 deletions(-)
/tmp/lixbug » json-diff lock2.json lock3.json
 {
   nodes: {
     nix2container: {
       locked: {
-        lastModified: 1712990762
+        lastModified: 1720642556
-        narHash: "sha256-hO9W3w7NcnYeX8u8cleHiSpK2YJo7ecarFTUlbybl7k="
+        narHash: "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is="
-        rev: "20aad300c925639d5d6cbe30013c8357ce9f2a2e"
+        rev: "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4"
       }
     }
     nixpkgs: {
       locked: {
-        lastModified: 1718379166
+        lastModified: 1721931987
-        narHash: "sha256-B/Q/Pf4kD+yWk3fGh5H0fUpwxmLgEKt9KBon+bZ3d9U="
+        narHash: "sha256-1Zg8LY0T5EfXtv0Kf4M6SFnjH7Eto4VV+EKJ/YSnhiI="
-        rev: "93fbfcd45e966ea1cff043d48bd45d1285082770"
+        rev: "e21630230c77140bc6478a21cd71e8bb73706fce"
       }
     }
     pre-commit-hooks: {
       locked: {
-        lastModified: 1712055707
+        lastModified: 1721042469
-        narHash: "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8="
+        narHash: "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70="
-        rev: "e35aed5fda3cc79f88ed7f1795021e559582093a"
+        rev: "f451c19376071a90d8c58ab1a953c6e9840527fd"
       }
     }
   }
 }

repro gist

You can git clone https://gist.github.com/lf-/dc9386df57c20df7561ea475664791b7 to get the full reproduction above as git history.

Expected behaviour

I would expect that updating a flake URL would cause the input to be re-fetched and its inputs updated to the latest ones. After all, to me, this state semantically means that the input is using the upstream inputs.

Version

nix (Lix, like Nix) 2.91.0-dev-pre20240807-529eed7

Related to #8. Changing a flake input URL to a newer version and then running `nix flake lock` incorrectly does not update any of the inputs of that input, even if there is nothing holding them at their current version. Initial state: URL is set to the one for Lix 2.90.0 as follows: ## lock1.json (repro gist commit `a8b4606`), initial state `flake.nix`: ```nix { description = "The Lix Installer"; inputs = { lix = { # See set_version.py # BEGIN GENERATE-URLS url = "https://git.lix.systems/lix-project/lix/archive/2.90.0.tar.gz"; # END GENERATE-URLS # Omitting `inputs.nixpkgs.follows = "nixpkgs";` on purpose }; }; outputs = { self , lix , ... }: {}; } ``` <details><summary>flake.lock</summary> ```json { "nodes": { "flake-compat": { "flake": false, "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { "owner": "edolstra", "repo": "flake-compat", "type": "github" } }, "lix": { "inputs": { "flake-compat": "flake-compat", "nix2container": "nix2container", "nixpkgs": "nixpkgs", "nixpkgs-regression": "nixpkgs-regression", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { "lastModified": 1723503926, "narHash": "sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s=", "rev": "bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2", "type": "tarball", "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2.tar.gz?rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2" }, "original": { "type": "tarball", "url": "https://git.lix.systems/lix-project/lix/archive/2.91.0.tar.gz" } }, "nix2container": { "flake": false, "locked": { "lastModified": 1720642556, "narHash": "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is=", "owner": "nlewo", "repo": "nix2container", "rev": "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4", "type": "github" }, "original": { "owner": "nlewo", "repo": "nix2container", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1721931987, "narHash": "sha256-1Zg8LY0T5EfXtv0Kf4M6SFnjH7Eto4VV+EKJ/YSnhiI=", "owner": "NixOS", "repo": "nixpkgs", "rev": "e21630230c77140bc6478a21cd71e8bb73706fce", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixos-24.05-small", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-regression": { "locked": { "lastModified": 1643052045, "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", "owner": "NixOS", "repo": "nixpkgs", "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", "type": "github" } }, "pre-commit-hooks": { "flake": false, "locked": { "lastModified": 1721042469, "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", "owner": "cachix", "repo": "git-hooks.nix", "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", "type": "github" }, "original": { "owner": "cachix", "repo": "git-hooks.nix", "type": "github" } }, "root": { "inputs": { "lix": "lix" } } }, "root": "root", "version": 7 } ``` </details> ``` /tmp/lixbug » git commit -m 'initial state' [main (root-commit) a8b4606] initial state 2 files changed, 126 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix ``` Technically even here the lock file is out of date because of this bug previously affecting the Lix installer. But don't mind that, it would happen even if it were not broken that way. ## lock2.json (repro gist commit `54af1e0`), clearly broken state Then we update the `2.90.0` in the URL above to `2.91.0` and run `nix flake lock`. ``` /tmp/lixbug » nix flake lock warning: Git tree '/tmp/lixbug' is dirty warning: updating lock file '/tmp/lixbug/flake.lock': • Updated input 'lix': 'https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a4376be20d70feaa2b0e640c5041fb66ddc67ed.tar.gz? narHash=sha256-f8k%2BBezKdJfmE%2Bk7zgBJiohtS3VkkriycdXYsKOm3sc%3D' (2024-07-10) → 'https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2.tar.gz? narHash=sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s%3D&rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2' (2024- 08-12) warning: Git tree '/tmp/lixbug' is dirty /tmp/lixbug » git add -u /tmp/lixbug » git commit -m 'on nix flake lock' [main 54af1e0] on nix flake lock 2 files changed, 6 insertions(+), 6 deletions(-) ``` ```diff /tmp/lixbug » json-diff lock1.json lock2.json { nodes: { lix: { locked: { - lastModified: 1720626042 + lastModified: 1723503926 - narHash: "sha256-f8k+BezKdJfmE+k7zgBJiohtS3VkkriycdXYsKOm3sc=" + narHash: "sha256-Rosl9iA9MybF5Bud4BTAQ9adbY81aGmPfV8dDBGl34s=" - rev: "2a4376be20d70feaa2b0e640c5041fb66ddc67ed" + rev: "bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2" - url: "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2a4376be20d70feaa2b0e640c5041fb66ddc67 ed.tar.gz" + url: "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/bcaeb6388b8916ac6d1736e3aa2b13313e6a6b d2.tar.gz?rev=bcaeb6388b8916ac6d1736e3aa2b13313e6a6bd2" } original: { - url: "https://git.lix.systems/lix-project/lix/archive/2.90.0.tar.gz" + url: "https://git.lix.systems/lix-project/lix/archive/2.91.0.tar.gz" } } } } ``` This commit describes the broken state. ## lock3.json (repro gist commit `35a7298`) From this broken state, we can update the inputs of `lix` by running `nix flake update lix`: Observe that it updates the inputs of Lix in the lock file even though it does not update lix itself. ``` /tmp/lixbug » nix flake update lix warning: updating lock file '/tmp/lixbug/flake.lock': • Updated input 'lix/nix2container': 'github:nlewo/nix2container/20aad300c925639d5d6cbe30013c8357ce9f2a2e' (2024-04-13) → 'github:nlewo/nix2container/3853e5caf9ad24103b13aa6e0e8bcebb47649fe4' (2024-07-10) • Updated input 'lix/nixpkgs': 'github:NixOS/nixpkgs/93fbfcd45e966ea1cff043d48bd45d1285082770' (2024-06-14) → 'github:NixOS/nixpkgs/e21630230c77140bc6478a21cd71e8bb73706fce' (2024-07-25) • Updated input 'lix/pre-commit-hooks': 'github:cachix/git-hooks.nix/e35aed5fda3cc79f88ed7f1795021e559582093a' (2024-04-02) → 'github:cachix/git-hooks.nix/f451c19376071a90d8c58ab1a953c6e9840527fd' (2024-07-15) warning: Git tree '/tmp/lixbug' is dirty /tmp/lixbug » git add -u /tmp/lixbug » git commit -m 'after nix flake update' [main 35a7298] after nix flake update 1 file changed, 9 insertions(+), 9 deletions(-) ``` ```diff /tmp/lixbug » json-diff lock2.json lock3.json { nodes: { nix2container: { locked: { - lastModified: 1712990762 + lastModified: 1720642556 - narHash: "sha256-hO9W3w7NcnYeX8u8cleHiSpK2YJo7ecarFTUlbybl7k=" + narHash: "sha256-qsnqk13UmREKmRT7c8hEnz26X3GFFyIQrqx4EaRc1Is=" - rev: "20aad300c925639d5d6cbe30013c8357ce9f2a2e" + rev: "3853e5caf9ad24103b13aa6e0e8bcebb47649fe4" } } nixpkgs: { locked: { - lastModified: 1718379166 + lastModified: 1721931987 - narHash: "sha256-B/Q/Pf4kD+yWk3fGh5H0fUpwxmLgEKt9KBon+bZ3d9U=" + narHash: "sha256-1Zg8LY0T5EfXtv0Kf4M6SFnjH7Eto4VV+EKJ/YSnhiI=" - rev: "93fbfcd45e966ea1cff043d48bd45d1285082770" + rev: "e21630230c77140bc6478a21cd71e8bb73706fce" } } pre-commit-hooks: { locked: { - lastModified: 1712055707 + lastModified: 1721042469 - narHash: "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=" + narHash: "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=" - rev: "e35aed5fda3cc79f88ed7f1795021e559582093a" + rev: "f451c19376071a90d8c58ab1a953c6e9840527fd" } } } } ``` ## repro gist You can `git clone https://gist.github.com/lf-/dc9386df57c20df7561ea475664791b7` to get the full reproduction above as git history. ## Expected behaviour I would expect that updating a flake URL would cause the input to be re-fetched and its inputs updated to the latest ones. After all, to me, this state semantically means that the input is *using the upstream inputs*. ## Version nix (Lix, like Nix) 2.91.0-dev-pre20240807-529eed7
jade added the
bug
Area/flakes
E/help wanted
labels 2024-08-13 02:09:19 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1782 ("Fix: make Lix actually update the lock file correctly")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix-installer/+/1782", "number": 1782, "kind": "commit message"}], "cl_meta": {"1782": {"change_title": "Fix: make Lix actually update the lock file correctly"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1782](https://gerrit.lix.systems/c/lix-installer/+/1782) ("Fix: make Lix actually update the lock file correctly")
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#465
No description provided.