1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

packaging/everything.nix: Use a multi-output derivation

This should fix a few packaging regressions.

`dev` also includes a merged `includes/`, which may be helpful until
inter-component includes are fixed properly.
This commit is contained in:
Robert Hensing 2025-02-28 17:40:32 +01:00
parent d8a7c50495
commit 41085295ab

View file

@ -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,19 +119,49 @@ let
}; };
in in
(buildEnv { stdenv.mkDerivation (finalAttrs: {
name = "nix-${nix-cli.version}"; pname = "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;
/**
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; 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 = checkInputs =
[ [
@ -144,10 +174,6 @@ in
# Make sure the functional tests have passed # Make sure the functional tests have passed
nix-functional-tests 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 ++ lib.optionals
(!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform) (!stdenv.hostPlatform.isStatic && stdenv.buildPlatform.canExecute stdenv.hostPlatform)
@ -156,7 +182,30 @@ in
# TODO: Split out tests into a separate derivation? # TODO: Split out tests into a separate derivation?
nix-perl-bindings 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; inherit (nix-cli) version;
/** /**
@ -178,33 +227,28 @@ in
*/ */
inherit libs; inherit libs;
tests = prevAttrs.passthru.tests or { } // { /**
# TODO: create a proper fixpoint and: Developer documentation for `nix`, in `share/doc/nix/{internal,external}-api/`.
# pkg-config =
# testers.hasPkgConfigModules { This is not a proper output; see `outputs` for context.
# package = finalPackage; */
# }; 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; tests = {
inherit devdoc; pkg-config = testers.hasPkgConfigModules {
doc = nix-manual; package = finalAttrs.finalPackage;
outputs = [
"out"
"dev"
"devdoc"
"doc"
];
all = lib.attrValues (
lib.genAttrs finalAttrs.passthru.outputs (outName: finalAttrs.finalPackage.${outName})
);
}; };
meta = prevAttrs.meta // { };
};
meta = {
mainProgram = "nix";
description = "The Nix package manager"; description = "The Nix package manager";
pkgConfigModules = dev.meta.pkgConfigModules; pkgConfigModules = dev.meta.pkgConfigModules;
}; };
}
) })