MacOS Sequoia: Fix Nix-search Indexing Failure (Attribute 'version' Missing)
Hey guys! So, we've got a bit of a situation here with indexing failing on macOS Sequoia 15.6 when using nix-search
. It seems to be a recurring issue, possibly related to some older problems, but with a fresh twist. Let's break down what's happening, why it's happening, and how we can potentially fix it.
The Problem: Indexing Errors with nix-search
So, the core issue is that when trying to use nix-search
, especially for the first time or when the index is outdated, the indexing process craps out. This is super annoying because nix-search
is a powerful tool for finding packages in Nixpkgs. Without a working index, it's basically useless. The error message we're seeing points to a failure in nix-instantiate
, which is a crucial part of the Nix build process.
Diving into the Error Messages
Let's look at the error messages we're getting. The basic nix-search foo
command gives us:
2025-08-13T11:51:48.981+0100 [INFO] first run or outdated index detected, will index packages
2025-08-13T11:51:48.981+0100 [INFO] indexing packages
2025-08-13T11:51:56.833+0100 [ERROR] error: err="failed to get package index: nix-instantiate: exit status 1"
This tells us that the indexing process started but failed with a non-zero exit code from nix-instantiate
. Not very helpful on its own, but it's the starting point.
Using the -v
flag for verbose output gives us a ton more information:
2025-08-13T11:52:39.320+0100 [INFO] first run or outdated index detected, will index packages
2025-08-13T11:52:39.320+0100 [INFO] indexing packages
2025-08-13T11:52:39.320+0100 [DEBUG] search.IndexPackages: indexing packages: nixpkgs=<nixpkgs> parallelism=14
2025-08-13T11:52:39.320+0100 [DEBUG] search.IndexPackages: worker: indexing: attrs=""
2025-08-13T11:52:39.320+0100 [DEBUG] search.IndexPackages: queued job: attrs=[]
...
2025-08-13T11:52:46.916+0100 [DEBUG] search.IndexPackages.nix-instantiate: error:
2025-08-13T11:52:46.916+0100 [DEBUG] search.IndexPackages.nix-instantiate: … while evaluating attribute 'more'
...
2025-08-13T11:52:46.916+0100 [DEBUG] search.IndexPackages.nix-instantiate: error: attribute 'version' missing
2025-08-13T11:52:46.916+0100 [DEBUG] search.IndexPackages.nix-instantiate: at /nix/store/c39q7pww80997lz0fyqxpvsr29q6f7ld-source/pkgs/top-level/unixtools.nix:47:30:
...
2025-08-13T11:52:46.950+0100 [ERROR] error: err="failed to get package index: nix-instantiate: exit status 1"
This is where things get interesting. We see a bunch of evaluation warnings (which are probably unrelated but good to be aware of) and then a critical error: attribute 'version' missing
. This suggests that the nix-search
indexing process is encountering a package in Nixpkgs that doesn't have a version
attribute defined in its metadata. This is not ideal and points to a potential issue in the Nixpkgs package definitions.
Digging Deeper with nix-instantiate
To confirm the issue, we can run the nix-instantiate
command directly with the --show-trace
flag. This gives us the full stack trace, making it easier to pinpoint the problem:
nix-instantiate --show-trace --eval --json --strict --arg attrs '[]' ./search/nix/dump_packages.nix
This command attempts to evaluate the dump_packages.nix
file, which is responsible for extracting package information for nix-search
. The output confirms the attribute 'version' missing
error and provides a detailed trace, showing exactly where the error occurs within the Nixpkgs code. In this case, it's in unixtools.nix
.
Trying a Flake-Based Index
The user also tried indexing using a flake:
nix-search --index --flake nixpkgs
But, unfortunately, this also failed with the same nix-instantiate
error, indicating that the issue isn't specific to the default channel but likely a deeper problem within the Nixpkgs definitions themselves.
Why is this Happening? Potential Causes
So, why are we seeing this attribute 'version' missing
error? There are a few potential reasons:
- Incomplete Package Definitions: As mentioned earlier, some packages in Nixpkgs might be missing the
version
attribute in their metadata. This could be due to human error, automated scripts not properly extracting version information, or changes in upstream package metadata formats. - Nixpkgs Evolution: Nixpkgs is a constantly evolving collection of package definitions. Sometimes, changes in the way packages are defined or how metadata is handled can introduce errors like this. The warnings about renamed packages and deprecated features are a testament to this ongoing evolution. It's possible that a recent change has exposed this issue.
- macOS Specific Issues: While the core error seems to be related to Nixpkgs, it's possible that there's something specific to macOS Sequoia 15.6 that's triggering this issue. It could be a compatibility problem with certain libraries or tools used by Nix.
How to Fix It: A Troubleshooting Guide
Okay, so we know what's happening and why it might be happening. Now, let's talk about how to fix it. Here's a troubleshooting guide:
1. Update Nix and Nixpkgs
This is the first and most important step. Make sure you're running the latest version of Nix and that your Nixpkgs channel is up to date. This will ensure that you have the latest bug fixes and package definitions. Run these commands:
nix-channel --update
nix-channel --update nixpkgs
nix-env -u '
2. Clean the Nix Store
Sometimes, old or corrupted files in the Nix store can cause problems. Cleaning the store can help resolve these issues. Use the following command:
nix-collect-garbage -d
This command will remove any unused packages and garbage from your Nix store.
3. Identify the Problematic Package
To really nail this, we need to figure out which package is missing the version
attribute. The error trace points to unixtools.nix
, but that's a generic file. We need to isolate the specific package causing the issue. A good way to do this is to modify the dump_packages.nix
script to log the package name before attempting to access its metadata. This will help narrow down the culprit.
4. Report the Issue to Nixpkgs
Once you've identified the problematic package, report it to the Nixpkgs maintainers! This is crucial because they're the ones who can fix the package definition. You can report the issue on the Nixpkgs GitHub repository. Be sure to include all the details you've gathered, including the error messages, the package name, and your system information.
5. Workaround (If Necessary)
If you need nix-search
to work immediately, you might consider temporarily pinning your Nixpkgs channel to an older revision where this issue doesn't exist. However, this is a temporary workaround and should only be used if necessary. You'll still want to report the issue and update to the latest Nixpkgs once it's resolved.
Long term solution
Once reported, the Nixpkgs maintainers can address the package definition. They might add the missing version
attribute, adjust the metadata extraction process, or potentially remove the broken package if it's no longer maintained. A fix in Nixpkgs will eventually propagate to your system when you update your channels.
Conclusion: Getting nix-search
Back on Track
So, indexing failing on macOS Sequoia 15.6 is a bummer, but it's a problem we can tackle. By understanding the error messages, digging into the Nixpkgs code, and following the troubleshooting steps, we can get nix-search
back up and running. Remember, reporting issues to the Nixpkgs community is super important for keeping Nixpkgs healthy and reliable. Let's get this fixed, guys!
I hope this article was helpful and informative. If you have any questions or run into any other issues, feel free to leave a comment below. Happy Nixing!