Better error message when current schema is one version behind the latest one
After a flake update, colmena started to show following error message:
while calling the 'throw' builtin
at «string»:1:64:
1| with builtins; hive: assert (hive.__schema == "v0.20241006" || throw ''
| ^
2| The colmenaHive output (schema ${hive.__schema}) isn't compatible with this version of Colmena.
error: The colmenaHive output (schema v0.5) isn't compatible with this version of Colmena.
Hint: Use the same version of Colmena as in the Flake input
It's really confusing because I do uses colmena from upstream flake.
It took me a while to realize that the colmena currently installed is outdated because systems have yet been updated due to this error, and surely "v0.20241006" is older than "v0.5" :/ After updating with good old nixos-rebuild the error sure is gone.
I'd like to suggest that colmena gives a better hint, saying something like: "The schema v0.20241006 is from the previous version of colmena where the latest is v0.5. Use nixos-rebuild to update your system first to install the newer colmena".
I'd like to suggest that colmena gives a better hint, saying something like: "The schema v0.20241006 is from the previous version of colmena where the latest is v0.5. Use nixos-rebuild to update your system first to install the newer colmena".
Would it help to clarify that it's a mismatch between the Colmena executable and the Colmena input in the flake? People get the colmena command via various ways and it's not always globally installed. Personally, I add it to the devShell in the same flake so the version is always consistent.
Would it help to clarify that it's a mismatch between the Colmena executable and the Colmena input in the flake?
I think this could be helpful. Using Github code search there are bunch of configs which install colmena globally, so it might beneficial for more people :)
I add it to the devShell
I used to do this too, but the experience isn't quite enjoyful so I opted into install apps globally.
I'd like to suggest that colmena gives a better hint, saying something like: "The schema v0.20241006 is from the previous version of colmena where the latest is v0.5. Use nixos-rebuild to update your system first to install the newer colmena".
Would it help to clarify that it's a mismatch between the Colmena executable and the Colmena input in the flake? People get the
colmenacommand via various ways and it's not always globally installed. Personally, I add it to thedevShellin the same flake so the version is always consistent.
@zhaofengli would you mind providing a minimal example of a flake that does this? I'm having trouble figuring out how to pass the colmena flake input as a package for the devShell. Also struggled when trying to use flake-utils.lib.eachDefaultSystem for the devShell (as almost all examples tend to use it) while having the colmenaHive output separately
@JonnyHaystack below works for me.
flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
colmena = {
url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
colmena,
sops-nix,
}@inputs: {
devShells = eachDefaultSystemMap (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
default = pkgs.callPackage ./shell.nix { inherit (inputs) sops-nix colmena; };
}
);
};
}
shell.nix
{
pkgs,
colmena,
sops-nix,
...
}:
mkShell {
buildInputs = [
colmena.defaultPackage.${pkgs.system}
];
}
In shell.nix, i have to use the package from flake instead of upstream nixpkgs (which is at 0.4.0), so colmena.defaultPackage.${pkgs.system} or colmena.packages.${pkgs.system}.colmena. Now my colmena version is 0.5.0-pre and that error is gone