I would like to clone a Git repo (from Github) which does not contain a Nix derivation or a Nix flake, nor any executable program at all, but just some data that I want to use.
From the Nix wiki I figure that this is possible by specifying the URL like in the following flake.nix, and indeed when I nix develop, I see that it fetches the repo.
But, how can I use the repo then??? Like, where is it stored, how is it accessible from the nix develop shell? Ideally, the way to access it would not involve any hash or commit information, such that when I update the lock file and there is a new commit I do not need to change any code to use this new commit.
I feel like the solution is probably very obvious, but I have no clue and extensive googling has not led me anywhere. So, thank you very much in advance for your help!
Check the variable buildInputs in your shell when you use that flake. It will contain the paths to all the buildInputs:
$ nix develop ./test
$ echo $buildInputs
/nix/store/2ip2m8c8g0csnl9i64yar7vjbfk6pij7-source
$ ls $buildInputs
ICWSM_poster.pdf LICENSE README.md classifier data lexicons src
However, as you add more buildInputs, the variable will contain a list of the paths of all of them. So if you want to do specific things with that source, you may want to declare it like so:
So, I had not really understood the mkShell command, now I do. Indeed, for my use case, I then do no longer need myrepo in buildInputs, but having it in a separate environment variable works best. Thanks!
Thanks, this worked for me also … was curious if it fetches the latest from the repo on each invocation of nix develop? in the shellHook I cd into the downloaded repo and do git fetch but it complains it isn’t a git repo … would also be curious how to make that work or if I’ve somehow messed up. In any case, thanks!
You would use nix flake update to update all your dependencies or nix flake lock --update-input myrepo to update a single input (you then need to re-enter your devShell to make this active). If you cd into the path of myrepo you will end up in the nix-store where it stored the content of myrepo. Not only will this be read-only, it will also only contain the content of the specific git-commit that myrepo is currently locked to according to flake.lock.