In a flake that I am developing, I built a bash script that calls:
nix flake new "${NAME}" --template "${TEMPLATE}"
Today I hard code the TEMPLATE
variable with something like:
git+ssh://git@gitlab.com/mygroup/myrepo?ref=main&rev=99727ebe33e443d42eacad2434b349c95d7274f4#mytemplate
As you can see I manually pin the version of the template that I need, but I would like to leverage the lock file to do that instead.
So I added an input to my flake:
{
inputs = {
...
myinput = {
url = git+ssh://git@gitlab.com/mygroup/myrepo?ref=main;
};
};
outputs = { self, myinput, ... }: {
...
# How to get the input locked ref in here?
}
}
Can I get the input locked ref (i.e. “git+ssh://git@gitlab.com/mygroup/myrepo?ref=main&rev=99727ebe33e443d42eacad2434b349c95d7274f4”)—if that is what it’s called—in the outputs
scope?
I know I can get the hash with myinput.rev
and I could easily built the final string with this, but I would like the complete “git+ssh://git@gitlab.com/mygroup/myrepo?ref=main&rev=99727ebe33e443d42eacad2434b349c95d7274f4” without having to duplicate the knowledge of the rest of the input data (repo git@gitlab.com/mygroup/myrepo
and branch (i.e. main
).