zilch-cli-go: fixup

Change-Id: I6a6a6964284b0d7d37cb9f659cc2bf1e057c3ca9
This commit is contained in:
puck 2025-06-23 12:22:20 +00:00
parent 33cfccc4ae
commit 324aa9696b

View file

@ -9,12 +9,10 @@
(write-string (string-append msg "\n\n") (current-error-port)))
(write-string "Usage: zilch-cli-go [OPTION] [PACKAGE...]
Process the given module (or the current directory, if unspecified) and
output derivations for each package given on the command line (or all
executables in the module, if unspecified)
output the store path for each package given on the command line (or
all executables in the module, if unspecified)
-h, --help Print this help message.
-b, --build Build the store paths, rather than show their
derivations.
-j, --max-jobs COUNT The maximum amount of builds to run. Defaults
to the amount of cores.
-v, --verbose Increase the verbosity configured in the Nix
@ -34,7 +32,6 @@ executables in the module, if unspecified)
(define-values (options args)
(getopt
'((help #f #\h)
(build #f #\b)
(max-jobs #t #\j)
(verbose #f #\v)
(print-build-logs #f #\L)
@ -71,13 +68,12 @@ executables in the module, if unspecified)
(import
(scheme file) (chicken file) (chicken format)
(zilch magic)
(zilch magic) (zilch vfs)
(zilch lang go mod) (zilch lang go vfs) (zilch lang go)
(zilch nix drv)
(zilch lang go))
(define module-dir (if (assoc 'module-dir options) (cdr (assoc 'module-dir options)) (current-directory)))
(define do-build (assoc 'build options))
(define do-debug (assoc 'debug options))
(unless (file-exists? (string-append module-dir "/go.mod"))
@ -112,12 +108,7 @@ executables in the module, if unspecified)
(if (string=? (go-package-name package) "main")
(let ((linked (go-package-link package)))
(write-string (string-append package-name "\t"))
(store-path-materialize linked)
(if do-build
(begin
(store-path-build linked)
(write-string (store-path-realisation linked)))
(write-string (derivation-path (store-path-drv linked))))
(write-string (store-path-realised linked))
(newline))
(unless skip-if-not-bin
(write-string (string-append package-name "\tnot a binary\n")))))))