diff options
| author | Jérôme Benoit <[email protected]> | 2026-01-12 19:49:06 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-12 12:49:06 -0600 |
| commit | ca1b597b010bdf624fd839de479533cf5e4010df (patch) | |
| tree | 84464a8c1d93a532a5d67bb986f9b1d8f2204c14 /flake.nix | |
| parent | d527ceeb2be7c00b29f051163762e46ea6d70537 (diff) | |
| download | opencode-ca1b597b010bdf624fd839de479533cf5e4010df.tar.gz opencode-ca1b597b010bdf624fd839de479533cf5e4010df.zip | |
fix(nix): filter optional dependencies by target platform (#8033)
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -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 { }; |
