From 6057bf64a6786975ee7dc55f10d95615f9358a66 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Thu, 29 Jan 2026 19:43:28 -0800 Subject: [PATCH] mqtt-exporter: use patch rather than `substituteInPlace` The problem with this `substituteInPlace` is that it happily continues doing something once we're on a version of `mqtt-exporter` that has this bug fixed (which happened upstream in ). Here's how it fails: ```console $ mqtt-exporter Traceback (most recent call last): File "/nix/store/apglhyifvx73d4ybmrcyic2fdp7dxq38-mqtt-exporter-1.9.0/bin/.mqtt-exporter-wrapped", line 6, in from mqtt_exporter.main import main_mqtt_exporter_mqtt_exporter ImportError: cannot import name 'main_mqtt_exporter_mqtt_exporter' from 'mqtt_exporter.main' (/nix/store/apglhyifvx73d4ybmrcyic2fdp7dxq38-mqtt-exporter-1.9.0/lib/python3.13/site-packages/mqtt_exporter/main.py) ``` The patch will do the correct thing and start to fail once it has already been applied. --- pkgs/by-name/mq/mqtt-exporter/package.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/mq/mqtt-exporter/package.nix b/pkgs/by-name/mq/mqtt-exporter/package.nix index 8ae7fe04a6aa..60fde8c7b47a 100644 --- a/pkgs/by-name/mq/mqtt-exporter/package.nix +++ b/pkgs/by-name/mq/mqtt-exporter/package.nix @@ -1,6 +1,7 @@ { lib, fetchFromGitHub, + fetchpatch, python3, }: @@ -16,11 +17,13 @@ python3.pkgs.buildPythonApplication rec { hash = "sha256-z2y43sRlwgy3Bwhu8rvlTkf6HOT+v8kjo5FT3lo5CEA="; }; - postPatch = '' - # https://github.com/kpetremann/mqtt-exporter/pull/117 - substituteInPlace pyproject.toml \ - --replace-fail "mqtt_exporter.main:main" "mqtt_exporter.main:main_mqtt_exporter" - ''; + patches = [ + (fetchpatch { + name = "Fix `mqtt-exporter` script"; + url = "https://github.com/kpetremann/mqtt-exporter/commit/53f5f31b28cb5aeec1c8d0bb7d1aea56f036082e.diff"; + hash = "sha256-LS+kO6bHofNQxk9o+ExsJnaecwfY/40S0MIJwpJxCAI="; + }) + ]; build-system = with python3.pkgs; [ setuptools ];