Subject: Re: [bug#30147] Simplify “scripts/guix”

From: Eric Bavier <[email-masked]>
Date: Mon, 22 Jan 2018 12:19:58 -0600

On Wed, 17 Jan 2018 20:25:14 +0100
Mathieu Lirzin <[email-masked]> wrote:

> This moves the complexity of Autotools variable expansion outside of the
> application code.
> 
> * scripts/guix.in (config-lookup): Delete.
> (maybe-augment-load-paths!, run-guix-main): Use fully expanded variables
> instead of calling ‘config-lookup’.
> * configure.ac: Don't use AC_CONFIG_FILES for ‘scripts/guix’.
> * Makefile.am (scripts/guix): New rule.
> (do_subst): New variable.
> (CLEANFILES, EXTRA_DIST): Adapt.

FWIW this is what my Joy compiler does for its entry script.  It works
well.

https://notabug.org/bavier/joy-in-the-morning.git

> +scripts/guix: scripts/guix.in Makefile
> +	$(AM_V_GEN)rm -f $@ $@-t \
> +	  && $(MKDIR_P) $(@D) \
> +	  && $(do_subst) <$(srcdir)/$@.in >$@-t \
> +	  && chmod a+x,a-w $@-t && mv -f $@-t $@

I think. since there's no state variables that needs to carry accross
commands, that this would read better without the line continuations and
appropriate use of $(AM_V_at).

While we're looking at it: I'm not certain, but I think Guix currently
work if one overrides the "prefix" variable when invoking 'make
install', which is a use-case suggested by the GNU Coding Standards
(Section 7.2.5).  I bring it up because adding '$(prefix)/bin/guix' to
the above rule might be a start.

> +;; Run Guix.
> +(let ((guix-main (module-ref (resolve-interface '(guix ui)) 'guix-main)))
> +  (bindtextdomain "guix" "@localedir@")
> +  (bindtextdomain "guix-packages" "@localedir@")
>    ;; XXX: It would be more convenient to change it to:
>    ;;   (exit (run-guix-main))
>    ;; but since the 'guix' command is not updated by 'guix pull', we cannot
>    ;; really do it now.
> -  (run-guix-main))
> +  (apply guix-main (command-line)))

If we're going to be patching scripts/guix.in, would now be the time to
add the '(exit ...)'?

Otherwise LGTM!

`~Eric