lib: replace deprecated overrideDerivation with overrideAttrs

overrideDerivation has been deprecated since 2019. The new
overrideAttrs properly handles the env attribute set used by
modern derivations to avoid the NIX_CFLAGS_COMPILE overlap
error between env and top-level derivation arguments.
This commit is contained in:
2026-04-03 15:18:22 -04:00
parent 47aeb58f7a
commit 37ac88fc0f

View File

@@ -10,20 +10,16 @@ inputs.nixpkgs.lib.extend (
lib = prev; lib = prev;
in in
{ {
# stolen from: https://stackoverflow.com/a/42398526
optimizeWithFlags = optimizeWithFlags =
pkg: flags: pkg: flags:
lib.overrideDerivation pkg ( pkg.overrideAttrs (old: {
old: env = (old.env or { }) // {
let NIX_CFLAGS_COMPILE =
newflags = lib.foldl' (acc: x: "${acc} ${x}") "" flags; (old.env.NIX_CFLAGS_COMPILE or old.NIX_CFLAGS_COMPILE or "")
oldflags = if (lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else ""; + " "
in + (lib.concatStringsSep " " flags);
{ };
NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}"; });
# stdenv = pkgs.clang19Stdenv;
}
);
optimizePackage = optimizePackage =
pkg: pkg: