lib/json-c: Work around the 0.19 memory leak
Update docs / update (push) Successful in 1m28s
CI / Check, build and cache nixfiles (push) Failing after 1m31s

In json-c 0.19, json_object_put calls the function that frees detached
JSON objects inside assert(). Release builds with NDEBUG skip that
call. Sway's frequent IPC replies then leak memory, eventually making
workspace switches lag.

Patching json-c in the main package set changes the library's store
path and forces dependent packages, including Firefox and Chromium,
to rebuild. Keep the pin with SPDK 26.09 and build the ABI-compatible
fix separately. Rewrite runtime references in NixOS systems and
standalone Home Manager generations to reuse their existing binaries.

Drop the replacement when the pinned nixpkgs includes the fix.

https://github.com/NixOS/nixpkgs/pull/586077
This commit is contained in:
jackos1998 committed 2026-11-23 17:09:05 +00:00
1 parent a75d94f492
commit af32a8dd4b
3 files changed
+36 -1

No files matched your search

+17 -1
View File
@@ -2,10 +2,12 @@
let
inherit (builtins) listToAttrs mapAttrs readFile;
inherit (lib)
optionalString nameValuePair concatMapStrings concatStringsSep optionalAttrs
optionalString nameValuePair concatMapStrings concatStringsSep
mapAttrsToList mkMerge mkIf mkDefault mkOption;
inherit (lib.hm) dag;
inherit (lib.my) mkOpt' dummyOption;
jsonCRuntimeReplacements = import ../../lib/json-c-runtime.nix { inherit lib pkgs pkgsFlake; };
in
{
# Disabled: breaks `nix flake check` in CI (see flake.nix pi-agent note).
@@ -29,6 +31,20 @@ in
};
};
};
home.activationPackage = mkOption {
apply = drv:
if config.my.isStandalone && jsonCRuntimeReplacements != [ ] then
(pkgs.replaceDependencies.override {
replaceDirectDependencies = pkgs.replaceDirectDependencies.override {
nix = config.nix.package;
};
}) {
inherit drv;
replacements = jsonCRuntimeReplacements;
}
else drv;
};
};
config = mkMerge [