CLI for initializing projects in a configurable way.
 
 
 
 
 
 
Go to file
Joshua Potter f949647e1b Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
include Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
specs/clang Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
src Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
.envrc Initial commit. 2023-11-22 10:43:05 -07:00
.gitignore Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
Makefile Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
README.md Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
flake.lock Add example `main.c` file. 2023-11-22 11:50:15 -07:00
flake.nix Add all files. 2023-11-22 13:43:34 -07:00
gen-flake Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00
main.c Add example of spec and explanation on how it works. 2023-11-22 14:39:27 -07:00

README.md

gen-flake

CLI utility for initializing projects deterministically using flakes.

Problem

Nix supports the concept of templates out of the box, but the usefulness of the implementation is dubious. In particular,

> nix flake init

simply copies the files specified in the template directory to the current local directory, with no means of configuring the copied files. This is especially useless when working with projects that typically generate files on initialization (i.e. most projects).

How This Works

Within the specs directory exists so-called specs. A spec is a directory containing a spec.json file and a run.sh file. The former is configured like so:

{
  versions: [...],
}

The keys of this top-level JSON object correspond to the parameters that are prompted by the gen-flake curses interface. The value is used to determine what kind of prompt gen-flake provides for the given question. Possible value types are:

  • [...] (list)
    • This indicates a select option prompt. The user chooses amongst the values specified in the JSON list.

Once all prompts are evaluated, the keys of the object are converted into uppercase environment variables and passed to the run.sh file relative to the current directory.