mirror of
https://github.com/NixOS/nix.git
synced 2025-12-16 14:01:05 +01:00
nix flake init: Add a '--template' flag
The initial contents of the flake is specified by the
'templates.<name>' or 'defaultTemplate' output of another flake. E.g.
outputs = { self }: {
templates = {
nixos-container = {
path = ./nixos-container;
description = "An example of a NixOS container";
};
};
};
allows
$ nix flake init -t templates#nixos-container
Also add a command 'nix flake new', which is identical to 'nix flake
init' except that it initializes a specified directory rather than the
current directory.
This commit is contained in:
parent
dc305500c3
commit
810b2c6a48
8 changed files with 258 additions and 41 deletions
|
|
@ -237,7 +237,7 @@ App Installable::toApp(EvalState & state)
|
|||
}
|
||||
|
||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||
Installable::getCursor(EvalState & state, bool useEvalCache)
|
||||
Installable::getCursors(EvalState & state, bool useEvalCache)
|
||||
{
|
||||
auto evalCache =
|
||||
std::make_shared<nix::eval_cache::EvalCache>(false, Hash(), state,
|
||||
|
|
@ -245,6 +245,15 @@ Installable::getCursor(EvalState & state, bool useEvalCache)
|
|||
return {{evalCache->getRoot(), ""}};
|
||||
}
|
||||
|
||||
std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>
|
||||
Installable::getCursor(EvalState & state, bool useEvalCache)
|
||||
{
|
||||
auto cursors = getCursors(state, useEvalCache);
|
||||
if (cursors.empty())
|
||||
throw Error("cannot find flake attribute '%s'", what());
|
||||
return cursors[0];
|
||||
}
|
||||
|
||||
struct InstallableStorePath : Installable
|
||||
{
|
||||
ref<Store> store;
|
||||
|
|
@ -474,7 +483,7 @@ std::pair<Value *, Pos> InstallableFlake::toValue(EvalState & state)
|
|||
}
|
||||
|
||||
std::vector<std::pair<std::shared_ptr<eval_cache::AttrCursor>, std::string>>
|
||||
InstallableFlake::getCursor(EvalState & state, bool useEvalCache)
|
||||
InstallableFlake::getCursors(EvalState & state, bool useEvalCache)
|
||||
{
|
||||
auto evalCache = openEvalCache(state,
|
||||
std::make_shared<flake::LockedFlake>(lockFlake(state, flakeRef, lockFlags)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue