1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 06:11:46 +02: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:
Eelco Dolstra 2025-04-30 17:45:27 +02:00
commit c92cb4c130
29 changed files with 148 additions and 105 deletions

View file

@ -1 +1 @@
2.28.2
2.28.3

View file

@ -142,14 +142,15 @@
# without "polluting" the top level "`pkgs`" attrset.
# This also has the benefit of providing us with a distinct set of packages
# we can iterate over.
nixComponents =
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
nixComponents2 =
lib.makeScopeWithSplicing'
{
inherit (final) splicePackages;
inherit (final.nixDependencies) newScope;
inherit (final.nixDependencies2) newScope;
}
{
otherSplices = final.generateSplicesForMkScope "nixComponents";
otherSplices = final.generateSplicesForMkScope "nixComponents2";
f = import ./packaging/components.nix {
inherit (final) lib;
inherit officialRelease;
@ -160,22 +161,23 @@
};
# The dependencies are in their own scope, so that they don't have to be
# in Nixpkgs top level `pkgs` or `nixComponents`.
nixDependencies =
# in Nixpkgs top level `pkgs` or `nixComponents2`.
# The `2` suffix is here because otherwise it interferes with `nixVersions.latest`, which is used in daemon compat tests.
nixDependencies2 =
lib.makeScopeWithSplicing'
{
inherit (final) splicePackages;
inherit (final) newScope; # layered directly on pkgs, unlike nixComponents above
inherit (final) newScope; # layered directly on pkgs, unlike nixComponents2 above
}
{
otherSplices = final.generateSplicesForMkScope "nixDependencies";
otherSplices = final.generateSplicesForMkScope "nixDependencies2";
f = import ./packaging/dependencies.nix {
inherit inputs stdenv;
pkgs = final;
};
};
nix = final.nixComponents.nix-cli;
nix = final.nixComponents2.nix-cli;
# See https://github.com/NixOS/nixpkgs/pull/214409
# Remove when fixed in this flake's nixpkgs
@ -275,7 +277,7 @@
# memory leaks with detect_leaks=0.
"" = rec {
nixpkgs = nixpkgsFor.${system}.native;
nixComponents = nixpkgs.nixComponents.overrideScope (
nixComponents = nixpkgs.nixComponents2.overrideScope (
nixCompFinal: nixCompPrev: {
mesonComponentOverrides = _finalAttrs: prevAttrs: {
mesonFlags =
@ -303,7 +305,7 @@
nixpkgsPrefix:
{
nixpkgs,
nixComponents ? nixpkgs.nixComponents,
nixComponents ? nixpkgs.nixComponents2,
}:
flatMapAttrs nixComponents (
pkgName: pkg:
@ -333,9 +335,9 @@
binaryTarball = self.hydraJobs.binaryTarball.${system};
# TODO probably should be `nix-cli`
nix = self.packages.${system}.nix-everything;
nix-manual = nixpkgsFor.${system}.native.nixComponents.nix-manual;
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
nix-manual = nixpkgsFor.${system}.native.nixComponents2.nix-manual;
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-external-api-docs;
fallbackPathsNix =
let
@ -421,7 +423,7 @@
}:
{
# These attributes go right into `packages.<system>`.
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName};
"${pkgName}" = nixpkgsFor.${system}.native.nixComponents2.${pkgName};
}
// lib.optionalAttrs supportsCross (
flatMapAttrs (lib.genAttrs crossSystems (_: { })) (
@ -429,7 +431,7 @@
{ }:
{
# These attributes go right into `packages.<system>`.
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName};
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents2.${pkgName};
}
)
)
@ -439,7 +441,7 @@
{
# These attributes go right into `packages.<system>`.
"${pkgName}-${stdenvName}" =
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents.${pkgName};
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName};
}
)
)

View file

@ -172,14 +172,14 @@
''^src/libfetchers/include/nix/fetchers/tarball\.hh$''
''^src/libfetchers/git\.cc$''
''^src/libfetchers/mercurial\.cc$''
''^src/libflake/flake/config\.cc$''
''^src/libflake/flake/flake\.cc$''
''^src/libflake/config\.cc$''
''^src/libflake/flake\.cc$''
''^src/libflake/include/nix/flake/flake\.hh$''
''^src/libflake/flake/flakeref\.cc$''
''^src/libflake/flakeref\.cc$''
''^src/libflake/include/nix/flake/flakeref\.hh$''
''^src/libflake/flake/lockfile\.cc$''
''^src/libflake/lockfile\.cc$''
''^src/libflake/include/nix/flake/lockfile\.hh$''
''^src/libflake/flake/url-name\.cc$''
''^src/libflake/url-name\.cc$''
''^src/libmain/common-args\.cc$''
''^src/libmain/include/nix/main/common-args\.hh$''
''^src/libmain/loggers\.cc$''

View file

@ -5,11 +5,11 @@
{ pkgs }:
pkgs.nixComponents.nix-util.overrideAttrs (
pkgs.nixComponents2.nix-util.overrideAttrs (
attrs:
let
stdenv = pkgs.nixDependencies.stdenv;
stdenv = pkgs.nixDependencies2.stdenv;
buildCanExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
modular = devFlake.getSystem stdenv.buildPlatform.system;
transformFlag =
@ -79,26 +79,26 @@ pkgs.nixComponents.nix-util.overrideAttrs (
};
mesonFlags =
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents.nix-util.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents.nix-store.mesonFlags)
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents.nix-fetchers.mesonFlags)
map (transformFlag "libutil") (ignoreCrossFile pkgs.nixComponents2.nix-util.mesonFlags)
++ map (transformFlag "libstore") (ignoreCrossFile pkgs.nixComponents2.nix-store.mesonFlags)
++ map (transformFlag "libfetchers") (ignoreCrossFile pkgs.nixComponents2.nix-fetchers.mesonFlags)
++ lib.optionals havePerl (
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents.nix-perl-bindings.mesonFlags)
map (transformFlag "perl") (ignoreCrossFile pkgs.nixComponents2.nix-perl-bindings.mesonFlags)
)
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents.nix-cmd.mesonFlags);
++ map (transformFlag "libexpr") (ignoreCrossFile pkgs.nixComponents2.nix-expr.mesonFlags)
++ map (transformFlag "libcmd") (ignoreCrossFile pkgs.nixComponents2.nix-cmd.mesonFlags);
nativeBuildInputs =
attrs.nativeBuildInputs or [ ]
++ pkgs.nixComponents.nix-util.nativeBuildInputs
++ pkgs.nixComponents.nix-store.nativeBuildInputs
++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs
++ pkgs.nixComponents.nix-expr.nativeBuildInputs
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs
++ lib.optionals buildCanExecuteHost pkgs.nixComponents.nix-manual.externalNativeBuildInputs
++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-functional-tests.externalNativeBuildInputs
++ pkgs.nixComponents2.nix-util.nativeBuildInputs
++ pkgs.nixComponents2.nix-store.nativeBuildInputs
++ pkgs.nixComponents2.nix-fetchers.nativeBuildInputs
++ pkgs.nixComponents2.nix-expr.nativeBuildInputs
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.nativeBuildInputs
++ lib.optionals buildCanExecuteHost pkgs.nixComponents2.nix-manual.externalNativeBuildInputs
++ pkgs.nixComponents2.nix-internal-api-docs.nativeBuildInputs
++ pkgs.nixComponents2.nix-external-api-docs.nativeBuildInputs
++ pkgs.nixComponents2.nix-functional-tests.externalNativeBuildInputs
++ lib.optional (
!buildCanExecuteHost
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
@ -123,14 +123,14 @@ pkgs.nixComponents.nix-util.overrideAttrs (
buildInputs =
attrs.buildInputs or [ ]
++ pkgs.nixComponents.nix-util.buildInputs
++ pkgs.nixComponents.nix-store.buildInputs
++ pkgs.nixComponents.nix-store-tests.externalBuildInputs
++ pkgs.nixComponents.nix-fetchers.buildInputs
++ pkgs.nixComponents.nix-expr.buildInputs
++ pkgs.nixComponents.nix-expr.externalPropagatedBuildInputs
++ pkgs.nixComponents.nix-cmd.buildInputs
++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.externalBuildInputs
++ pkgs.nixComponents2.nix-util.buildInputs
++ pkgs.nixComponents2.nix-store.buildInputs
++ pkgs.nixComponents2.nix-store-tests.externalBuildInputs
++ pkgs.nixComponents2.nix-fetchers.buildInputs
++ pkgs.nixComponents2.nix-expr.buildInputs
++ pkgs.nixComponents2.nix-expr.externalPropagatedBuildInputs
++ pkgs.nixComponents2.nix-cmd.buildInputs
++ lib.optionals havePerl pkgs.nixComponents2.nix-perl-bindings.externalBuildInputs
++ lib.optional havePerl pkgs.perl;
}
)

View file

@ -19,14 +19,14 @@ let
testNixVersions =
pkgs: daemon:
pkgs.nixComponents.nix-functional-tests.override {
pkgs.nixComponents2.nix-functional-tests.override {
pname = "nix-daemon-compat-tests";
version = "${pkgs.nix.version}-with-daemon-${daemon.version}";
test-daemon = daemon;
};
# Technically we could just return `pkgs.nixComponents`, but for Hydra it's
# Technically we could just return `pkgs.nixComponents2`, but for Hydra it's
# convention to transpose it, and to transpose it efficiently, we need to
# enumerate them manually, so that we don't evaluate unnecessary package sets.
# See listingIsComplete below.
@ -85,7 +85,7 @@ in
} (_: null);
actualPkgs = lib.concatMapAttrs (
k: v: if lib.strings.hasPrefix "nix-" k then { ${k} = null; } else { }
) nixpkgsFor.${arbitrarySystem}.native.nixComponents;
) nixpkgsFor.${arbitrarySystem}.native.nixComponents2;
diff = lib.concatStringsSep "\n" (
lib.concatLists (
lib.mapAttrsToList (
@ -111,7 +111,7 @@ in
# Binary package for various platforms.
build = forAllPackages (
pkgName: forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.${pkgName})
pkgName: forAllSystems (system: nixpkgsFor.${system}.native.nixComponents2.${pkgName})
);
shellInputs = removeAttrs (forAllSystems (
@ -119,7 +119,7 @@ in
)) [ "i686-linux" ];
# Perl bindings for various platforms.
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.nix-perl-bindings);
perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents2.nix-perl-bindings);
# Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of
@ -145,13 +145,13 @@ in
# };
# Nix's manual
manual = nixpkgsFor.x86_64-linux.native.nixComponents.nix-manual;
manual = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-manual;
# API docs for Nix's unstable internal C++ interfaces.
internal-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-internal-api-docs;
internal-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-internal-api-docs;
# API docs for Nix's C bindings.
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-external-api-docs;
external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents2.nix-external-api-docs;
# System tests.
tests =

View file

@ -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);

View file

@ -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())

View file

@ -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);
}

View file

@ -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>());

View file

@ -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() &&

View file

@ -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));
}

View file

@ -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.

View file

@ -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,

View file

@ -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')

View file

@ -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")));
}
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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 */

View file

@ -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');

View file

@ -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__

View file

@ -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;

View file

@ -223,7 +223,7 @@ mv "$registry.tmp" "$registry"
# Ensure that locking ignores the user registry.
mkdir -p "$TEST_HOME/.config/nix"
ln -sfn "$registry" "$TEST_HOME/.config/nix/registry.json"
nix flake metadata flake1
nix flake metadata --flake-registry '' flake1
expectStderr 1 nix flake update --flake-registry '' --flake "$flake3Dir" | grepQuiet "cannot find flake 'flake:flake1' in the flake registries"
rm "$TEST_HOME/.config/nix/registry.json"
@ -266,6 +266,7 @@ nix registry add user-flake2 "git+file://$percentEncodedFlake2Dir"
[[ $(nix --flake-registry "" registry list | wc -l) == 2 ]]
nix --flake-registry "" registry list | grepQuietInverse '^global' # nothing in global registry
nix --flake-registry "" registry list | grepQuiet '^user'
nix flake metadata --flake-registry "" user-flake1 | grepQuiet 'URL:.*flake1.*'
nix registry remove user-flake1
nix registry remove user-flake2
[[ $(nix registry list | wc -l) == 4 ]]

View file

@ -31,7 +31,7 @@ let
nixpkgs.pkgs = nixpkgsFor.${system}.native;
nix.checkAllErrors = false;
# TODO: decide which packaging stage to use. `nix-cli` is efficient, but not the same as the user-facing `everything.nix` package (`default`). Perhaps a good compromise is `everything.nix` + `noTests` defined above?
nix.package = nixpkgsFor.${system}.native.nixComponents.nix-cli;
nix.package = nixpkgsFor.${system}.native.nixComponents2.nix-cli;
# Evaluate VMs faster
documentation.enable = false;

View file

@ -49,11 +49,11 @@ in
cd ~
cp -r ${pkgs.nixComponents.nix-functional-tests.src} nix
cp -r ${pkgs.nixComponents2.nix-functional-tests.src} nix
chmod -R +w nix
chmod u+w nix/.version
echo ${pkgs.nixComponents.version} > nix/.version
echo ${pkgs.nixComponents2.version} > nix/.version
export isTestOnNixOS=1