help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Makefile to run guix shell?


From: zimoun
Subject: Re: Using Makefile to run guix shell?
Date: Thu, 08 Dec 2022 19:47:14 +0100

Hi,

On Thu, 08 Dec 2022 at 09:21, Peter Polidoro <peter@polidoro.io> wrote:

>                realistically I never want to go back to life 
> before Guix. Spending too much effort making it work without Guix 
> just encourages other people to use bad practices I am starting to 
> think.

Well, it depends on your collaborators, if you have. :-)

For instance, maybe your collaborators are using other tools than Guix
and they do not want to give a try for whatever reason.  Sometime, this
folder guix/ is not in the Git repository since some colleagues do not
want to be “polluted” by some extra files unrelated to the direct
project.


> I do not know enough about writing Makefiles, but is there a way 
> to chain together the rules and targets so you could either use 
> Guix or not, like a "make serial-shell" and a "make 
> guix-serial-shell" with the latter prepending "guix 
> time-machine..." to the serial-shell command?

You mean compose the rule, right?  Well, without being a Makefile guru,
I think you can have some recursion.

--8<---------------cut here---------------start------------->8---
$ cat Makefile
ifndef GUIX_ENVIRONMENT
    todo:=echo
else
    todo:=hello
endif

stuff:
        @echo "Enter stuff"
        @echo "GUIX_ENVIRONMENT: ${GUIX_ENVIRONMENT}"
        $(todo)
        @echo "stuff done."

hello:
        guix shell -C hello make -- $(MAKE) stuff

.PHONY: stuff hello


$ make stuff
Enter stuff
GUIX_ENVIRONMENT: 
echo

stuff done.

$ make hello
guix shell -C hello make -- make stuff
Enter stuff
GUIX_ENVIRONMENT: /gnu/store/qh9mcsp50kc21h505qvzj9asrkdk0bl1-profile
hello
Hello, world!
stuff done.
--8<---------------cut here---------------end--------------->8---

Note that the Makefile calls the Makefile but since it is run inside a
shell --container, then you need to provide ’make’.


Cheers,
simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]