Hi!

I am writing a module in Guile, and I would like to have an optional dependency
on another library.  And I am not sure how to express it.  So far I found that
#:autoload can be used for it.

I have tried two approaches:

      #:autoload (guix derivations) (build-derivations
                                     derivation?
                                     derivation->output-path)
      #:autoload (guix gexp) (lower-object)
      #:autoload (guix store) (run-with-store store-protocol-error? with-store)

This works, but when I try to compile my library in environment without Guix, I
get a lot of warnings in the build log:

    ;;; Failed to autoload with-store in (guix store):
    ;;; no code for module (guix store)
    ;;; Failed to autoload run-with-store in (guix store):
    ;;; no code for module (guix store)
    ...

The build does succeed, but the spam in the logs is annoying.  The other
approach I discovered is using module-autoload!:

    (module-autoload!
     (current-module)
     '(guix derivations) '(build-derivations derivation? 
derivation->output-path)
     '(guix gexp)        '(lower-object)
     '(guix store)       '(run-with-store store-protocol-error? with-store))

This *also* works, but *also* leads to (different) warnings:

    wolfsden/guix/utils.scm:62:14: warning: possibly unbound variable 
`with-store'
    wolfsden/guix/utils.scm:62:25: warning: possibly unbound variable `%store'
    wolfsden/guix/utils.scm:63:16: warning: possibly unbound variable 
`run-with-store'
    wolfsden/guix/utils.scm:64:18: warning: possibly unbound variable 
`lower-object'
    wolfsden/guix/utils.scm:66:14: warning: possibly unbound variable 
`store-protocol-error?'
    wolfsden/guix/utils.scm:70:9: warning: possibly unbound variable 
`build-derivations'
    wolfsden/guix/utils.scm:71:20: warning: possibly unbound variable 
`derivation?'
    wolfsden/guix/utils.scm:72:20: warning: possibly unbound variable 
`derivation->output-path'

Is there a way to have a module as an optional dependency without any warnings?
For example, is there a way to convince the Guile that those specific variables
will be bound?  How do people commonly approach this?

Thanks,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Attachment: signature.asc
Description: PGP signature

  • How to have an optional... Tomas Volf

Reply via email to