unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: Fredrik Salomonsson <plattfot@posteo.net>
Cc: help-guix <help-guix@gnu.org>
Subject: Re: Question about scripts in guix-home
Date: Sun, 17 Oct 2021 13:33:48 +0300	[thread overview]
Message-ID: <8735p07xf7.fsf@gmail.com> (raw)
In-Reply-To: <87wnmc8vmk.fsf@posteo.net> (Fredrik Salomonsson's message of "Sat, 16 Oct 2021 22:14:59 +0000")

[-- Attachment #1: Type: text/plain, Size: 2887 bytes --]

Fredrik Salomonsson <plattfot@posteo.net> writes:

[…]

> This is what I tried. Note that I only tested this on my mic.sh script
> to see if it worked.
>
> #+begin_src scheme
>   (define-public (get-services host)
>     "Return services for HOST."
>     (let ((storage-script (program-file
>                            "storage.sh"
>                            #~(execl #$(local-file "files/waybar/modules-storage.sh") "storage.sh"))))
>       (list
>        (simple-service 'plt-waybar-config
>                        home-files-service-type
>                        `(
>                          ("config/waybar/config"
>                           ,(local-file (format #f "~a/files/waybar/~a.conf" %source-dir host)))
>                          ("config/waybar/style.css"
>                           ,(local-file (format #f "~a/files/waybar/~a-style.css" %source-dir host)))
>                          ("config/waybar/modules/mic.sh"
>                           ,(computed-file
>                             "mic-wrapper"
>                             #~(begin
>                                 (let ((script #$(local-file "files/waybar/modules-mic.sh")))
>                                   (with-output-to-file #$output
>                                     (lambda ()
>                                       (format #t "\
>   #!/bin/sh
>   exec -a \"$0\" ~a --shell=bash \"$@\"\n"
>                                               script)))
>                                   (chmod script #o555)) ;; <-- trying to chmod the script
>                                 (chmod #$output #o555))))
>                          ("config/waybar/modules/storage.sh"
>                           ,storage-script)
>                          )))))
> #+end_src

Well, if you don't want to put the content of
files/waybar/modules-mic.sh file inside a Scheme string, then you need
to read the file to a string, e.g.:
--8<---------------cut here---------------start------------->8---
(simple-service 'shellcheck-wrapper
                   home-files-service-type
                   (list `("local/bin/shellcheck"
                           ,(computed-file
                             "shellcheck-wrapper"
                             #~(begin
                                 (use-modules (ice-9 rdelim))
                                 (with-output-to-file #$output
                                   (lambda ()
                                     (display #$(with-input-from-file "/tmp/foo" read-string))))
                                 (chmod #$output #o555))))))
--8<---------------cut here---------------end--------------->8---

Note that it's just an example which you should change according to your
needs.  ;-)  Also, it creates not an executable but a symlink to an
executable in a store, which I missed in a previous answer.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2021-10-17 10:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16  3:43 Question about scripts in guix-home Fredrik Salomonsson
2021-10-16 10:22 ` Edouard Klein
2021-10-16 20:30   ` Fredrik Salomonsson
2021-10-16 12:40 ` Oleg Pykhalov
2021-10-16 22:14   ` Fredrik Salomonsson
2021-10-17 10:33     ` Oleg Pykhalov [this message]
2021-10-17 18:45       ` Fredrik Salomonsson
2021-10-21  9:58         ` Oleg Pykhalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735p07xf7.fsf@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=plattfot@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).