From d37f90a2b3ca3716e9297478e2a6827798ffd7cf Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 16 Nov 2024 22:58:09 +0100 Subject: [PATCH] stdenv.mkDerivation: support output checks with structuredAttrs Once __structuredAttrs are enabled, nix only supports disallowedReferences and friends inside the outputChecks attribute set, defined specifically for each output. Top-level disallowedReferences, as used throughout nixpkgs without structuredAttrs, throws a warning instead: warning: In a derivation named 'perl-5.40.0', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedReferences'; use 'outputChecks..disallowedReferences' instead To support a seamless migration to enabling structuredAttrs by default, those derivation attributes are now mapped to each output separately when structuredAttrs are enabled. Since both top-level disallowedReferences and outputChecks can be given at the same time, those are now merged together. One package that can be simplified this way is neovim, because all checks should be applied to all outputs anyway. --- pkgs/by-name/ne/neovim-unwrapped/package.nix | 13 +------------ pkgs/stdenv/generic/make-derivation.nix | 10 ++++++++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/pkgs/by-name/ne/neovim-unwrapped/package.nix b/pkgs/by-name/ne/neovim-unwrapped/package.nix index fb185d85f646..2507934eca13 100644 --- a/pkgs/by-name/ne/neovim-unwrapped/package.nix +++ b/pkgs/by-name/ne/neovim-unwrapped/package.nix @@ -193,18 +193,7 @@ stdenv.mkDerivation ( find "$out" -type f -exec remove-references-to -t ${stdenv.cc} '{}' + ''; # check that the above patching actually works - outputChecks = - let - disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua; - in - { - out = { - inherit disallowedRequisites; - }; - debug = { - inherit disallowedRequisites; - }; - }; + disallowedRequisites = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua; cmakeFlags = [ diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index fd3a51e06e42..b640474e3ab3 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -493,10 +493,16 @@ else let "/bin/sh" ]; __propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps; - }) // ( + }) // lib.optionalAttrs (!__structuredAttrs) ( makeOutputChecks attrs ) // lib.optionalAttrs (__structuredAttrs) { - outputChecks = builtins.mapAttrs (_: makeOutputChecks) attrs.outputChecks or {}; + outputChecks = builtins.listToAttrs (map (name: { + inherit name; + value = lib.zipAttrsWith (_: builtins.concatLists) [ + (makeOutputChecks attrs) + (makeOutputChecks attrs.outputChecks.${name} or {}) + ]; + }) outputs); }; in