* Using Makefile to run guix shell? @ 2022-12-07 14:47 Peter Polidoro 2022-12-07 15:12 ` ( 2022-12-07 17:08 ` Wolf 0 siblings, 2 replies; 19+ messages in thread From: Peter Polidoro @ 2022-12-07 14:47 UTC (permalink / raw) To: help-guix In the root of every project directory, I now include a channels.scm file and a manifest.scm file. I was using direnv to automatically launch guix shell, but I wanted more flexibility to easily launch variations of guix shell. Now I am also including a Makefile in the root of every project directory so I can use "make guix-shell" or "make guix-container" or "make project-documentation" etc to quickly run commands. This works well for certain types of projects, but there could be conflicts with projects that expect or automatically generate their own Makefiles. I could use a different Makefile name for my guix commands, but that makes my commands less convenient to type. Is it considered bad practice to use make like this? Is there a better way to do something similar? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 14:47 Using Makefile to run guix shell? Peter Polidoro @ 2022-12-07 15:12 ` ( 2022-12-07 15:26 ` Peter Polidoro 2022-12-07 17:08 ` Wolf 1 sibling, 1 reply; 19+ messages in thread From: ( @ 2022-12-07 15:12 UTC (permalink / raw) To: Peter Polidoro, help-guix [-- Attachment #1: Type: text/plain, Size: 527 bytes --] Heya, On Wed Dec 7, 2022 at 2:47 PM GMT, Peter Polidoro wrote: > Is it considered bad practice to use make like this? Is there a > better way to do something similar? All you need to do is have a ``guix.scm'' or ``manifest.scm'' in your project directory, then add it to the ``guix shell'' authorised directories: echo $PROJECT_DIR >> ~/.config/guix/shell-authorized-directories And then all you need to do is run ``guix shell'', and it will automatically pick up that manifest or package file. -- ( [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 659 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 15:12 ` ( @ 2022-12-07 15:26 ` Peter Polidoro 2022-12-07 15:38 ` ( 2022-12-09 18:38 ` Philip McGrath 0 siblings, 2 replies; 19+ messages in thread From: Peter Polidoro @ 2022-12-07 15:26 UTC (permalink / raw) To: (; +Cc: help-guix > And then all you need to do is run ``guix shell'', and it will > automatically > pick up that manifest or package file. That works well for just the "guix shell" command, but what if I want shortcuts to a whole set of commands? For example, I might want a command to automatically generate project metadata from an org file running "make metadata": metadata: $(GUIX-CONTAINER) -- sh -c "emacs --batch -Q -l .init.el --eval '(process-org \".metadata.org\")'" This seems to work well, but I just wondered if putting a Makefile into every project root may cause conflicts for some build systems. Is there something better to use than make for such command shortcuts? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 15:26 ` Peter Polidoro @ 2022-12-07 15:38 ` ( 2022-12-07 18:27 ` Peter Polidoro 2022-12-09 18:38 ` Philip McGrath 1 sibling, 1 reply; 19+ messages in thread From: ( @ 2022-12-07 15:38 UTC (permalink / raw) To: Peter Polidoro; +Cc: help-guix [-- Attachment #1: Type: text/plain, Size: 316 bytes --] Heya, On Wed Dec 7, 2022 at 3:26 PM GMT, Peter Polidoro wrote: > metadata: > $(GUIX-CONTAINER) -- sh -c "emacs --batch -Q -l .init.el --eval > '(process-org \".metadata.org\")'" Why not just do: guix shell -- make metadata ? That way, people without Guix installed can use it, too. -- ( [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 659 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 15:38 ` ( @ 2022-12-07 18:27 ` Peter Polidoro 2022-12-07 21:01 ` Wojtek Kosior via 2022-12-08 10:44 ` zimoun 0 siblings, 2 replies; 19+ messages in thread From: Peter Polidoro @ 2022-12-07 18:27 UTC (permalink / raw) To: (; +Cc: help-guix > Why not just do: > > guix shell -- make metadata I do like the idea of not making it depend on guix. One of the things I am trying to avoid, though, is typing long guix commands. When I type "make guix-shell", what I really want is something like: guix-shell: guix time-machine -C channels.scm -- shell --pure --check -m manifest.scm Or if I am doing embedded work I might want type "make serial-shell" to do something like: serial-shell: guix time-machine -C channels.scm -- shell -m manifest.scm --container --expose=$(PORT) picocom -- picocom -b 9600 -f n -y n -d 8 -p 1 -c $(PORT) I guess I am just curious how other people manage such long commands? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 18:27 ` Peter Polidoro @ 2022-12-07 21:01 ` Wojtek Kosior via 2022-12-08 10:44 ` zimoun 1 sibling, 0 replies; 19+ messages in thread From: Wojtek Kosior via @ 2022-12-07 21:01 UTC (permalink / raw) To: Peter Polidoro; +Cc: (, help-guix [-- Attachment #1: Type: text/plain, Size: 1536 bytes --] > > Why not just do: > > > > guix shell -- make metadata > > I do like the idea of not making it depend on guix. > > One of the things I am trying to avoid, though, is typing long > guix commands. > > When I type "make guix-shell", what I really want is something > like: > > guix-shell: > guix time-machine -C channels.scm -- shell --pure --check -m > manifest.scm > > Or if I am doing embedded work I might want type "make > serial-shell" to do something like: > > serial-shell: > guix time-machine -C channels.scm -- shell -m manifest.scm > --container --expose=$(PORT) picocom -- picocom -b 9600 -f n -y > n -d 8 -p 1 -c $(PORT) > > I guess I am just curious how other people manage such long > commands? > I recently came up with the same solution as you[1][2] :) I haven't considered hard requirement on Guix a major issue. But I did for a moment think about another solution to the same problem. I believe it'd be possible to use a mere shell script instead of a Makefile. Or a mere guile script or Python script (setup.py on steroids?) :) Wojtek [1] https://git.koszko.org/pydrilla/ [2] https://git.koszko.org/koszko-org-server/ -- (sig_start) website: https://koszko.org/koszko.html PGP: https://koszko.org/key.gpg fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A Meet Kraków saints! #21: saint Kazimierz Poznaj świętych krakowskich! #21: święty Kazimierz https://pl.wikipedia.org/wiki/Święty_Kazimierz -- (sig_end) [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 18:27 ` Peter Polidoro 2022-12-07 21:01 ` Wojtek Kosior via @ 2022-12-08 10:44 ` zimoun 2022-12-08 14:21 ` Peter Polidoro 1 sibling, 1 reply; 19+ messages in thread From: zimoun @ 2022-12-08 10:44 UTC (permalink / raw) To: Peter Polidoro, (; +Cc: help-guix Hi, On Wed, 07 Dec 2022 at 13:27, Peter Polidoro <peter@polidoro.io> wrote: >> Why not just do: >> >> guix shell -- make metadata > > I do like the idea of not making it depend on guix. [...] > I guess I am just curious how other people manage such long > commands? Quoting [1], I have a “general” script (named guixify) under ~/.local/bin/ which roughly reads: --8<---------------cut here---------------start------------->8--- #!/bin/sh guix time-machine -C channels.scm \ -- shell --pure \ -m manifest.scm \ -- $@ --8<---------------cut here---------------end--------------->8--- where manifest.scm and channels.scm are kept with the Git project. I prefer to pin a specific Guix revision to avoid bad surprises. :-) Well, in a project, I just run: guixify make # run make using the Guix environment guixify # enter in the environment Well and if I need a more complex command-line invocation specific to the project, I have Shell scripts with the Git project; for instance guix-serial-shell.sh --8<---------------cut here---------------start------------->8--- #!/bin/sh guix time-machine -C guix/channels.scm \ -- shell -m guix/manifest.scm \ --container --expose=$(PORT) picocom \ -- $@ --8<---------------cut here---------------end--------------->8--- where I try to decouple what requires Guix and what not. Well, I have not tried, but the idea is then to run: $ guix-serial-shell.sh make serial-shell where the Makefile contains the rule: serial-shell: picocom -b 9600 -f n -y n -d 8 -p 1 -c $(PORT) (well, adapting for PORT :-)) Other said, in general, I have a Git repository which looks like . ├── COPYING ├── guix │ ├── channels.scm │ ├── extra │ │ └── packages.scm │ ├── manifest.scm │ ├── other-script.sh │ └── serial-shell.sh ├── Makefile ├── README ├── src │ └── code └── tests └── stuff And the guixify scripts from above contains guix/manifest.scm and guix/channels.scm instead. :-) Well, I try to keep Makefile working without Guix. And usually, the folder guix/extra contains some packages that I use via --load-path, for instance, guix-serial-shell.sh would have: guix time-machine -C channels.scm \ -- shell -m manifest.scm \ --load-path guix/extra \ --container --expose=$(PORT) picocom \ -- $@ 1: https://yhetil.org/guix/86wn9puqj7.fsf@gmail.com HTH simon ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 10:44 ` zimoun @ 2022-12-08 14:21 ` Peter Polidoro 2022-12-08 15:30 ` Wojtek Kosior via 2022-12-08 18:47 ` zimoun 0 siblings, 2 replies; 19+ messages in thread From: Peter Polidoro @ 2022-12-08 14:21 UTC (permalink / raw) To: zimoun; +Cc: (, help-guix zimoun <zimon.toutoune@gmail.com> writes: > where I try to decouple what requires Guix and what not. Well, > I have > not tried, but the idea is then to run: > > $ guix-serial-shell.sh make serial-shell > > where the Makefile contains the rule: > > serial-shell: > picocom -b 9600 -f n -y n -d 8 -p 1 -c $(PORT) I really like your approach and your directory layout, thank you. So you are not concerned about Makefile conflicts or using Make in ways that may not have been intended? Maybe I should just learn to stop worrying and love the Makefile. It does seem to add lots of complication in order to decouple Guix from the Makefile, though, with all the extra shell scripts and commands. In general I like the idea of software units being decoupled, but 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. 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? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 14:21 ` Peter Polidoro @ 2022-12-08 15:30 ` Wojtek Kosior via 2022-12-08 18:47 ` zimoun 1 sibling, 0 replies; 19+ messages in thread From: Wojtek Kosior via @ 2022-12-08 15:30 UTC (permalink / raw) To: Peter Polidoro; +Cc: zimoun, (, help-guix [-- Attachment #1: Type: text/plain, Size: 2896 bytes --] > 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? How about sth like #+begin_src makefile something: @ echo "Doing something" guix-something: guix shell coreutils -- $(MAKE) something .PHONY: something guix-something #+end_src Assuming you did put the above under /tmp you can try it out like this #+begin_example /tmp$ make something Doing something /tmp$ make guix-something guix shell coreutils -- make something make[1]: Entering directory '/tmp' Doing something make[1]: Leaving directory '/tmp' #+end_example This is great for phony targets (i.e. ones that are not intended to produce a file with the same name as the target). You're also not forbidden from making `guix-` variants for non-phony targets the same way. Although then the `guix-` variant will end up being phony anyway ¯\_(ツ)_/¯ W -- (sig_start) website: https://koszko.org/koszko.html PGP: https://koszko.org/key.gpg fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A Meet Kraków saints! #37: blessed Michał Tomaszek Poznaj świętych krakowskich! #37: błogosławiony Michał Tomaszek https://pl.wikipedia.org/wiki/Michał_Tomaszek -- (sig_end) On Thu, 08 Dec 2022 09:21:42 -0500 Peter Polidoro <peter@polidoro.io> wrote: > zimoun <zimon.toutoune@gmail.com> writes: > > > where I try to decouple what requires Guix and what not. Well, > > I have > > not tried, but the idea is then to run: > > > > $ guix-serial-shell.sh make serial-shell > > > > where the Makefile contains the rule: > > > > serial-shell: > > picocom -b 9600 -f n -y n -d 8 -p 1 -c $(PORT) > > I really like your approach and your directory layout, thank you. > > So you are not concerned about Makefile conflicts or using Make in > ways that may not have been intended? Maybe I should just learn to > stop worrying and love the Makefile. > > It does seem to add lots of complication in order to decouple Guix > from the Makefile, though, with all the extra shell scripts and > commands. In general I like the idea of software units being > decoupled, but 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. > > 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? > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 14:21 ` Peter Polidoro 2022-12-08 15:30 ` Wojtek Kosior via @ 2022-12-08 18:47 ` zimoun 2022-12-08 21:30 ` Wojtek Kosior via 1 sibling, 1 reply; 19+ messages in thread From: zimoun @ 2022-12-08 18:47 UTC (permalink / raw) To: Peter Polidoro; +Cc: (, help-guix 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 18:47 ` zimoun @ 2022-12-08 21:30 ` Wojtek Kosior via 2022-12-08 23:04 ` zimoun 0 siblings, 1 reply; 19+ messages in thread From: Wojtek Kosior via @ 2022-12-08 21:30 UTC (permalink / raw) To: zimoun; +Cc: Peter Polidoro, (, help-guix [-- Attachment #1: Type: text/plain, Size: 682 bytes --] > 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 > > [...] > > Note that the Makefile calls the Makefile but since it is run inside a > shell --container, then you need to provide ’make’. > > > Cheers, > simon > What is the purpose of using `$(MAKE)` over just `make` in the recipe in this case? It would only be appropriate if you wanted the same make to be used for both the manual and recursive invocation, right? [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 21:30 ` Wojtek Kosior via @ 2022-12-08 23:04 ` zimoun 2022-12-08 23:24 ` Wojtek Kosior via 2022-12-09 17:46 ` Peter Polidoro 0 siblings, 2 replies; 19+ messages in thread From: zimoun @ 2022-12-08 23:04 UTC (permalink / raw) To: Wojtek Kosior; +Cc: Peter Polidoro, (, help-guix Hi, On Thu, 08 Dec 2022 at 22:30, Wojtek Kosior via <help-guix@gnu.org> wrote: >> hello: >> guix shell -C hello make -- $(MAKE) stuff [...] > What is the purpose of using `$(MAKE)` over just `make` in the recipe > in this case? It would only be appropriate if you wanted the same make > to be used for both the manual and recursive invocation, right? No specific reason. Initially I wrote without the container option ’-C’ or --pure, so really recursive. But then I checked if it also worked with the container option ’-C’ and let the old $(MAKE) invocation. In case reader is not convinced, here $(MAKE) does not refer to the same ’make’: --8<---------------cut here---------------start------------->8--- $ cat Makefile stuff: which make guixy: @guix shell -C which make -- $(MAKE) stuff $ which make /usr/bin/make $ make stuff which make /usr/bin/make $ make guixy which make /gnu/store/dp8bar2xgzwz1yfm9lcafqn3vhs2cjqc-profile/bin/make --8<---------------cut here---------------end--------------->8--- Cheers, simon ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 23:04 ` zimoun @ 2022-12-08 23:24 ` Wojtek Kosior via 2022-12-09 17:46 ` Peter Polidoro 1 sibling, 0 replies; 19+ messages in thread From: Wojtek Kosior via @ 2022-12-08 23:24 UTC (permalink / raw) To: zimoun; +Cc: Peter Polidoro, (, help-guix [-- Attachment #1: Type: text/plain, Size: 459 bytes --] > In case reader is not convinced, here $(MAKE) does not refer to the same > ’make’: Of course it doesn't. The reason I pointed out this detail is because if someone makes the first invocation differently, e.g. with /usr/bin/make hello or, in case of the example Makefile from your last email, with /usr/bin/make guixy I expect the command to fail with missing `/usr/bin/make` (which is indeed not present in the container) [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-08 23:04 ` zimoun 2022-12-08 23:24 ` Wojtek Kosior via @ 2022-12-09 17:46 ` Peter Polidoro 2022-12-10 13:21 ` zimoun 1 sibling, 1 reply; 19+ messages in thread From: Peter Polidoro @ 2022-12-09 17:46 UTC (permalink / raw) To: zimoun; +Cc: Wojtek Kosior, (, help-guix zimoun <zimon.toutoune@gmail.com> writes: > $ cat Makefile > stuff: > which make > > guixy: > @guix shell -C which make -- $(MAKE) stuff > > $ which make > /usr/bin/make > > $ make stuff > which make > /usr/bin/make > > $ make guixy > which make > /gnu/store/dp8bar2xgzwz1yfm9lcafqn3vhs2cjqc-profile/bin/make > > Cheers, > simon I just watched the excellent 10 Years of Guix talk "Guix REPL—to infinity and beyond". I am not sure if you are the same Simon, but it made me wonder if using guix extension could a nice way to solve these sorts of problems. Could I have a set of guix extensions local to each project so that I can run commands like: guix serial-shell PORT=/dev/ttyUSB0 Which would really run something like: guix time-machine -C .channels.scm -- shell --container --expose=$(PORT) -- make PORT=$(PORT) serial-shell Where some Makefile defines serial-shell: serial-shell picocom -b 9600 -f n -y n -d 8 -p 1 -c $(PORT) Maybe the path of the Makefile would need to be specified in the extension somewhere. That way non-guix users can just run the Makefile and guix users only need to use the guix command. Or maybe the extension could call a shell script if that is better for non-guix users than running a Makefile. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-09 17:46 ` Peter Polidoro @ 2022-12-10 13:21 ` zimoun 2022-12-12 17:55 ` Peter Polidoro 0 siblings, 1 reply; 19+ messages in thread From: zimoun @ 2022-12-10 13:21 UTC (permalink / raw) To: Peter Polidoro; +Cc: Wojtek Kosior, (, help-guix Hi, On Fri, 09 Dec 2022 at 12:46, Peter Polidoro <peter@polidoro.io> wrote: > I am not sure if you are the same Simon Yes, I am. :-) Have we met? > but it made me wonder if > using guix extension could a nice way to solve these sorts of > problems. Well, I do not know, I mean it is not clear for me what I would like as an interface. > Could I have a set of guix extensions local to each project so > that I can run commands like: > > guix serial-shell PORT=/dev/ttyUSB0 > > Which would really run something like: > > guix time-machine -C .channels.scm -- shell --container > --expose=$(PORT) -- make PORT=$(PORT) serial-shell From my understanding, there is 2 levels: + how do you call the Guix specific? + how do you implement this Guix specific? Because calling “guix serial-shell PORT=/dev/ttyUSB0” or “guix-serial-shell PORT=/dev/ttyUSB0” is almost identical. :-) So the true question is how to implement? If using Shell script containing something like, guix time-machine -C .channels.scm -- shell --container --expose=$(PORT) -- make PORT=$(PORT) serial-shell Well, the extension is just for fun; it would contain something like: (invoke "guix" "time-machine" …) So the extension is replacing the dash by one space. :-) Now, if instead of the command-line (guix time-machine …), you would like to use the Scheme API, yeah you can do it using an extension. From my point of view, in this case, maybe an extension is a heavy solution when a quick script would just smooth the workflow. Somehow, for the difference, give a look at patch#58339 [1], + [PATH 1/2] uses “(apply system* …)” instead of “invoke” but that’s the same idea, + [PATH 2/2] uses the Scheme API, sure trivially. :-) 1: <http://issues.guix.gnu.org/msgid/20221006163609.2280960-1-zimon.toutoune@gmail.com> HTH. Cheers, simon ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-10 13:21 ` zimoun @ 2022-12-12 17:55 ` Peter Polidoro 2022-12-12 19:00 ` Wojtek Kosior via 0 siblings, 1 reply; 19+ messages in thread From: Peter Polidoro @ 2022-12-12 17:55 UTC (permalink / raw) To: zimoun; +Cc: Wojtek Kosior, (, help-guix zimoun <zimon.toutoune@gmail.com> writes: > Because calling “guix serial-shell PORT=/dev/ttyUSB0” or > “guix-serial-shell PORT=/dev/ttyUSB0” is almost identical. :-) Yes good point. > > So the true question is how to implement? If using Shell script Using shell scripts would mean one script per command? I usually have a set of commands that I would like to be able to run for every project. I would like to minimize the number of extra files in my project directory, so I would lean towards your Scheme API option. > From my point of view, in this case, maybe an extension is a > heavy > solution when a quick script would just smooth the workflow. Maybe it is too heavy a solution, but I do like the idea of just needing the channels.scm, the guix.scm, and maybe a Makefile for people who do not use guix. Or am I wrong and I would need more files than that? I also like that a user could find information about the project commands using guix help. Can command extensions be grouped into a single sub-command so I would not feel like I am polluting the guix command namespace? Like could I run something like "guix project serial-shell PORT=/dev/ttyUSB0" or "guix project help" to get the set of project-specific commands that I added as extensions? Is there some sort of extension bootstrap process where you run an intial command in the project directory every session to add the extensions, then the extensions are available for future commands? ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-12 17:55 ` Peter Polidoro @ 2022-12-12 19:00 ` Wojtek Kosior via 0 siblings, 0 replies; 19+ messages in thread From: Wojtek Kosior via @ 2022-12-12 19:00 UTC (permalink / raw) To: Peter Polidoro; +Cc: zimoun, (, help-guix [-- Attachment #1: Type: text/plain, Size: 3151 bytes --] > > So the true question is how to implement? If using Shell script > > Using shell scripts would mean one script per command? I usually > have a set of commands that I would like to be able to run for > every project. I would like to minimize the number of extra files > in my project directory, so I would lean towards your Scheme API > option. There's nothing that stops a shell script from exposing multiple commands. Consider for example the SysV init scripts. They typically utilize the `case` statement to support commands like "start", "stop", "status", etc. So you could craft a solution where from the root of your project you can run `./my-script.sh command1`, `./my-script.sh command2`, etc. Also, you mentioned you "would like to minimize the number of extra files" in your "project directory". Does that mean you don't actually mind creating more files in a *subdirectory* thereof? If you don't, how about putting command scripts under, say, `my-scripts/` and running them as `my-scripts/command1.sh`, `my-scripts/command2.sh`, etc.? Wojtek -- (sig_start) website: https://koszko.org/koszko.html PGP: https://koszko.org/key.gpg fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A Meet Kraków saints! #25: blessed Maksymilian Binkiewicz Poznaj świętych krakowskich! #25: błogosławiony Maksymilian Binkiewicz https://pl.wikipedia.org/wiki/Maksymilian_Binkiewicz -- (sig_end) On Mon, 12 Dec 2022 12:55:39 -0500 Peter Polidoro <peter@polidoro.io> wrote: > zimoun <zimon.toutoune@gmail.com> writes: > > > Because calling “guix serial-shell PORT=/dev/ttyUSB0” or > > “guix-serial-shell PORT=/dev/ttyUSB0” is almost identical. :-) > > Yes good point. > > > > > So the true question is how to implement? If using Shell script > > Using shell scripts would mean one script per command? I usually > have a set of commands that I would like to be able to run for > every project. I would like to minimize the number of extra files > in my project directory, so I would lean towards your Scheme API > option. > > > From my point of view, in this case, maybe an extension is a > > heavy > > solution when a quick script would just smooth the workflow. > > Maybe it is too heavy a solution, but I do like the idea of just > needing the channels.scm, the guix.scm, and maybe a Makefile for > people who do not use guix. Or am I wrong and I would need more > files than that? > > I also like that a user could find information about the project > commands using guix help. Can command extensions be grouped into a > single sub-command so I would not feel like I am polluting the > guix command namespace? Like could I run something like "guix > project serial-shell PORT=/dev/ttyUSB0" or "guix project help" to > get the set of project-specific commands that I added as > extensions? > > Is there some sort of extension bootstrap process where you run an > intial command in the project directory every session to add the > extensions, then the extensions are available for future commands? [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 15:26 ` Peter Polidoro 2022-12-07 15:38 ` ( @ 2022-12-09 18:38 ` Philip McGrath 1 sibling, 0 replies; 19+ messages in thread From: Philip McGrath @ 2022-12-09 18:38 UTC (permalink / raw) To: Felix Lechner via On Wed, Dec 7, 2022, at 10:26 AM, Peter Polidoro wrote: >> And then all you need to do is run ``guix shell'', and it will >> automatically >> pick up that manifest or package file. > > That works well for just the "guix shell" command, but what if I > want shortcuts to a whole set of commands? > > For example, I might want a command to automatically generate > project metadata from an org file running "make metadata": > > metadata: > $(GUIX-CONTAINER) -- sh -c "emacs --batch -Q -l .init.el --eval > '(process-org \".metadata.org\")'" > > This seems to work well, but I just wondered if putting a Makefile > into every project root may cause conflicts for some build > systems. > > Is there something better to use than make for such command > shortcuts? The ability to to this sort of thing is one of the interesting aspects of Nix Flakes. See in particular the “apps” output attributes and the `nix run` command: https://nixos.wiki/wiki/Flakes ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Using Makefile to run guix shell? 2022-12-07 14:47 Using Makefile to run guix shell? Peter Polidoro 2022-12-07 15:12 ` ( @ 2022-12-07 17:08 ` Wolf 1 sibling, 0 replies; 19+ messages in thread From: Wolf @ 2022-12-07 17:08 UTC (permalink / raw) To: Peter Polidoro; +Cc: help-guix [-- Attachment #1: Type: text/plain, Size: 770 bytes --] On 2022-12-07 09:47:16 -0500, Peter Polidoro wrote: > I could use a different Makefile name for my guix commands, but that makes > my commands less convenient to type. I guess you could do something like alias ,make=make\ -f\ Makefile.mine and then invoke it as ,make guix-shell That will rid you of the risk of collision (especially if you pick something more unique then Makefile.mine) while keeping it easy to write. But the alternative suggestion in this thread to do guix shell -- make metadata seems like a better approach, since it does not make guix a required component to build your project. W. -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2022-12-12 19:01 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-12-07 14:47 Using Makefile to run guix shell? Peter Polidoro 2022-12-07 15:12 ` ( 2022-12-07 15:26 ` Peter Polidoro 2022-12-07 15:38 ` ( 2022-12-07 18:27 ` Peter Polidoro 2022-12-07 21:01 ` Wojtek Kosior via 2022-12-08 10:44 ` zimoun 2022-12-08 14:21 ` Peter Polidoro 2022-12-08 15:30 ` Wojtek Kosior via 2022-12-08 18:47 ` zimoun 2022-12-08 21:30 ` Wojtek Kosior via 2022-12-08 23:04 ` zimoun 2022-12-08 23:24 ` Wojtek Kosior via 2022-12-09 17:46 ` Peter Polidoro 2022-12-10 13:21 ` zimoun 2022-12-12 17:55 ` Peter Polidoro 2022-12-12 19:00 ` Wojtek Kosior via 2022-12-09 18:38 ` Philip McGrath 2022-12-07 17:08 ` Wolf
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).