[object Object]

← back to Exo

Extract mlx revision from uv lock (#1715)

f28b2fd037c29d0cad9806845ded961f9443392d · 2026-03-13 12:34:54 +0000 · ciaranbor

## Motivation

The MLX version and git revision in nix/mlx.nix were hardcoded and had
to be manually kept in sync with uv.lock

## Changes

- flake.nix: Extract MLX git rev from uv.lock's source.git URL and pass
as uvLockMlxRev
- nix/mlx.nix: Use uvLockMlxVersion and uvLockMlxRev instead of
hardcoded values; remove version mismatch assertion

## Why It Works

uv.lock is already the source of truth — now Nix reads both version and
rev from it directly. The pinned fetchFromGitHub hash still guards
against unexpected changes.

Files touched

Diff

commit f28b2fd037c29d0cad9806845ded961f9443392d
Author: ciaranbor <81697641+ciaranbor@users.noreply.github.com>
Date:   Fri Mar 13 12:34:54 2026 +0000

    Extract mlx revision from uv lock (#1715)
    
    ## Motivation
    
    The MLX version and git revision in nix/mlx.nix were hardcoded and had
    to be manually kept in sync with uv.lock
    
    ## Changes
    
    - flake.nix: Extract MLX git rev from uv.lock's source.git URL and pass
    as uvLockMlxRev
    - nix/mlx.nix: Use uvLockMlxVersion and uvLockMlxRev instead of
    hardcoded values; remove version mismatch assertion
    
    ## Why It Works
    
    uv.lock is already the source of truth — now Nix reads both version and
    rev from it directly. The pinned fetchFromGitHub hash still guards
    against unexpected changes.
---
 flake.nix   | 3 ++-
 nix/mlx.nix | 7 +++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/flake.nix b/flake.nix
index 14d5a20e..ff5ec712 100644
--- a/flake.nix
+++ b/flake.nix
@@ -117,12 +117,13 @@
               uvLock = builtins.fromTOML (builtins.readFile ./uv.lock);
               mlxPackage = builtins.head (builtins.filter (p: p.name == "mlx" && p.source ? git) uvLock.package);
               uvLockMlxVersion = mlxPackage.version;
+              uvLockMlxRev = builtins.elemAt (builtins.split "#" mlxPackage.source.git) 2;
             in
             {
               metal-toolchain = pkgs.callPackage ./nix/metal-toolchain.nix { };
               mlx = pkgs.callPackage ./nix/mlx.nix {
                 inherit (self'.packages) metal-toolchain;
-                inherit uvLockMlxVersion;
+                inherit uvLockMlxVersion uvLockMlxRev;
               };
               default = self'.packages.exo;
             }
diff --git a/nix/mlx.nix b/nix/mlx.nix
index 6a3b565c..39b0ac9f 100644
--- a/nix/mlx.nix
+++ b/nix/mlx.nix
@@ -11,6 +11,7 @@
 , fmt
 , python313Packages
 , uvLockMlxVersion
+, uvLockMlxRev
 }:
 
 assert stdenv.isDarwin;
@@ -41,15 +42,13 @@ let
 
   mlx = stdenv.mkDerivation rec {
     pname = "mlx";
-    version = let v = "0.30.7.dev20260225+257d5692"; in
-      assert v == uvLockMlxVersion || throw "MLX version mismatch: nix/mlx.nix has ${v} but uv.lock has ${uvLockMlxVersion}. Update both the version and hash in nix/mlx.nix.";
-      v;
+    version = uvLockMlxVersion;
     pyproject = true;
 
     src = fetchFromGitHub {
       owner = "rltakashige";
       repo = "mlx-jaccl-fix-small-recv";
-      rev = "257d5692fc7af6bba3b8afaeb63c549b7d1e43d5";
+      rev = uvLockMlxRev;
       hash = "sha256-GosFIWxIB48Egb1MqJrR3xhsUsQeWdRk5rV93USY6wQ=";
     };
 

← ea18a625 fix: guard against ZeroDivisionError in mlx_lm stats (#1707)  ·  back to Exo  ·  fix: shield macmon cleanup from cancellation to prevent orph 12af7c95 →