[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about scripts in guix-home
From: |
Oleg Pykhalov |
Subject: |
Re: Question about scripts in guix-home |
Date: |
Sun, 17 Oct 2021 13:33:48 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
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.
signature.asc
Description: PGP signature