forked from lix-project/lix
Merge branch 'flakes' of github.com:NixOS/nix into flakes
This commit is contained in:
commit
03a4a3c95c
|
@ -46,7 +46,7 @@ static FlakeRef lookupInFlakeCache(
|
||||||
return flakeRef;
|
return flakeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::pair<fetchers::Tree, FlakeRef> fetchOrSubstituteTree(
|
static std::tuple<fetchers::Tree, FlakeRef, FlakeRef> fetchOrSubstituteTree(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
const FlakeRef & originalRef,
|
const FlakeRef & originalRef,
|
||||||
std::optional<TreeInfo> treeInfo,
|
std::optional<TreeInfo> treeInfo,
|
||||||
|
@ -76,6 +76,7 @@ static std::pair<fetchers::Tree, FlakeRef> fetchOrSubstituteTree(
|
||||||
.storePath = std::move(storePath),
|
.storePath = std::move(storePath),
|
||||||
.info = *treeInfo,
|
.info = *treeInfo,
|
||||||
},
|
},
|
||||||
|
originalRef,
|
||||||
originalRef
|
originalRef
|
||||||
};
|
};
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
|
@ -101,7 +102,7 @@ static std::pair<fetchers::Tree, FlakeRef> fetchOrSubstituteTree(
|
||||||
if (treeInfo)
|
if (treeInfo)
|
||||||
assert(tree.storePath == treeInfo->computeStorePath(*state.store));
|
assert(tree.storePath == treeInfo->computeStorePath(*state.store));
|
||||||
|
|
||||||
return {std::move(tree), lockedRef};
|
return {std::move(tree), resolvedRef, lockedRef};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expectType(EvalState & state, ValueType type,
|
static void expectType(EvalState & state, ValueType type,
|
||||||
|
@ -206,7 +207,7 @@ static Flake getFlake(
|
||||||
bool allowLookup,
|
bool allowLookup,
|
||||||
FlakeCache & flakeCache)
|
FlakeCache & flakeCache)
|
||||||
{
|
{
|
||||||
auto [sourceInfo, lockedRef] = fetchOrSubstituteTree(
|
auto [sourceInfo, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||||
state, originalRef, treeInfo, allowLookup, flakeCache);
|
state, originalRef, treeInfo, allowLookup, flakeCache);
|
||||||
|
|
||||||
// Guard against symlink attacks.
|
// Guard against symlink attacks.
|
||||||
|
@ -217,6 +218,7 @@ static Flake getFlake(
|
||||||
|
|
||||||
Flake flake {
|
Flake flake {
|
||||||
.originalRef = originalRef,
|
.originalRef = originalRef,
|
||||||
|
.resolvedRef = resolvedRef,
|
||||||
.lockedRef = lockedRef,
|
.lockedRef = lockedRef,
|
||||||
.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
.sourceInfo = std::make_shared<fetchers::Tree>(std::move(sourceInfo))
|
||||||
};
|
};
|
||||||
|
@ -490,7 +492,7 @@ LockedFlake lockFlake(
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
auto [sourceInfo, lockedRef] = fetchOrSubstituteTree(
|
auto [sourceInfo, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||||
state, input.ref, {}, lockFlags.useRegistries, flakeCache);
|
state, input.ref, {}, lockFlags.useRegistries, flakeCache);
|
||||||
node->inputs.insert_or_assign(id,
|
node->inputs.insert_or_assign(id,
|
||||||
std::make_shared<LockedNode>(lockedRef, input.ref, sourceInfo.info, false));
|
std::make_shared<LockedNode>(lockedRef, input.ref, sourceInfo.info, false));
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct FlakeInput
|
||||||
struct Flake
|
struct Flake
|
||||||
{
|
{
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
|
FlakeRef resolvedRef;
|
||||||
FlakeRef lockedRef;
|
FlakeRef lockedRef;
|
||||||
std::optional<std::string> description;
|
std::optional<std::string> description;
|
||||||
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
std::shared_ptr<const fetchers::Tree> sourceInfo;
|
||||||
|
|
|
@ -80,7 +80,8 @@ struct CmdFlakeList : EvalCommand
|
||||||
|
|
||||||
static void printFlakeInfo(const Store & store, const Flake & flake)
|
static void printFlakeInfo(const Store & store, const Flake & flake)
|
||||||
{
|
{
|
||||||
std::cout << fmt("URL: %s\n", flake.lockedRef.to_string());
|
std::cout << fmt("Resolved URL: %s\n", flake.resolvedRef.to_string());
|
||||||
|
std::cout << fmt("Locked URL: %s\n", flake.lockedRef.to_string());
|
||||||
std::cout << fmt("Edition: %s\n", flake.edition);
|
std::cout << fmt("Edition: %s\n", flake.edition);
|
||||||
if (flake.description)
|
if (flake.description)
|
||||||
std::cout << fmt("Description: %s\n", *flake.description);
|
std::cout << fmt("Description: %s\n", *flake.description);
|
||||||
|
@ -100,8 +101,11 @@ static nlohmann::json flakeToJson(const Store & store, const Flake & flake)
|
||||||
if (flake.description)
|
if (flake.description)
|
||||||
j["description"] = *flake.description;
|
j["description"] = *flake.description;
|
||||||
j["edition"] = flake.edition;
|
j["edition"] = flake.edition;
|
||||||
j["url"] = flake.lockedRef.to_string();
|
j["originalUrl"] = flake.originalRef.to_string();
|
||||||
j["original"] = attrsToJson(flake.originalRef.toAttrs());
|
j["original"] = attrsToJson(flake.originalRef.toAttrs());
|
||||||
|
j["resolvedUrl"] = flake.resolvedRef.to_string();
|
||||||
|
j["resolved"] = attrsToJson(flake.resolvedRef.toAttrs());
|
||||||
|
j["url"] = flake.lockedRef.to_string(); // FIXME: rename to lockedUrl
|
||||||
j["locked"] = attrsToJson(flake.lockedRef.toAttrs());
|
j["locked"] = attrsToJson(flake.lockedRef.toAttrs());
|
||||||
j["info"] = flake.sourceInfo->info.toJson();
|
j["info"] = flake.sourceInfo->info.toJson();
|
||||||
if (auto rev = flake.lockedRef.input->getRev())
|
if (auto rev = flake.lockedRef.input->getRev())
|
||||||
|
@ -153,39 +157,14 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
|
||||||
|
|
||||||
void run(nix::ref<nix::Store> store) override
|
void run(nix::ref<nix::Store> store) override
|
||||||
{
|
{
|
||||||
|
auto flake = getFlake();
|
||||||
|
stopProgressBar();
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
auto state = getEvalState();
|
auto json = flakeToJson(*store, flake);
|
||||||
auto flake = lockFlake();
|
|
||||||
|
|
||||||
auto json = flakeToJson(*store, flake.flake);
|
|
||||||
|
|
||||||
auto vFlake = state->allocValue();
|
|
||||||
flake::callFlake(*state, flake, *vFlake);
|
|
||||||
|
|
||||||
auto outputs = nlohmann::json::object();
|
|
||||||
|
|
||||||
enumerateOutputs(*state,
|
|
||||||
*vFlake,
|
|
||||||
[&](const std::string & name, Value & vProvide, const Pos & pos) {
|
|
||||||
auto provide = nlohmann::json::object();
|
|
||||||
|
|
||||||
if (name == "checks" || name == "packages") {
|
|
||||||
state->forceAttrs(vProvide, pos);
|
|
||||||
for (auto & aCheck : *vProvide.attrs)
|
|
||||||
provide[aCheck.name] = nlohmann::json::object();
|
|
||||||
}
|
|
||||||
|
|
||||||
outputs[name] = provide;
|
|
||||||
});
|
|
||||||
|
|
||||||
json["outputs"] = std::move(outputs);
|
|
||||||
|
|
||||||
std::cout << json.dump() << std::endl;
|
std::cout << json.dump() << std::endl;
|
||||||
} else {
|
} else
|
||||||
auto flake = getFlake();
|
|
||||||
stopProgressBar();
|
|
||||||
printFlakeInfo(*store, flake);
|
printFlakeInfo(*store, flake);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ let
|
||||||
dir=NixOS-nixpkgs-${nixpkgs.shortRev}
|
dir=NixOS-nixpkgs-${nixpkgs.shortRev}
|
||||||
cp -prd ${nixpkgs} $dir
|
cp -prd ${nixpkgs} $dir
|
||||||
# Set the correct timestamp in the tarball.
|
# Set the correct timestamp in the tarball.
|
||||||
find $dir -print0 | xargs -0 touch -t ${builtins.substring 0 12 nixpkgs.lastModified}.${builtins.substring 12 2 nixpkgs.lastModified} --
|
find $dir -print0 | xargs -0 touch -t ${builtins.substring 0 12 nixpkgs.lastModifiedDate}.${builtins.substring 12 2 nixpkgs.lastModifiedDate} --
|
||||||
tar cfz $out/tarball/${nixpkgs.rev} $dir --hard-dereference
|
tar cfz $out/tarball/${nixpkgs.rev} $dir --hard-dereference
|
||||||
|
|
||||||
mkdir -p $out/commits
|
mkdir -p $out/commits
|
||||||
|
@ -128,7 +128,7 @@ makeTest (
|
||||||
$github->succeed("systemctl stop httpd.service");
|
$github->succeed("systemctl stop httpd.service");
|
||||||
|
|
||||||
my $date = $client->succeed("nix flake info nixpkgs --json | jq -M .lastModified");
|
my $date = $client->succeed("nix flake info nixpkgs --json | jq -M .lastModified");
|
||||||
strftime("%Y%m%d%H%M%S", gmtime($date)) eq "${nixpkgs.lastModified}" or die "time mismatch";
|
strftime("%Y%m%d%H%M%S", gmtime($date)) eq "${nixpkgs.lastModifiedDate}" or die "time mismatch";
|
||||||
|
|
||||||
$client->succeed("nix build nixpkgs#hello");
|
$client->succeed("nix build nixpkgs#hello");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue