-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
nix flake prefetch --json reports inconsistent information after Nix 2.27 #13049
Copy link
Copy link
Closed
Labels
Description
Describe the bug
The "locked" attribute of the output will only sometimes contain the narHash of the Flake
Steps To Reproduce
- Run
nix flake prefetch --jsonon a localpath:type Flake (e.g., thenixpkgsregistry entry in NixOS by default) - Run
nix flake prefetch --jsonon a remote Flake (e.g.,github;)
Expected behavior
locked.narHash is consistently reported
Metadata
nix-env (Nix) 2.28.1
Additional context
With the following `nix flake metadata` output for different Flakes
$ nix flake metadata nixpkgs
Resolved URL: path:/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source?lastModified=1744463964&narHash=sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR%2BXhw3kr/3Xd0GPTM%3D&rev=2631b0b7abcea6e640ce31cd78ea58910d31e650
Locked URL: path:/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source?lastModified=1744463964&narHash=sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR%2BXhw3kr/3Xd0GPTM%3D&rev=2631b0b7abcea6e640ce31cd78ea58910d31e650
Description: A collection of packages for the Nix package manager
Path: /nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source
Revision: 2631b0b7abcea6e640ce31cd78ea58910d31e650
Last modified: 2025-04-12 09:19:24
Fingerprint: 69bcf68d2f795758132d280b52882973cf81960aaa93af45417a6758921728ea
$ nix flake metadata github:NixOS/nix
Resolved URL: github:NixOS/nix
Locked URL: github:NixOS/nix/f683a555bf3e258ca7e3669d51993587f6a641d0?narHash=sha256-eErpyq4Fdvz%2Bcla8NmTiwJ0WdrYKDeJ0nlvion5FhmQ%3D
Description: The purely functional package manager
Path: /nix/store/mhdcdd15m3zmyw8xkzbw39h0alzpsp7y-source
Revision: f683a555bf3e258ca7e3669d51993587f6a641d0
Last modified: 2025-04-18 01:27:04
Fingerprint: d7e7a6c5fe739e2fa0689a2ca8ea4e8d277a7f2271725325564167f2722a4849
Inputs:
├───flake-compat: github:edolstra/flake-compat/ff81ac966bb2cae68946d5ed5fc4994f96d0ffec?narHash=sha256-NeCCThCEP3eCl2l/%2B27kNNK7QrwZB1IJCrXfrbv5oqU%3D (2024-12-04 16:08:25)
├───flake-parts: github:hercules-ci/flake-parts/205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9?narHash=sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c%3D (2024-12-04 11:43:21)
│ └───nixpkgs-lib follows input 'nixpkgs'
├───git-hooks-nix: github:cachix/git-hooks.nix/aa9f40c906904ebd83da78e7f328cd8aeaeae785?narHash=sha256-NdaCraHPp8iYMWzdXAt5Nv6sA3MUzlCiGiR586TCwo0%3D (2024-12-15 16:26:21)
│ ├───flake-compat follows input ''
│ ├───gitignore follows input ''
│ ├───nixpkgs follows input 'nixpkgs'
│ └───nixpkgs-stable follows input 'nixpkgs'
├───nixpkgs: github:NixOS/nixpkgs/52faf482a3889b7619003c0daec593a1912fddc1?narHash=sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om%2BD4UnDhlDW9BE%3D (2025-03-30 06:12:12)
├───nixpkgs-23-11: github:NixOS/nixpkgs/a62e6edd6d5e1fa0329b8653c801147986f8d446?narHash=sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw%3D (2024-05-31 12:45:33)
└───nixpkgs-regression: github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2?narHash=sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw%3D (2022-01-24 19:20:45)You will get the following outputs (Note that both contain a `hash`, but not `locked.narHash`)
$ nix flake prefetch nixpkgs --json | jq '.'
{
"hash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
"locked": {
"__final": true,
"lastModified": 1744463964,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
"path": "/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source",
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
"type": "path"
},
"original": {
"lastModified": 1744463964,
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
"path": "/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source",
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
"type": "path"
},
"storePath": "/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source"
}
$ nix flake prefetch github:NixOS/nix --json | jq '.'
{
"hash": "sha256-eErpyq4Fdvz+cla8NmTiwJ0WdrYKDeJ0nlvion5FhmQ=",
"locked": {
"__final": true,
"lastModified": 1744954024,
"owner": "NixOS",
"repo": "nix",
"rev": "f683a555bf3e258ca7e3669d51993587f6a641d0",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nix",
"type": "github"
},
"storePath": "/nix/store/mhdcdd15m3zmyw8xkzbw39h0alzpsp7y-source"
}This doesn't occur in Nix < 2.27
After a bit of bisecting, it seems this was introduced in #12421 via c74ad6b.
Thanks to @isabelroses for noticing this in catppuccin/nix#542. The bump to Nix 2.28 in Nixpkgs revealed this by breaking our current parsing of this output
Checklist
- checked latest Nix manual (source)
- checked open bug issues and pull requests for possible duplicates
Add 👍 to issues you find important.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Projects
Status
Done