From 31bdc68f8c7c899a10b9118149919f10868be06b Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Wed, 18 Jun 2025 17:07:16 +0000 Subject: [PATCH] (zilch magic): add post-build hook ..This is really starting to look like a build scheduler, huh? Change-Id: I6a6a696433e0a13f8de759061d47e737d48f4342 --- core/src/magic.sld | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/magic.sld b/core/src/magic.sld index 7c2b4b7..53d8b37 100644 --- a/core/src/magic.sld +++ b/core/src/magic.sld @@ -25,6 +25,7 @@ store-path-devirtualise store-path-register-fallback + store-path-register-post-build ca-thread-count drv-resolve-ca @@ -464,6 +465,11 @@ (mutex-lock! pending-count-mutex) (unless (eq? pending-count 'error) (set! pending-count (- pending-count 1))) + + ; Notify the derivation that it is built. + (let* ((meta (derivation-meta ca-drv)) + (post-build (and meta (assoc 'post-build meta)))) + (when post-build ((cdr post-build) (pending-item-resolved-paths item)))) (mutex-unlock! pending-count-mutex) (mutex-lock! pending-mutex) (set-pending-item-awaiting-count! item 'built) @@ -593,6 +599,11 @@ (set-derivation-meta! (store-path-drv path) (cons (cons 'fallback wrap-fallback) (or (derivation-meta (store-path-drv path)) '()))) path) + ; Note: this post-build hook is called with a mutex taken. + (define (store-path-register-post-build path callback) + (set-derivation-meta! (store-path-drv path) (cons (cons 'post-build callback) (or (derivation-meta (store-path-drv path)) '()))) + path) + (register-build-step '((zilch core magic) build) #t (lambda items (printf "received build info: ~S\n" items)