help-guix
[Top][All Lists]
Advanced

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

Re: Guix Home, .local/bin executable scripts


From: Fabio Natali
Subject: Re: Guix Home, .local/bin executable scripts
Date: Sun, 25 Sep 2022 14:27:05 +0100

Hey Trev,

Thanks for your help!

On 2022-09-24, 15:49 -0700, Trev <trev@trevdev.ca> wrote:
> If the thing is being moved to your store for any reason you may want
> to explicitly update the permissions.  I had to do this when I
> packaged PHP composer for personal use.  Things tend to go into the
> store as read-only.

I see, yes, I followed your advice and ended up adding an explicit
`chmod' command.

> You can patch a shebang or anything else with substitute by doing the
> following from within a gexp where #$bash happens to be the bash
> package reference so long as it is in the right lexical scope. See
> (with-imported-modules) in the manual.
>
> (substitute* "scripts/hello.sh"
>   ("#!/bin/bash" (string-append #$bash "/bin/bash")))

This was a great starting point. Thanks to this and some fantastic
support on IRC, I was able to get to this working version:

,----
| (define my/home-hello-service
|   (service
|    home-files-service-type
|    `((".local/bin/hello.sh"
|       ,(computed-file
|         "hello.sh"
|         (with-imported-modules
|          '((guix build utils))
|          #~(begin
|              (use-modules (guix build utils))
|              (copy-file #$(local-file "scripts/hello.sh") #$output)
|              (substitute*
|               #$output (("/bin/bash") #$(file-append bash-minimal 
"/bin/bash")))
|              (chmod #$output #o555))))))))
`----

It was quite a learning curve, but I'm happy I got that working.

Thanks, best, Fabio.



reply via email to

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