From 5c8bac0971dd2895c0989b3b8c3392e812b54e39 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 18 Jul 2026 20:43:59 -0400 Subject: [PATCH] expat: make version easily overridable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, doing e.g. ``` expat.overrideAttrs (old: { version = "2.8.1"; src = old.src.overrideAttrs { hash = ""; }; }) ``` would not work since `tag` was created outside `mkDerivation` using `version`, not `finalAttrs.version`. Most sensible perhaps would be to move it inside (e.g. `mkDerivation (finalAttrs: let tag = … in …`), however then `nix fmt` wants to indent everything. So instead keep it outside but make it a fn that takes the version, and always use `finalAttrs.version`. --- pkgs/by-name/ex/expat/package.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/ex/expat/package.nix b/pkgs/by-name/ex/expat/package.nix index 72459e1c2ac6..2e831ef025da 100644 --- a/pkgs/by-name/ex/expat/package.nix +++ b/pkgs/by-name/ex/expat/package.nix @@ -18,17 +18,17 @@ # files. let - version = "2.8.2"; - tag = "R_${lib.replaceStrings [ "." ] [ "_" ] version}"; + tagFor = version: "R_${lib.replaceStrings [ "." ] [ "_" ] version}"; in + stdenv.mkDerivation (finalAttrs: { pname = "expat"; - inherit version; + version = "2.8.2"; src = fetchurl { url = with finalAttrs; - "https://github.com/libexpat/libexpat/releases/download/${tag}/${pname}-${version}.tar.xz"; + "https://github.com/libexpat/libexpat/releases/download/${tagFor version}/${pname}-${version}.tar.xz"; hash = "sha256-OtibhYjmZEvU5JmBSA1IshKJ7rvNTwoaSvscKfmbarQ="; }; @@ -73,7 +73,7 @@ stdenv.mkDerivation (finalAttrs: { }; meta = { - changelog = "https://github.com/libexpat/libexpat/blob/${tag}/expat/Changes"; + changelog = "https://github.com/libexpat/libexpat/blob/${tagFor finalAttrs.version}/expat/Changes"; homepage = "https://libexpat.github.io/"; description = "Stream-oriented XML parser library written in C"; mainProgram = "xmlwf";