godarch / darch

A tool for building and booting stateless and immutable images, bare metal.
https://godarch.com/
MIT License
831 stars 32 forks source link

Feature request: Compositional inheritance #49

Closed aaroncwhite closed 4 years ago

aaroncwhite commented 4 years ago

I have darch builds deployed on three computers in the home lab now- my workstation, laptop, and server. It's pretty great!

A feature that I think would be a great extension of darch would be compositional inheritance instead of a single parent "recipe". For example, I have a base recipe, similar to @pauldotknopf's, that installs most things I care about on all machines. Then I have a separate desktop and workstation recipes which build on top of that. Right now, the build is linear: base -> desktop -> workstation. Then I have computer specific builds to install nvidia drivers for the workstation, linux-surface for my surface book, etc. which all build off of the workstation build.

What I'd like to do is specify the final builds as the recipe and keep the upstream builds more abstract. Something like this for my laptop:

{
    "inherits" : [
        "base",
        "desktop",
        "workstation"
    ]
}

Then it would run the final script to customize. But my server, which does not need any gui libs still needs what's in workstation:

{
    "inherits" : [
        "base",
        "workstation"
    ]
}

As currently formulated, I would have to copy the contents of development into a second recipe to break the base -> desktop -> workstation chain, but it's all the same things in the recipe.

Order would matter, but storing as an array in the JSON should handle that. I'm kind of thinking of mixins for python's inheritance.

Happy to discuss more. It seems like it would primarily impact the darch recipes build and build-deps steps. I'd be willing to take a stab at it if it fits within the vision of darch.

pauldotknopf commented 4 years ago

Unfortunately, the concept of a single parent is baked into the Docker/OCI image format. We won't be able to make compositional parents a thing within Darch.