From ca1b597b010bdf624fd839de479533cf5e4010df Mon Sep 17 00:00:00 2001 From: Jérôme Benoit Date: Mon, 12 Jan 2026 19:49:06 +0100 Subject: fix(nix): filter optional dependencies by target platform (#8033) --- flake.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index e53053217..4219a7e8e 100644 --- a/flake.nix +++ b/flake.nix @@ -27,11 +27,28 @@ "aarch64-darwin" = "bun-darwin-arm64"; "x86_64-darwin" = "bun-darwin-x64"; }; - defaultNodeModules = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + + # Parse "bun-{os}-{cpu}" to {os, cpu} + parseBunTarget = + target: + let + parts = lib.splitString "-" target; + in + { + os = builtins.elemAt parts 1; + cpu = builtins.elemAt parts 2; + }; + hashesFile = "${./nix}/hashes.json"; hashesData = if builtins.pathExists hashesFile then builtins.fromJSON (builtins.readFile hashesFile) else { }; - nodeModulesHash = hashesData.nodeModules or defaultNodeModules; + # Lookup hash: supports per-system ({system: hash}) or legacy single hash + nodeModulesHashFor = + system: + if builtins.isAttrs hashesData.nodeModules then + hashesData.nodeModules.${system} + else + hashesData.nodeModules; modelsDev = forEachSystem ( system: let @@ -63,8 +80,11 @@ system: let pkgs = pkgsFor system; + bunPlatform = parseBunTarget bunTarget.${system}; mkNodeModules = pkgs.callPackage ./nix/node-modules.nix { - hash = nodeModulesHash; + hash = nodeModulesHashFor system; + bunCpu = bunPlatform.cpu; + bunOs = bunPlatform.os; }; mkOpencode = pkgs.callPackage ./nix/opencode.nix { }; mkDesktop = pkgs.callPackage ./nix/desktop.nix { }; -- cgit v1.2.3