Mark H Weaver <m...@netris.org> skribis: > The second patch is the main subject of this email. It reworks the > shell script headers at the top of 'guix-package' and the other scripts > to avoid modifying environment variables (which could propagate to > unrelated subprocesses that use libguile), and to avoid prepending > installed directories to the guile load paths in the case where > 'pre-inst-env' is being used. > > My approach here might be controversial, given that the resulting code > is a bit longer, so if you don't like it, no worries :)
[...] > +script=guix-build > + > prefix="@prefix@" > datarootdir="@datarootdir@" > > -GUILE_LOAD_COMPILED_PATH="@guilemoduledir@:$GUILE_LOAD_COMPILED_PATH" > -export GUILE_LOAD_COMPILED_PATH > - > -main='(module-ref (resolve-interface '\''(guix-build)) '\'guix-build')' > -exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \ > - -c "(apply $main (cdr (command-line)))" "$@" > +startup=" > +(let () > + (define-syntax-rule (push! elt v) (set! v (cons elt v))) > + (define (main interpreter module-dir script-file . args) > + (unless (getenv \"GUIX_UNINSTALLED\") > + (push! module-dir %load-path) > + (push! module-dir %load-compiled-path)) > + (load script-file) > + (let ((proc (module-ref (resolve-interface '($script)) > + '$script))) > + (apply proc args))) > + (apply main (command-line))) > +" > +exec "${GUILE-@GUILE@}" -c "$startup" "@guilemoduledir@" "$0" "$@" Well, it’s a bit longer. :-) Honestly, I wouldn’t worry about the propagation of $GUILE_LOAD_PATH & co. to subprocesses, because we know there’s none anyway. What about a simple: if test "x$GUIX_UNINSTALLED" = x; then ... ? Ludo’.