@dlakelan @abcdw @charliemac it may be that you need to override the #:select keyword argument, like in this case: codeberg.org/fishinthecalculat

You should pass it a function like:

(use-modules (ice-9 match))

(define-public (staged-module-name? name)
"Return true if NAME (a list of symbols) denotes a Guix or staged module."
(match name
(('guix _ ...) )
(('gnu _ ...) )
(('staged _ ...) )
(_ )))

This is what I'm doing in gocix: codeberg.org/fishinthecalculat .

@dlakelan @abcdw @charliemac It's not documented as far as I know, I am also not sure why. Because of reasons I'm not aware of, with-imported-modules only allows importing from the #guix or gnu namespaces (so only modules starting with guix or gnu, such as (gnu build dbus) ) . The function I shared overrides this behavior allowing also to import from modules in the oci namespace, so modules such as (oci build oci-containers) .

If you have the staged code under a (staged ... ...) namespace you can allow it to be imported by passing the function I shared in the #:select argument

@paulbutgold
Wait, what? Are you sure about that?

Andrew was helping me debug this stuff last night and he certainly seemed to be getting gexp to run with locally defined functions. I'll try some stuff out and give the results later today. This might be a very important point and I will file a bug with the results if it works like you say. Either this is a software bug or a documentation bug if it works like that.
@abcdw @charliemac

@dlakelan @abcdw @charliemac I am sure as it took a lot of time and frustration to get it working in #gocix . but I was slightly incorrect in my statement, it is not with-imported-modules which has the #:select argument, it is source-module-clousure which has it. this would have been evident by reading the links I provided before or looking at guix' source code: https://codeberg.org/guix/guix/src/branch/master/guix/modules.scm#L165 and https://codeberg.org/guix/guix/src/branch/master/guix/modules.scm#L116 . maybe you can send a patch to the manual fixing this?
@paulbutgold
Yes I did read it yesterday, but didn't have it in my head and am on my phone. Hard to check.

The closure function... I see. So I'm guessing there you have to put in all your own modules, and the point of the closure is to suck up all the modules from the system that are additionally required. If your own project has a lot of hierarchical dependencies I agree it could be frustrating to figure them out manually. Weird that closure works like that.
@abcdw @charliemac