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

using cookiecutter or similar tools to bootstrap the template #16

Closed
jnoortheen opened this issue Jun 28, 2020 · 7 comments
Closed

using cookiecutter or similar tools to bootstrap the template #16

jnoortheen opened this issue Jun 28, 2020 · 7 comments
Labels
APIv1 related to 1.0 api stabilization

Comments

@jnoortheen
Copy link

jnoortheen commented Jun 28, 2020

Is your feature request related to a problem? Please describe.
As of now we endup with lot of files not necessarily used.

Describe the solution you'd like
Using such tool we can set the

  • default user name
  • new-host file's name -> automatically generate the file under hosts folder after entering the name as from generate-config
  • set of profiles that user wants to use
  • desktop environment that user wants
  • etc.,
  • an update script to pull down latest changes from this repo

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@nrdxp
Copy link
Collaborator

nrdxp commented Jul 9, 2020

I've got some ideas for making the bootstrap process simpler and more automatic and this could definitely be a part of it. It'll take some time, but I'll have a new branch up soon(ish) and I'll see if this can work.

@nrdxp
Copy link
Collaborator

nrdxp commented Aug 2, 2020

I've decided not to opt for external tools, but instead I created a bare branch which should suffice if you're wanting the benefits of this template without any of the predefined profiles. I've also wired up the template output, so creating a new iteration of a bare template is as simple as:

nix flake new -t "github:nrdxp/nixflk/bare" flk

@nrdxp nrdxp closed this as completed Aug 2, 2020
@nrdxp
Copy link
Collaborator

nrdxp commented Mar 27, 2021

I'm reopening this, as we might be able to use cookiecutter during the building of the system generation to easily solve some current introspective problems, such as knowing available users to assign user properties to each, without causing infinite recursion.

Not to mention, cookiecutter or similar tools could help with #179 in general.

@nrdxp nrdxp reopened this Mar 27, 2021
@blaggacao
Copy link
Contributor

blaggacao commented Mar 28, 2021

I'd have thought ideally nix templates would offer us something, here.

Instead of a template, we might use annotations, so that an unprocessed template is still a valid project.

{
  name = "hey"; # setter: name
}

And I think nix even provides something to manipulate values on the fly over the cli.

@blaggacao
Copy link
Contributor

blaggacao commented Mar 28, 2021

When running nix edit nixpkgs#hello, there is a heuristic to find the package declaration which essentially goes like this:

$ nix repl
Welcome to Nix version 3.0pre20200829_f156513. Type :? for help.

nix-repl> pkgs = import <nixpkgs> {}

nix-repl> builtins.unsafeGetAttrPos "description" pkgs.hello.meta
{ column = 5; file = "/home/zimbatm/go/src/github.com/NixOS/nixpkgs/pkgs/applications/misc/hello/default.nix"; line = 15; } 

Once the file and line have been found, call $EDITOR $file +$line.

Here is what happens when an attribute cannot be found:

nix-repl> builtins.unsafeGetAttrPos "broken" pkgs.hello.meta
null 

It wouldn’t be too hard to write a tool that relies on this information and then combines it with an AST patcher. We have a number of those in the community.

Quote from zimbatm from a private conversation.

@nrdxp nrdxp mentioned this issue Mar 31, 2021
@blaggacao blaggacao added the APIv1 related to 1.0 api stabilization label Apr 11, 2021
@blaggacao
Copy link
Contributor

With suites, we have a cheap way of introspecting the global composing components for a host by name and coukd write those into a host template via substitute --replace '@suites@' "${suiteNames}".

That could go into flk up which already partly addresses this use case.

@blaggacao
Copy link
Contributor

This template has evolved quite a bit, and also flk gained a boostrapping command. I don't think there is a need to improve the templating experience further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIv1 related to 1.0 api stabilization
Projects
None yet
Development

No branches or pull requests

3 participants