feat: Add an eject command to convert project to flakes#404
feat: Add an eject command to convert project to flakes#404414owen wants to merge 2 commits intonmattia:masterfrom
eject command to convert project to flakes#404Conversation
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 |
Co-authored-by: Nicolas Mattia <nicolas@nmattia.com>
This adds a
niv ejectcommand, which prints the nivsources.jsonin 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.