-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add an eject
command to convert project to flakes
#404
base: master
Are you sure you want to change the base?
Conversation
You can now run `niv eject` to print the inputs of your sources.json as flake inputs.
thanks @414owen ! Actually last weekend @zimbatm and I were talking about whether it'd be feasible to use Do you think that would make sense? When working on ejecting the flake, did you see any issue that might prevent |
Hmmm, I ran a few tests, and the flake format is pretty strict. It (and the input attr) has to be a literal set, it can't be imported, or used from a let. For example, this doesn't work:
So it should always be possible to edit flake inputs purely based on the AST. I guess separating out the parser from |
Using niv to implement Actually you could totally cheat and get niv to call nix... |
Nice! I think that's the conclusion we also reached. That'd mean that the parsing should be "pretty" straightforward.
That's the one bit I'm not sure about though. Can you e.g. specify a branch in the flake.lock itself? For instance, if the
In |
@nmattia Ah, yes, you're right. We would need to read the Of course this might include converting |
Ah, that's amazing!
Sure, that makes sense. I like the idea of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
Co-authored-by: Nicolas Mattia <nicolas@nmattia.com>
This adds a
niv eject
command, which prints the nivsources.json
in flake input format.We ended up not actually switching to flakes at all, but maaaaybe this will save someone a lot of time, so I thought I'd make it public.
It's far from perfect, but it'll get you 95% of the way there.