Open
Description
nixos-generators-search-path-proposal
Proposal
Support runtime extension of the format file search path via environment variables and CLI options.
Motivation
Provide a mechanism for end users and third parties to host libraries of nixos-generate
formats.
Hypothetical usage
$ NIXOS_GENERATORS_FORMAT_SEARCH_PATH=/some/location:/another/location \
nixos-generate \
--format-search-path /yet/another/location \
--format-search-path /yes/there/is/another/location \
--format my-custom-format \
--flake '.#my-host'
This would make nixos-generate
search for the format file my-custom-format.nix
in the following directories, ordered from highest to lowest precedence:
/yes/there/is/another/location
/yet/another/location
/some/location
/another/location
/nix/store/...-nixos-generators/share/nixos-generator/format
In other words:
- CLI arguments are highest-precedence, with later arguments (those toward the end of
argv
) being of higher precedence than earlier arguments, - The search path specified in
NIXOS_GENERATORS_FORMAT_SEARCH_PATH
is next-highest-precedence, and - The builtin format directory is lowest-precedence.
Example use cases
- Setting the
NIXOS_GENERATORS_FORMAT_SEARCH_PATH
environment varible in adevshell
configuration so that enteringnix develop
makes the project's customnixos-generate
formats available via the--format
flag rather than only via typing out their paths. - Using
makeWrapper
/wrapProgram
to ship a customnixos-generate
with additional format definitions, without having to rebuildnixos-generators
itself (and modify its builder, etc.). - Easily incorporating libraries of custom formats supplied by third parties.
WDYT?
I would be happy to submit a PR introducing the described changes if they sound sane and desirable. Thanks in advance for your feedback.
Metadata
Metadata
Assignees
Labels
No labels