diff --git a/home-manager/modules/common.nix b/home-manager/modules/common.nix index adc275f..e2d1298 100644 --- a/home-manager/modules/common.nix +++ b/home-manager/modules/common.nix @@ -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 [ diff --git a/lib/json-c-runtime.nix b/lib/json-c-runtime.nix new file mode 100644 index 0000000..492e340 --- /dev/null +++ b/lib/json-c-runtime.nix @@ -0,0 +1,13 @@ +{ lib, pkgs, pkgsFlake }: + +# TODO: Drop this when updating the fork pin to a revision with the json-c fix. +# Patch the runtime library separately so existing consumers can be reused. +lib.optional ((pkgsFlake.rev or null) == "320600d55ff67365e933b98b339acdeac238eb26") { + oldDependency = pkgs.json_c; + newDependency = pkgs.json_c.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ (pkgs.fetchpatch { + url = "https://github.com/json-c/json-c/commit/f291fa81c6f21d925ea771a8cca597f5886309cc.patch"; + hash = "sha256-ZffSw1pfEfOH2ylRpJShdx7sTQR2nmPM/JIj/26UrDM="; + }) ]; + }); +} diff --git a/nixos/modules/common.nix b/nixos/modules/common.nix index 8f9f4ba..d397bb4 100644 --- a/nixos/modules/common.nix +++ b/nixos/modules/common.nix @@ -2,6 +2,8 @@ let inherit (lib) mkIf mkDefault mkMerge optionalAttrs versionOlder; inherit (lib.my) mkDefault'; + + jsonCRuntimeReplacements = import ../../lib/json-c-runtime.nix { inherit lib pkgs pkgsFlake; }; in { options = with lib.types; { @@ -18,6 +20,10 @@ in ]; config = mkMerge [ + (optionalAttrs (jsonCRuntimeReplacements != [ ]) { + system.replaceDependencies.replacements = jsonCRuntimeReplacements; + }) + { system = { stateVersion = "22.05";