DeterminateSystems / bootspec

Implementation of RFC-0125's datatype and synthesis tooling.
MIT License
24 stars 5 forks source link

Extensions for specializationn #147

Open CertainLach opened 2 weeks ago

CertainLach commented 2 weeks ago

In PR https://github.com/DeterminateSystems/bootspec/pull/105 extensions field of GenerationV1 was removed in favor of BootJson

However, this limits extensibility: it is now impossible to use structures in this crate to represent extensions only relevant to specific system specializations, extensions are now always only applied to top-level generation.

Due to that, sortKey is now broken in lanzaboote, as it is always inherited from root generation with no possibility to override it in generation: https://github.com/nix-community/lanzaboote/issues/349

CertainLach commented 2 weeks ago

I'm not sure why it is implemented this way as it is, current implementation needs to be redone a bit, what about having such implementation of extensibility, with multiple extension points, making it possible for user to define anything he wants, anywhere he wants?

struct GenerationExtension {
  #[serde(rename = "nixos-community.lanzaboote")]
  lanzaboote: ...,
}

trait Extensions {
  type Generation = GenerationExtension;
  type BootSpec = ();
};

struct GenerationV1<E: Extensions> {
  ...
  initrd_secrets: ...,
  toplevel: ...,
  #[serde(flatten)]
  extensions: E::Generation,
}