Hi! I’m looking into Flox as a way to onboard my less nix-familiar team members to a Nix environment. I really like it so far! The sticking point in terms of a missing feature that I can’t find in the docs is how to include/link a custom nix expression into the Manifest.toml.
In this case, our team uses an older version of protobuf. I solved this from a purely Nix level using a custom-built package of protobuf. I pin to protobuf 3.15.xx, and then reference in my environment configuration like so:
my-custom-protobuf = import ../custom/protobuf.nix { inherit pkgs; }
and then add it to my path and so on.
This is great (for me) but I think my team members would rather use Flox. However, while I have migrated the majority of our config over, and flox show protobuf
includes protobuf@3.15.7, adding the following to my Manifest.toml produces the following error:
protobuf = { pkg-path = “protobuf”, version = “3.15.7”, pkg-group = “protobuf-toolchain” }
ERROR: resolution failed: constraints for group ‘protobuf-toolchain’ are too tight
protobuf is the only item in the protobuf toolchain group, and if I relax the package version with version = "^3.15.7"
flox allows upgrades to the major version and I end up with protoc-24.3.0 which is not what I want.
So, with all that in mind, is there a way I can use flox on my team? Either a way to actually use the protobuf@3.15.7 or a way to breakout to a custom nix expression would work for me.
I know enough of Nix to be dangerous but not enough to know what I’m doing, so if something I said in here seems to make no sense please let me know!
I think this is due to that version of the protobuf
package not being available for aarch64-darwin
. If you look at the flox show protobuf
output you see this:
protobuf - Google's data interchange format
protobuf@29.1
...
protobuf@3.16.0
protobuf@3.15.7 (aarch64-linux, x86_64-darwin, x86_64-linux only)
protobuf@3.15.5 (aarch64-linux, x86_64-darwin, x86_64-linux only)
protobuf@3.14.0 (aarch64-linux, x86_64-darwin, x86_64-linux only)
The (aarch64-linux, x86_64-darwin, x86_64-linux only)
part means that it’s not available for aarch64-darwin
.
By default we create an environment that’s available for all four systems, so you might think that you’d need to edit the systems supported by the environment, but we actually make it easier than that (most of the time ). For packages that aren’t available on all the systems in your manifest we typically install it for the systems on which the package is available. That’s the part that failed here for some reason.
In order to install this package you just need to edit the manifest directly and add the systems
field yourself:
protobuf = { pkg-path = “protobuf”, version = “3.15.7”, pkg-group = “protobuf-toolchain”, systems = ["aarch64-linux", "x86_64-darwin", "x86_64-linux"]}
Does that all make sense? We’re looking into why the automatic “only install for available systems” part failed.
1 Like
Did some digging and the automatic installation for available systems specifically only works for the flox install
command. When you’ve edited the manifest directly (like you did by adding it to a package group) we honor whatever you’ve written. That means (intentionally or not) that you were requesting version 3.15.7 for all the systems in your manifest (e.g. all four systems).
There is no package with that version that supports all four systems, which is why you got that error. You did the right thing by adding the package to a package group. I think the messaging about why it still failed could be better.
1 Like
Thank you so much for your help!
Definitely if there was a little message that flox tossed in the console when it can’t find a version that just said something like:
:x: ERROR: resolution failed: constraints for group ‘protobuf-toolchain’ are too tight - versions found for x86_64-linux and NOT aarch64-darwin
That would have clued me in to what I was missing.
Appreciate you getting back to me so quickly!