From 37ac88fc0fc9c2b1c666dc90f322356afd618e62 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 3 Apr 2026 15:18:22 -0400 Subject: [PATCH] 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. --- modules/lib.nix | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/lib.nix b/modules/lib.nix index 8f36a9d..7e3160c 100644 --- a/modules/lib.nix +++ b/modules/lib.nix @@ -10,20 +10,16 @@ inputs.nixpkgs.lib.extend ( lib = prev; in { - # stolen from: https://stackoverflow.com/a/42398526 optimizeWithFlags = pkg: flags: - lib.overrideDerivation pkg ( - old: - let - newflags = lib.foldl' (acc: x: "${acc} ${x}") "" flags; - oldflags = if (lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else ""; - in - { - NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}"; - # stdenv = pkgs.clang19Stdenv; - } - ); + pkg.overrideAttrs (old: { + env = (old.env or { }) // { + NIX_CFLAGS_COMPILE = + (old.env.NIX_CFLAGS_COMPILE or old.NIX_CFLAGS_COMPILE or "") + + " " + + (lib.concatStringsSep " " flags); + }; + }); optimizePackage = pkg: