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:
commit
25ba7c55d3
5 changed files with 157 additions and 95 deletions
|
@ -52,7 +52,7 @@ let
|
||||||
setVersionLayer = finalAttrs: prevAttrs: {
|
setVersionLayer = finalAttrs: prevAttrs: {
|
||||||
/*
|
/*
|
||||||
preConfigure =
|
preConfigure =
|
||||||
prevAttrs.prevAttrs or ""
|
prevAttrs.preConfigure or ""
|
||||||
+
|
+
|
||||||
# Update the repo-global .version file.
|
# Update the repo-global .version file.
|
||||||
# Symlink ./.version points there, but by default only workDir is writable.
|
# Symlink ./.version points there, but by default only workDir is writable.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
|
lndir,
|
||||||
buildEnv,
|
buildEnv,
|
||||||
|
|
||||||
nix-util,
|
nix-util,
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
nix-perl-bindings,
|
nix-perl-bindings,
|
||||||
|
|
||||||
testers,
|
testers,
|
||||||
runCommand,
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -119,92 +119,136 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
(buildEnv {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
name = "determinate-nix-${nix-cli.version}";
|
pname = "determinate-nix";
|
||||||
paths = [
|
version = nix-cli.version;
|
||||||
nix-cli
|
|
||||||
nix-manual.man
|
/**
|
||||||
|
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
|
Unpacking is handled in this package's constituent components
|
||||||
(
|
*/
|
||||||
finalAttrs: prevAttrs: {
|
dontUnpack = true;
|
||||||
doCheck = true;
|
/**
|
||||||
doInstallCheck = true;
|
Building is handled in this package's constituent components
|
||||||
|
*/
|
||||||
|
dontBuild = true;
|
||||||
|
|
||||||
checkInputs =
|
/**
|
||||||
[
|
`doCheck` controles whether tests are added as build gate for the combined package.
|
||||||
# Make sure the unit tests have passed
|
This includes both the unit tests and the functional tests, but not the
|
||||||
nix-util-tests.tests.run
|
integration tests that run in CI (the flake's `hydraJobs` and some of the `checks`).
|
||||||
nix-store-tests.tests.run
|
*/
|
||||||
nix-expr-tests.tests.run
|
doCheck = true;
|
||||||
nix-fetchers-tests.tests.run
|
|
||||||
nix-flake-tests.tests.run
|
|
||||||
|
|
||||||
# Make sure the functional tests have passed
|
/**
|
||||||
nix-functional-tests
|
`fixupPhase` currently doesn't understand that a symlink output isn't writable.
|
||||||
|
|
||||||
# dev bundle is ok
|
We don't compile or link anything in this derivation, so fixups aren't needed.
|
||||||
# (checkInputs must be empty paths??)
|
*/
|
||||||
(runCommand "check-pkg-config" { checked = dev.tests.pkg-config; } "mkdir $out")
|
dontFixup = true;
|
||||||
]
|
|
||||||
++ lib.optionals
|
|
||||||
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
|
||||||
[
|
|
||||||
# Perl currently fails in static build
|
|
||||||
# TODO: Split out tests into a separate derivation?
|
|
||||||
nix-perl-bindings
|
|
||||||
];
|
|
||||||
passthru = prevAttrs.passthru // {
|
|
||||||
inherit (nix-cli) version;
|
|
||||||
|
|
||||||
/**
|
checkInputs =
|
||||||
These are the libraries that are part of the Nix project. They are used
|
[
|
||||||
by the Nix CLI and other tools.
|
# Make sure the unit tests have passed
|
||||||
|
nix-util-tests.tests.run
|
||||||
|
nix-store-tests.tests.run
|
||||||
|
nix-expr-tests.tests.run
|
||||||
|
nix-fetchers-tests.tests.run
|
||||||
|
nix-flake-tests.tests.run
|
||||||
|
|
||||||
If you need to use these libraries in your project, we recommend to use
|
# Make sure the functional tests have passed
|
||||||
the `-c` C API libraries exclusively, if possible.
|
nix-functional-tests
|
||||||
|
]
|
||||||
|
++ lib.optionals
|
||||||
|
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
|
||||||
|
[
|
||||||
|
# Perl currently fails in static build
|
||||||
|
# TODO: Split out tests into a separate derivation?
|
||||||
|
nix-perl-bindings
|
||||||
|
];
|
||||||
|
|
||||||
We also recommend that you build the complete package to ensure that the unit tests pass.
|
nativeBuildInputs = [
|
||||||
You could do this in CI, or by passing it in an unused environment variable. e.g in a `mkDerivation` call:
|
lndir
|
||||||
|
];
|
||||||
|
|
||||||
```nix
|
installPhase =
|
||||||
buildInputs = [ nix.libs.nix-util-c nix.libs.nix-store-c ];
|
let
|
||||||
# Make sure the nix libs we use are ok
|
devPaths = lib.mapAttrsToList (_k: lib.getDev) finalAttrs.finalPackage.libs;
|
||||||
unusedInputsForTests = [ nix ];
|
in
|
||||||
disallowedReferences = nix.all;
|
''
|
||||||
```
|
mkdir -p $out $dev $doc $man
|
||||||
*/
|
|
||||||
inherit libs;
|
|
||||||
|
|
||||||
tests = prevAttrs.passthru.tests or { } // {
|
# Merged outputs
|
||||||
# TODO: create a proper fixpoint and:
|
lndir ${nix-cli} $out
|
||||||
# pkg-config =
|
for lib in ${lib.escapeShellArgs devPaths}; do
|
||||||
# testers.hasPkgConfigModules {
|
lndir $lib $dev
|
||||||
# package = finalPackage;
|
done
|
||||||
# };
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
# Forwarded outputs
|
||||||
A derivation referencing the `dev` outputs of the Nix libraries.
|
ln -s ${nix-manual} $doc
|
||||||
*/
|
ln -s ${nix-manual.man} $man
|
||||||
inherit dev;
|
'';
|
||||||
inherit devdoc;
|
|
||||||
doc = nix-manual;
|
passthru = {
|
||||||
outputs = [
|
inherit (nix-cli) version;
|
||||||
"out"
|
|
||||||
"dev"
|
/**
|
||||||
"devdoc"
|
These are the libraries that are part of the Nix project. They are used
|
||||||
"doc"
|
by the Nix CLI and other tools.
|
||||||
];
|
|
||||||
all = lib.attrValues (
|
If you need to use these libraries in your project, we recommend to use
|
||||||
lib.genAttrs finalAttrs.passthru.outputs (outName: finalAttrs.finalPackage.${outName})
|
the `-c` C API libraries exclusively, if possible.
|
||||||
);
|
|
||||||
|
We also recommend that you build the complete package to ensure that the unit tests pass.
|
||||||
|
You could do this in CI, or by passing it in an unused environment variable. e.g in a `mkDerivation` call:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
buildInputs = [ nix.libs.nix-util-c nix.libs.nix-store-c ];
|
||||||
|
# Make sure the nix libs we use are ok
|
||||||
|
unusedInputsForTests = [ nix ];
|
||||||
|
disallowedReferences = nix.all;
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
inherit libs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Developer documentation for `nix`, in `share/doc/nix/{internal,external}-api/`.
|
||||||
|
|
||||||
|
This is not a proper output; see `outputs` for context.
|
||||||
|
*/
|
||||||
|
inherit devdoc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
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>
|
||||||
|
*/
|
||||||
|
tests = {
|
||||||
|
pkg-config = testers.hasPkgConfigModules {
|
||||||
|
package = finalAttrs.finalPackage;
|
||||||
};
|
};
|
||||||
meta = prevAttrs.meta // {
|
};
|
||||||
description = "The Nix package manager";
|
};
|
||||||
pkgConfigModules = dev.meta.pkgConfigModules;
|
|
||||||
};
|
meta = {
|
||||||
}
|
mainProgram = "nix";
|
||||||
)
|
description = "The Nix package manager";
|
||||||
|
pkgConfigModules = dev.meta.pkgConfigModules;
|
||||||
|
};
|
||||||
|
|
||||||
|
})
|
||||||
|
|
|
@ -1088,21 +1088,21 @@ struct CmdFlakeArchive : FlakeCommand, MixJSON, MixDryRun
|
||||||
nlohmann::json jsonObj2 = json ? json::object() : nlohmann::json(nullptr);
|
nlohmann::json jsonObj2 = json ? json::object() : nlohmann::json(nullptr);
|
||||||
for (auto & [inputName, input] : node.inputs) {
|
for (auto & [inputName, input] : node.inputs) {
|
||||||
if (auto inputNode = std::get_if<0>(&input)) {
|
if (auto inputNode = std::get_if<0>(&input)) {
|
||||||
if ((*inputNode)->lockedRef.input.isRelative())
|
std::optional<StorePath> storePath;
|
||||||
continue;
|
if (!(*inputNode)->lockedRef.input.isRelative()) {
|
||||||
auto storePath =
|
storePath =
|
||||||
dryRun
|
dryRun
|
||||||
? (*inputNode)->lockedRef.input.computeStorePath(*store)
|
? (*inputNode)->lockedRef.input.computeStorePath(*store)
|
||||||
: (*inputNode)->lockedRef.input.fetchToStore(store).first;
|
: (*inputNode)->lockedRef.input.fetchToStore(store).first;
|
||||||
|
sources.insert(*storePath);
|
||||||
|
}
|
||||||
if (json) {
|
if (json) {
|
||||||
auto & jsonObj3 = jsonObj2[inputName];
|
auto & jsonObj3 = jsonObj2[inputName];
|
||||||
jsonObj3["path"] = store->printStorePath(storePath);
|
if (storePath)
|
||||||
sources.insert(std::move(storePath));
|
jsonObj3["path"] = store->printStorePath(*storePath);
|
||||||
jsonObj3["inputs"] = traverse(**inputNode);
|
jsonObj3["inputs"] = traverse(**inputNode);
|
||||||
} else {
|
} else
|
||||||
sources.insert(std::move(storePath));
|
|
||||||
traverse(**inputNode);
|
traverse(**inputNode);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jsonObj2;
|
return jsonObj2;
|
||||||
|
|
|
@ -99,6 +99,16 @@ writeTrivialFlake() {
|
||||||
EOF
|
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() {
|
createGitRepo() {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
local extraArgs="${2-}"
|
local extraArgs="${2-}"
|
||||||
|
@ -107,7 +117,5 @@ createGitRepo() {
|
||||||
mkdir -p "$repo"
|
mkdir -p "$repo"
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # word splitting of extraArgs is intended
|
# shellcheck disable=SC2086 # word splitting of extraArgs is intended
|
||||||
git -C "$repo" init $extraArgs
|
initGitRepo "$repo" $extraArgs
|
||||||
git -C "$repo" config user.email "foobar@example.com"
|
|
||||||
git -C "$repo" config user.name "Foobar"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ EOF
|
||||||
|
|
||||||
[[ $(nix eval "$rootFlake?dir=sub1#y") = 6 ]]
|
[[ $(nix eval "$rootFlake?dir=sub1#y") = 6 ]]
|
||||||
|
|
||||||
git init "$rootFlake"
|
initGitRepo "$rootFlake"
|
||||||
git -C "$rootFlake" add flake.nix sub0/flake.nix sub1/flake.nix
|
git -C "$rootFlake" add flake.nix sub0/flake.nix sub1/flake.nix
|
||||||
|
|
||||||
[[ $(nix eval "$subflake1#y") = 6 ]]
|
[[ $(nix eval "$subflake1#y") = 6 ]]
|
||||||
|
@ -77,7 +77,17 @@ fi
|
||||||
(! grep narHash "$subflake2/flake.lock")
|
(! grep narHash "$subflake2/flake.lock")
|
||||||
|
|
||||||
# Test `nix flake archive` with relative path flakes.
|
# 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.
|
# Test circular relative path flakes. FIXME: doesn't work at the moment.
|
||||||
if false; then
|
if false; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue