buildxyz icon indicating copy to clipboard operation
buildxyz copied to clipboard

Integration with nix-init

Open figsoda opened this issue 1 year ago • 2 comments

This is more of an open-ended discussion, if you are interested.

I am the maintainer of nix-init, which in short, generates nix expressions for packages interactively, and has some dependency inference based on language specific dependencies (e.g. Cargo.lock). It was suggested to me that an automated build-fail-adjust loop would be nice, which sounds similar to what buildxyz does under the hood, maybe we can work something out?

figsoda avatar Mar 15 '23 14:03 figsoda

Oh yes, I am so happy that you opened this. I definitely want to integrate with you at some point.

There are multiple things that I imagine, I do not know what would be the optimal priorization though wrt to your needs.

Something that I really really want to get is "recursive packaging" through nix-init and buildxyz.

If you start packaging a project, running building phase, hit a required paths, having a user interaction to provide the actual path or package this missing dependency recursively.

All of this could rerender Nix exprs at the end and I am probably planning for optimizations to maintain a Nix expr in memory that I can rerender for debugging or letting the user do final touches to the thing.

RaitoBezarius avatar Mar 15 '23 15:03 RaitoBezarius

This is what I roughly have in mind. I have two different types (struct and in memory nix expr) here, but maybe we can have only one type similar to syn::File. That way buildxyz can mutate the nix expr directly or return a more expressive diff, but rendering it to a file would be harder because of the freedom it gives.

d2 source for the diagram
nix-init (before) -> text: interactions

nix-init (after) -> struct: interactions
struct -> text: format

struct -> expr: cheap conversion
expr -> buildxyz: passed to
buildxyz -> diff: does its thing
diff -> struct: apply and repeat

struct: {
    shape: class
    style: {
        font-size: 16
    }
    builder: enum
    src: perhaps String?
    buildInputs: BTreeSet<String>
    "..."
}
expr: in memory nix expr
buildxyz: buildxyz (as a library)
text: nix code (text)

figsoda avatar Mar 16 '23 00:03 figsoda