mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 01:39:36 +01:00
Tagging release 2.28.3
-----BEGIN PGP SIGNATURE----- iQFHBAABCAAxFiEEtUHVUwEnDgvPFcpdgXC0cm1xmN4FAmgRLc8THGVkb2xzdHJh QGdtYWlsLmNvbQAKCRCBcLRybXGY3itzB/0ehHDYPXycvwpdL4MuAcroY5GgQJLz dGkrmv9tMQXERqjnqd86LW6BgKwG3UY12xFMeFgYQyV/TzC6iwZUgI+Kr+baFMhH JoEXgLTXRwnyC54mXUGPrX6P9MwPBoUpAClaG5iH9SCV70Z/PLuXsd4/HoDmLxsi tVCTxoq9kn7o/YAMOQGY3KTfM26LqEPOv2vTco2ETEnNqSXCjUJ/MniMdTGCsTxy rdWqel95EuIb0qsMSRPrVV6xmx/KjamTSzdCcXWQbpAu4xjUyacnjL3XpGWkMUKV HKtbNdXboHwJgtwe66HMCgtfWPB6JCamMRm+h/b6BrTTz46eJWiaG/KW =Exmm -----END PGP SIGNATURE----- Merge tag '2.28.3' into sync-2.28.3 Tagging release 2.28.3
This commit is contained in:
commit
c92cb4c130
29 changed files with 148 additions and 105 deletions
|
|
@ -40,7 +40,7 @@ void completeFlakeInputAttrPath(
|
|||
std::string_view prefix)
|
||||
{
|
||||
for (auto & flakeRef : flakeRefs) {
|
||||
auto flake = flake::getFlake(*evalState, flakeRef, true);
|
||||
auto flake = flake::getFlake(*evalState, flakeRef, fetchers::UseRegistries::All);
|
||||
for (auto & input : flake.inputs)
|
||||
if (hasPrefix(input.first, prefix))
|
||||
completions.add(input.first);
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ static void fetchTree(
|
|||
}
|
||||
|
||||
if (!state.settings.pureEval && !input.isDirect())
|
||||
input = lookupInRegistries(state.store, input).first;
|
||||
input = lookupInRegistries(state.store, input, fetchers::UseRegistries::Limited).first;
|
||||
|
||||
if (state.settings.pureEval && !input.isLocked()) {
|
||||
if (input.getNarHash())
|
||||
|
|
|
|||
|
|
@ -65,7 +65,11 @@ void overrideRegistry(
|
|||
const Input & to,
|
||||
const Attrs & extraAttrs);
|
||||
|
||||
using RegistryFilter = std::function<bool(Registry::RegistryType)>;
|
||||
enum class UseRegistries : int {
|
||||
No,
|
||||
All,
|
||||
Limited, // global and flag registry only
|
||||
};
|
||||
|
||||
/**
|
||||
* Rewrite a flakeref using the registries. If `filter` is set, only
|
||||
|
|
@ -74,6 +78,6 @@ using RegistryFilter = std::function<bool(Registry::RegistryType)>;
|
|||
std::pair<Input, Attrs> lookupInRegistries(
|
||||
ref<Store> store,
|
||||
const Input & input,
|
||||
const RegistryFilter & filter = {});
|
||||
UseRegistries useRegistries);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ std::shared_ptr<Registry> Registry::read(
|
|||
const Settings & settings,
|
||||
const Path & path, RegistryType type)
|
||||
{
|
||||
debug("reading registry '%s'", path);
|
||||
|
||||
auto registry = std::make_shared<Registry>(settings, type);
|
||||
|
||||
if (!pathExists(path))
|
||||
|
|
@ -179,29 +181,36 @@ Registries getRegistries(const Settings & settings, ref<Store> store)
|
|||
std::pair<Input, Attrs> lookupInRegistries(
|
||||
ref<Store> store,
|
||||
const Input & _input,
|
||||
const RegistryFilter & filter)
|
||||
UseRegistries useRegistries)
|
||||
{
|
||||
Attrs extraAttrs;
|
||||
int n = 0;
|
||||
Input input(_input);
|
||||
|
||||
if (useRegistries == UseRegistries::No)
|
||||
return {input, extraAttrs};
|
||||
|
||||
restart:
|
||||
|
||||
n++;
|
||||
if (n > 100) throw Error("cycle detected in flake registry for '%s'", input.to_string());
|
||||
|
||||
for (auto & registry : getRegistries(*input.settings, store)) {
|
||||
if (filter && !filter(registry->type)) continue;
|
||||
if (useRegistries == UseRegistries::Limited
|
||||
&& !(registry->type == fetchers::Registry::Flag || registry->type == fetchers::Registry::Global))
|
||||
continue;
|
||||
// FIXME: O(n)
|
||||
for (auto & entry : registry->entries) {
|
||||
if (entry.exact) {
|
||||
if (entry.from == input) {
|
||||
debug("resolved flakeref '%s' against registry %d exactly", input.to_string(), registry->type);
|
||||
input = entry.to;
|
||||
extraAttrs = entry.extraAttrs;
|
||||
goto restart;
|
||||
}
|
||||
} else {
|
||||
if (entry.from.contains(input)) {
|
||||
debug("resolved flakeref '%s' against registry %d", input.to_string(), registry->type);
|
||||
input = entry.to.applyOverrides(
|
||||
!entry.from.getRef() && input.getRef() ? input.getRef() : std::optional<std::string>(),
|
||||
!entry.from.getRev() && input.getRev() ? input.getRev() : std::optional<Hash>());
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static std::optional<FetchedFlake> lookupInFlakeCache(
|
|||
static std::tuple<ref<SourceAccessor>, FlakeRef, FlakeRef> fetchOrSubstituteTree(
|
||||
EvalState & state,
|
||||
const FlakeRef & originalRef,
|
||||
bool useRegistries,
|
||||
fetchers::UseRegistries useRegistries,
|
||||
FlakeCache & flakeCache)
|
||||
{
|
||||
auto fetched = lookupInFlakeCache(flakeCache, originalRef);
|
||||
|
|
@ -57,14 +57,8 @@ static std::tuple<ref<SourceAccessor>, FlakeRef, FlakeRef> fetchOrSubstituteTree
|
|||
auto [accessor, lockedRef] = originalRef.lazyFetch(state.store);
|
||||
fetched.emplace(FetchedFlake{.lockedRef = lockedRef, .accessor = accessor});
|
||||
} else {
|
||||
if (useRegistries) {
|
||||
resolvedRef = originalRef.resolve(
|
||||
state.store,
|
||||
[](fetchers::Registry::RegistryType type) {
|
||||
/* Only use the global registry and CLI flags
|
||||
to resolve indirect flakerefs. */
|
||||
return type == fetchers::Registry::Flag || type == fetchers::Registry::Global;
|
||||
});
|
||||
if (useRegistries != fetchers::UseRegistries::No) {
|
||||
resolvedRef = originalRef.resolve(state.store, useRegistries);
|
||||
fetched = lookupInFlakeCache(flakeCache, originalRef);
|
||||
if (!fetched) {
|
||||
auto [accessor, lockedRef] = resolvedRef.lazyFetch(state.store);
|
||||
|
|
@ -399,7 +393,7 @@ static FlakeRef applySelfAttrs(
|
|||
static Flake getFlake(
|
||||
EvalState & state,
|
||||
const FlakeRef & originalRef,
|
||||
bool useRegistries,
|
||||
fetchers::UseRegistries useRegistries,
|
||||
FlakeCache & flakeCache,
|
||||
const InputAttrPath & lockRootAttrPath)
|
||||
{
|
||||
|
|
@ -418,7 +412,7 @@ static Flake getFlake(
|
|||
// FIXME: need to remove attrs that are invalidated by the changed input attrs, such as 'narHash'.
|
||||
newLockedRef.input.attrs.erase("narHash");
|
||||
auto [accessor2, resolvedRef2, lockedRef2] = fetchOrSubstituteTree(
|
||||
state, newLockedRef, false, flakeCache);
|
||||
state, newLockedRef, fetchers::UseRegistries::No, flakeCache);
|
||||
accessor = accessor2;
|
||||
lockedRef = lockedRef2;
|
||||
}
|
||||
|
|
@ -430,7 +424,7 @@ static Flake getFlake(
|
|||
return readFlake(state, originalRef, resolvedRef, lockedRef, state.storePath(storePath), lockRootAttrPath);
|
||||
}
|
||||
|
||||
Flake getFlake(EvalState & state, const FlakeRef & originalRef, bool useRegistries)
|
||||
Flake getFlake(EvalState & state, const FlakeRef & originalRef, fetchers::UseRegistries useRegistries)
|
||||
{
|
||||
FlakeCache flakeCache;
|
||||
return getFlake(state, originalRef, useRegistries, flakeCache, {});
|
||||
|
|
@ -456,8 +450,15 @@ LockedFlake lockFlake(
|
|||
FlakeCache flakeCache;
|
||||
|
||||
auto useRegistries = lockFlags.useRegistries.value_or(settings.useRegistries);
|
||||
auto useRegistriesTop = useRegistries ? fetchers::UseRegistries::All : fetchers::UseRegistries::No;
|
||||
auto useRegistriesInputs = useRegistries ? fetchers::UseRegistries::Limited : fetchers::UseRegistries::No;
|
||||
|
||||
auto flake = getFlake(state, topRef, useRegistries, flakeCache, {});
|
||||
auto flake = getFlake(
|
||||
state,
|
||||
topRef,
|
||||
useRegistriesTop,
|
||||
flakeCache,
|
||||
{});
|
||||
|
||||
if (lockFlags.applyNixConfig) {
|
||||
flake.config.apply(settings);
|
||||
|
|
@ -632,7 +633,12 @@ LockedFlake lockFlake(
|
|||
if (auto resolvedPath = resolveRelativePath()) {
|
||||
return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath);
|
||||
} else {
|
||||
return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath);
|
||||
return getFlake(
|
||||
state,
|
||||
ref,
|
||||
useRegistriesInputs,
|
||||
flakeCache,
|
||||
inputAttrPath);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -806,7 +812,7 @@ LockedFlake lockFlake(
|
|||
return {*resolvedPath, *input.ref};
|
||||
} else {
|
||||
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||
state, *input.ref, useRegistries, flakeCache);
|
||||
state, *input.ref, useRegistriesInputs, flakeCache);
|
||||
|
||||
warnRegistry(resolvedRef);
|
||||
|
||||
|
|
@ -923,7 +929,10 @@ LockedFlake lockFlake(
|
|||
repo, so we should re-read it. FIXME: we could
|
||||
also just clear the 'rev' field... */
|
||||
auto prevLockedRef = flake.lockedRef;
|
||||
flake = getFlake(state, topRef, useRegistries);
|
||||
flake = getFlake(
|
||||
state,
|
||||
topRef,
|
||||
useRegistriesTop);
|
||||
|
||||
if (lockFlags.commitLockFile &&
|
||||
flake.lockedRef.input.getRev() &&
|
||||
|
|
@ -37,9 +37,9 @@ std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef)
|
|||
|
||||
FlakeRef FlakeRef::resolve(
|
||||
ref<Store> store,
|
||||
const fetchers::RegistryFilter & filter) const
|
||||
fetchers::UseRegistries useRegistries) const
|
||||
{
|
||||
auto [input2, extraAttrs] = lookupInRegistries(store, input, filter);
|
||||
auto [input2, extraAttrs] = lookupInRegistries(store, input, useRegistries);
|
||||
return FlakeRef(std::move(input2), fetchers::maybeGetStrAttr(extraAttrs, "dir").value_or(subdir));
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ struct Flake
|
|||
}
|
||||
};
|
||||
|
||||
Flake getFlake(EvalState & state, const FlakeRef & flakeRef, bool useRegistries);
|
||||
Flake getFlake(EvalState & state, const FlakeRef & flakeRef, fetchers::UseRegistries useRegistries);
|
||||
|
||||
/**
|
||||
* Fingerprint of a locked flake; used as a cache key.
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ struct FlakeRef
|
|||
|
||||
FlakeRef resolve(
|
||||
ref<Store> store,
|
||||
const fetchers::RegistryFilter & filter = {}) const;
|
||||
fetchers::UseRegistries useRegistries = fetchers::UseRegistries::All) const;
|
||||
|
||||
static FlakeRef fromAttrs(
|
||||
const fetchers::Settings & fetchSettings,
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ foreach header : [
|
|||
endforeach
|
||||
|
||||
sources = files(
|
||||
'flake/config.cc',
|
||||
'flake/flake.cc',
|
||||
'flake/flakeref.cc',
|
||||
'flake/lockfile.cc',
|
||||
'flake/flake-primops.cc',
|
||||
'flake/settings.cc',
|
||||
'flake/url-name.cc',
|
||||
'config.cc',
|
||||
'flake.cc',
|
||||
'flakeref.cc',
|
||||
'lockfile.cc',
|
||||
'flake-primops.cc',
|
||||
'settings.cc',
|
||||
'url-name.cc',
|
||||
)
|
||||
|
||||
subdir('include/nix/flake')
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "nix/util/file-content-address.hh"
|
||||
|
|
@ -26,8 +27,11 @@ TEST(FileSerialisationMethod, testRoundTripPrintParse_2) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException) {
|
||||
EXPECT_THROW(parseFileSerialisationMethod("narwhal"), UsageError);
|
||||
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException)
|
||||
{
|
||||
EXPECT_THAT(
|
||||
[]() { parseFileSerialisationMethod("narwhal"); },
|
||||
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
|
|
@ -54,8 +58,11 @@ TEST(FileIngestionMethod, testRoundTripPrintParse_2) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException) {
|
||||
EXPECT_THROW(parseFileIngestionMethod("narwhal"), UsageError);
|
||||
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException)
|
||||
{
|
||||
EXPECT_THAT(
|
||||
[]() { parseFileIngestionMethod("narwhal"); },
|
||||
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#include "nix/util/util.hh"
|
||||
#include "nix/util/monitor-fd.hh"
|
||||
#ifndef _WIN32
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <gtest/gtest.h>
|
||||
# include "nix/util/util.hh"
|
||||
# include "nix/util/monitor-fd.hh"
|
||||
|
||||
# include <sys/file.h>
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
namespace nix {
|
||||
TEST(MonitorFdHup, shouldNotBlock)
|
||||
|
|
@ -16,3 +18,5 @@ TEST(MonitorFdHup, shouldNotBlock)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ FileSerialisationMethod parseFileSerialisationMethod(std::string_view input)
|
|||
if (ret)
|
||||
return *ret;
|
||||
else
|
||||
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`");
|
||||
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`", input);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ FileIngestionMethod parseFileIngestionMethod(std::string_view input)
|
|||
if (ret)
|
||||
return static_cast<FileIngestionMethod>(*ret);
|
||||
else
|
||||
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`");
|
||||
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`", input);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ Path canonPath(PathView path, bool resolveSymlinks)
|
|||
(std::string & result, std::string_view & remaining) {
|
||||
if (resolveSymlinks && fs::is_symlink(result)) {
|
||||
if (++followCount >= maxFollow)
|
||||
throw Error("infinite symlink recursion in path '%0%'", remaining);
|
||||
throw Error("infinite symlink recursion in path '%1%'", remaining);
|
||||
remaining = (temp = concatStrings(readLink(result), remaining));
|
||||
if (isAbsolute(remaining)) {
|
||||
/* restart for symlinks pointing to absolute path */
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ void parseTree(
|
|||
RawMode rawMode = std::stoi(perms, 0, 8);
|
||||
auto modeOpt = decodeMode(rawMode);
|
||||
if (!modeOpt)
|
||||
throw Error("Unknown Git permission: %o", perms);
|
||||
throw Error("Unknown Git permission: %o", rawMode);
|
||||
auto mode = std::move(*modeOpt);
|
||||
|
||||
std::string name = getStringUntil(source, '\0');
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ static int childEntry(void * arg)
|
|||
|
||||
pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
|
||||
{
|
||||
auto newLogger = makeSimpleLogger();
|
||||
ChildWrapperFunction wrapper = [&] {
|
||||
if (!options.allowVfork) {
|
||||
/* Set a simple logger, while releasing (not destroying)
|
||||
|
|
@ -210,7 +211,7 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
|
|||
~ProgressBar() tries to join a thread that doesn't
|
||||
exist. */
|
||||
logger.release();
|
||||
logger = makeSimpleLogger();
|
||||
logger = std::move(newLogger);
|
||||
}
|
||||
try {
|
||||
#ifdef __linux__
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
mkMesonExecutable,
|
||||
|
||||
|
|
@ -94,6 +95,11 @@ mkMesonExecutable (finalAttrs: {
|
|||
mesonFlags = [
|
||||
];
|
||||
|
||||
postInstall = lib.optionalString stdenv.hostPlatform.isStatic ''
|
||||
mkdir -p $out/nix-support
|
||||
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
||||
'';
|
||||
|
||||
meta = {
|
||||
mainProgram = "nix";
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue