How to get the nixpkgs version that contains a /nix/store path?

Given the store path of a derivation such as /nix/store/fbd9sr5lx1r5r9w3cl4d5p5hgwbhk9jj-hello-2.10, is it possible to know from that path, which nixpkgs version or channel contains it?

If it’s a pre-built derivation, you can search for it on Hydra: https://hydra.nixos.org/search?query=fbd9sr5lx1r5r9w3cl4d5p5hgwbhk9jj
hydra

2 Likes

Thanks @AtnNn, I got some help on https://webchat.freenode.net/#nixos, and indeed searching on Hydra may help. In the example given, searching for the hash on Hydra returned https://hydra.nixos.org/search?query=fbd9sr5lx1r5r9w3cl4d5p5hgwbhk9jj.

I’m just curious, why do you want to know that information?

Somewhat related, if you want to know the last update to that channel, and you have a checkout of nixpkgs, you can do:

git log $(cat ~/.nix-defexpr/channels/<nix-channel>/.git-revision)
2 Likes

Thanks for the tip!

I was asking because I am working with a setup, (which I did not write), which installs a bunch of pre-built derivations using the nix-env -i nix/store/... paths, and then refers to these in the buildInputs of a derivation. So, I wanted to re-write the derivation such that there’s no need to “pre-install” the dependencies in with nix-env and such that instead of /nix/store/...foo-1.0 I can simply put foo in the buildInputs. I did that but then encountered many troubles such that the original build not longer worked. So one hypothesis I had, was that I am not using the correct nixpkgs version that was used, but then I did not know what was used, which then led me to ask this question.

So, what I actually then find out is that the “hard-coded” /nix/store/... dependencies are from different nixpkgs versions, which really complicates writing a derivation that depends on a pinned down nixpkgs version, which as I am just learning nix appeared to me the recommended practice (to pin down nixpkgs).

So, currently, I have managed to use the packages of a pinned down nixpkgs except for 3 of them …

I hope this answers your question and please let me know if you any more questions or tips, as I am learning nix and I am therefore happy to learn from various sources and people!

Correct, I would just find the branch or commit they used. pin nixpkgs to that, then just reference the packages by their attr path (e.g. python3) instead of their store path (e.g. /nix/store/.....-python3-)

Thanks for the feedback! That is what I did, but doing so does not for at least two packages, such that for these I still need to refer to them via their /nix/store/... paths …