Skip to content
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

om init - for smart template generation #152

Closed
6 of 9 tasks
Tracked by #140
srid opened this issue Jul 15, 2024 · 3 comments
Closed
6 of 9 tasks
Tracked by #140

om init - for smart template generation #152

srid opened this issue Jul 15, 2024 · 3 comments
Assignees

Comments

@srid
Copy link
Member

srid commented Jul 15, 2024

Add

om init

This should support a registry of flake templates (use our various flake-parts modules), initialize them using nix flake init as well as fill in any user-specific content using the templateGenerators idea in flake-parts/templates#7 (comment)

The goal is to have om init create flakes for any kind of stack, eventually.

Implementation

To extend flake.templates, we can add:

{
  flake.templateGenerators.default = {
    # The generator to use (string or package)
    generator = "om init";
    # Arbitrary metaata (of the template) to pass to the generator.
    templates.default.params = {
    };
  };
}

Here, generator can be an arbitrary derivation (a function that takes pkgs and returns a types.package?) or it can be a string that represents the command line to use to invoke the generator? om init can fetch templates, and look for the special "om init" generator, in which case it can short-circuit by calling the necessary internal initializer function, passing the templates.?.params property as necessary.

Tasks

@srid srid added this to the `omnix-cli` MVP milestone Jul 15, 2024
@srid srid self-assigned this Jul 15, 2024
@srid
Copy link
Member Author

srid commented Jul 15, 2024

cc @roberth (have I correctly understood your templateGenerators idea?)

@srid
Copy link
Member Author

srid commented Jul 15, 2024

Alternatively, if we don't care about being general enough, we could just pass om configuration for templates as:

{
  templates.default = { ... };
  om.templates.default = {
    params = {
      # ...
    };
  };
}

This way, we don't have to fully spec out the general case first.

(Later, if a general spec does emerge, it should be straightforward to port the om.templates configuration to it).

See #153 for configuration seen from larger context.

@srid
Copy link
Member Author

srid commented Aug 1, 2024

image

Regarding this, for MVP - let's keep the additional config in this repo, so it gives us some leeway to change things in future. Otherwise, we can consider this feature basically done.

@srid srid closed this as completed Aug 1, 2024
@srid srid unpinned this issue Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant