1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 12:41:15 +02:00

Merge remote-tracking branch 'origin/2.26-maintenance' into sync-with-2.26

This commit is contained in:
Eelco Dolstra 2025-03-05 18:01:03 +01:00
commit 25ba7c55d3
5 changed files with 157 additions and 95 deletions

View file

@ -52,7 +52,7 @@ let
setVersionLayer = finalAttrs: prevAttrs: {
/*
preConfigure =
prevAttrs.prevAttrs or ""
prevAttrs.preConfigure or ""
+
# Update the repo-global .version file.
# Symlink ./.version points there, but by default only workDir is writable.

View file

@ -1,6 +1,7 @@
{
lib,
stdenv,
lndir,
buildEnv,
nix-util,
@ -38,7 +39,6 @@
nix-perl-bindings,
testers,
runCommand,
}:
let
@ -119,19 +119,49 @@ let
};
in
(buildEnv {
name = "determinate-nix-${nix-cli.version}";
paths = [
nix-cli
nix-manual.man
stdenv.mkDerivation (finalAttrs: {
pname = "determinate-nix";
version = nix-cli.version;
/**
This package uses a multi-output derivation, even though some outputs could
have been provided directly by the constituent component that provides it.
This is because not all tooling handles packages composed of arbitrary
outputs yet. This includes nix itself, https://github.com/NixOS/nix/issues/6507.
`devdoc` is also available, but not listed here, because this attribute is
not an output of the same derivation that provides `out`, `dev`, etc.
*/
outputs = [
"out"
"dev"
"doc"
"man"
];
meta.mainProgram = "nix";
}).overrideAttrs
(
finalAttrs: prevAttrs: {
/**
Unpacking is handled in this package's constituent components
*/
dontUnpack = true;
/**
Building is handled in this package's constituent components
*/
dontBuild = true;
/**
`doCheck` controles whether tests are added as build gate for the combined package.
This includes both the unit tests and the functional tests, but not the
integration tests that run in CI (the flake's `hydraJobs` and some of the `checks`).
*/
doCheck = true;
doInstallCheck = true;
/**
`fixupPhase` currently doesn't understand that a symlink output isn't writable.
We don't compile or link anything in this derivation, so fixups aren't needed.
*/
dontFixup = true;
checkInputs =
[
@ -144,10 +174,6 @@ in
# Make sure the functional tests have passed
nix-functional-tests
# dev bundle is ok
# (checkInputs must be empty paths??)
(runCommand "check-pkg-config" { checked = dev.tests.pkg-config; } "mkdir $out")
]
++ lib.optionals
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
@ -156,7 +182,30 @@ in
# TODO: Split out tests into a separate derivation?
nix-perl-bindings
];
passthru = prevAttrs.passthru // {
nativeBuildInputs = [
lndir
];
installPhase =
let
devPaths = lib.mapAttrsToList (_k: lib.getDev) finalAttrs.finalPackage.libs;
in
''
mkdir -p $out $dev $doc $man
# Merged outputs
lndir ${nix-cli} $out
for lib in ${lib.escapeShellArgs devPaths}; do
lndir $lib $dev
done
# Forwarded outputs
ln -s ${nix-manual} $doc
ln -s ${nix-manual.man} $man
'';
passthru = {
inherit (nix-cli) version;
/**
@ -178,33 +227,28 @@ in
*/
inherit libs;
tests = prevAttrs.passthru.tests or { } // {
# TODO: create a proper fixpoint and:
# pkg-config =
# testers.hasPkgConfigModules {
# package = finalPackage;
# };
};
/**
Developer documentation for `nix`, in `share/doc/nix/{internal,external}-api/`.
This is not a proper output; see `outputs` for context.
*/
inherit devdoc;
/**
A derivation referencing the `dev` outputs of the Nix libraries.
Extra tests that test this package, but do not run as part of the build.
See <https://nixos.org/manual/nixpkgs/stable/index.html#var-passthru-tests>
*/
inherit dev;
inherit devdoc;
doc = nix-manual;
outputs = [
"out"
"dev"
"devdoc"
"doc"
];
all = lib.attrValues (
lib.genAttrs finalAttrs.passthru.outputs (outName: finalAttrs.finalPackage.${outName})
);
tests = {
pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
meta = prevAttrs.meta // {
};
};
meta = {
mainProgram = "nix";
description = "The Nix package manager";
pkgConfigModules = dev.meta.pkgConfigModules;
};
}
)
})

View file

@ -1088,23 +1088,23 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
nlohmann::json jsonObj2 = json ? json::object() : nlohmann::json(nullptr);
for (auto & [inputName, input] : node.inputs) {
if (auto inputNode = std::get_if<0>(&input)) {
if ((*inputNode)->lockedRef.input.isRelative())
continue;
auto storePath =
std::optional<StorePath> storePath;
if (!(*inputNode)->lockedRef.input.isRelative()) {
storePath =
dryRun
? (*inputNode)->lockedRef.input.computeStorePath(*store)
: (*inputNode)->lockedRef.input.fetchToStore(store).first;
sources.insert(*storePath);
}
if (json) {
auto & jsonObj3 = jsonObj2[inputName];
jsonObj3["path"] = store->printStorePath(storePath);
sources.insert(std::move(storePath));
if (storePath)
jsonObj3["path"] = store->printStorePath(*storePath);
jsonObj3["inputs"] = traverse(**inputNode);
} else {
sources.insert(std::move(storePath));
} else
traverse(**inputNode);
}
}
}
return jsonObj2;
};

View file

@ -99,6 +99,16 @@ writeTrivialFlake() {
EOF
}
initGitRepo() {
local repo="$1"
local extraArgs="${2-}"
# shellcheck disable=SC2086 # word splitting of extraArgs is intended
git -C "$repo" init $extraArgs
git -C "$repo" config user.email "foobar@example.com"
git -C "$repo" config user.name "Foobar"
}
createGitRepo() {
local repo="$1"
local extraArgs="${2-}"
@ -107,7 +117,5 @@ createGitRepo() {
mkdir -p "$repo"
# shellcheck disable=SC2086 # word splitting of extraArgs is intended
git -C "$repo" init $extraArgs
git -C "$repo" config user.email "foobar@example.com"
git -C "$repo" config user.name "Foobar"
initGitRepo "$repo" $extraArgs
}

View file

@ -45,7 +45,7 @@ EOF
[[ $(nix eval "$rootFlake?dir=sub1#y") = 6 ]]
git init "$rootFlake"
initGitRepo "$rootFlake"
git -C "$rootFlake" add flake.nix sub0/flake.nix sub1/flake.nix
[[ $(nix eval "$subflake1#y") = 6 ]]
@ -77,7 +77,17 @@ fi
(! grep narHash "$subflake2/flake.lock")
# Test `nix flake archive` with relative path flakes.
nix flake archive --json "$rootFlake"
git -C "$rootFlake" add flake.lock
git -C "$rootFlake" commit -a -m Foo
json=$(nix flake archive --json "$rootFlake" --to "$TEST_ROOT/store2")
[[ $(echo "$json" | jq .inputs.sub0.inputs) = {} ]]
[[ -n $(echo "$json" | jq .path) ]]
#nix flake prefetch --out-link "$TEST_ROOT/result" "$rootFlake"
#outPath=$(readlink "$TEST_ROOT/result")
#[ -e "$TEST_ROOT/store2/nix/store/$(basename "$outPath")" ]
# Test circular relative path flakes. FIXME: doesn't work at the moment.
if false; then