From 32dc7f6f02e01cd844fd289d5f7b1b47ed769ea8 Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Wed, 29 Apr 2026 09:44:54 -0400 Subject: [PATCH] stdenv.mkDerivation: inline hardeningDisable' We can safely check `elem "all" hardeningDisable'` on the original list, because calling `unique` and `concretizeFlagImplications` will never change whether the list contains "all". --- pkgs/stdenv/generic/make-derivation.nix | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 7a17cb27737e..855615856299 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -413,21 +413,20 @@ let actualValue; outputs' = if separateDebugInfo' then outputs ++ [ "debug" ] else outputs; - hardeningDisable' = unique ( - pipe hardeningDisable [ - # disabling fortify implies fortify3 should also be disabled - (concretizeFlagImplications "fortify" [ "fortify3" ]) - # disabling strictflexarrays1 implies strictflexarrays3 should also be disabled - (concretizeFlagImplications "strictflexarrays1" [ "strictflexarrays3" ]) - # disabling libcxxhardeningfast implies libcxxhardeningextensive should also be disabled - (concretizeFlagImplications "libcxxhardeningfast" [ "libcxxhardeningextensive" ]) - ] - ); enabledHardeningOptions = - if elem "all" hardeningDisable' then + if elem "all" hardeningDisable then [ ] else - subtractLists hardeningDisable' (defaultHardeningFlags ++ hardeningEnable); + subtractLists (unique ( + pipe hardeningDisable [ + # disabling fortify implies fortify3 should also be disabled + (concretizeFlagImplications "fortify" [ "fortify3" ]) + # disabling strictflexarrays1 implies strictflexarrays3 should also be disabled + (concretizeFlagImplications "strictflexarrays1" [ "strictflexarrays3" ]) + # disabling libcxxhardeningfast implies libcxxhardeningextensive should also be disabled + (concretizeFlagImplications "libcxxhardeningfast" [ "libcxxhardeningextensive" ]) + ] + )) (defaultHardeningFlags ++ hardeningEnable); # hardeningDisable additionally supports "all". erroneousHardeningFlags = subtractLists knownHardeningFlags ( hardeningEnable ++ remove "all" hardeningDisable