[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about scripts in guix-home
From: |
Fredrik Salomonsson |
Subject: |
Re: Question about scripts in guix-home |
Date: |
Sat, 16 Oct 2021 22:14:59 +0000 |
Hi,
Oleg Pykhalov <go.wigust@gmail.com> writes:
> I use the following, which creates ~/.local/bin/shellcheck executable file:
> --8<---------------cut here---------------start------------->8---
> (home-environment
> ;; ...
> (services
> (list
> (simple-service 'shellcheck-wrapper
> home-files-service-type
> (list `("local/bin/shellcheck"
> ,(computed-file
> "shellcheck-wrapper"
> #~(begin
> (with-output-to-file #$output
> (lambda ()
> (format #t "\
> #!/bin/sh
> exec -a \"$0\" ~a/bin/shellcheck --shell=bash \"$@\"\n"
> #$shellcheck)))
> (chmod #$output #o555)))))))))
> --8<---------------cut here---------------end--------------->8---
Thanks, still issue with the execution bit though…
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
Without the (chmod script #o555), it builds but when I try and run it I
get:
#+begin_src bash
$ ~/.config/waybar/modules/mic.sh
/home/plattfot/.config/waybar/modules/mic.sh: line 2:
/gnu/store/kbarnh2z2zaljwy6bwfhni2h3jjihzyj-modules-mic.sh: Permission denied
/home/plattfot/.config/waybar/modules/mic.sh: line 2: exec:
/gnu/store/kbarnh2z2zaljwy6bwfhni2h3jjihzyj-modules-mic.sh: cannot execute:
Permission denied
#+end_src
If I try and chmod the script, as shown in the example above, guix home
fails with:
#+begin_src bash
$ guix home reconfigure -L ~/.files ~/.files/plt/home/configs/surt.scm
1
substitute: updating substitutes from 'https://ci.guix.gnu.org'... 100.0%
substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'...
100.0%
The following derivations will be built:
/gnu/store/mn3ii78ri2bsi47rjc5qwnjc7hrd0znn-home.drv
/gnu/store/3fwk9l6xjgkac702figgn4ppfmlli5xh-files.drv
/gnu/store/jydir36k5b53n6wqnjzbkgkjz7wjw1g8-mic-wrapper.drv
building /gnu/store/jydir36k5b53n6wqnjzbkgkjz7wjw1g8-mic-wrapper.drv...
Backtrace:
2 (primitive-load "/gnu/store/w399i13mijh528x6ymlijh0k5fz?")
In ice-9/eval.scm:
619:8 1 (_ #f)
In unknown file:
0 (chmod "/gnu/store/kbarnh2z2zaljwy6bwfhni2h3jjihzyj-mo?" ?)
ERROR: In procedure chmod:
In procedure chmod: Operation not permitted
builder for `/gnu/store/jydir36k5b53n6wqnjzbkgkjz7wjw1g8-mic-wrapper.drv'
failed with exit code 1
build of /gnu/store/jydir36k5b53n6wqnjzbkgkjz7wjw1g8-mic-wrapper.drv failed
View build log at
'/var/log/guix/drvs/jy/dir36k5b53n6wqnjzbkgkjz7wjw1g8-mic-wrapper.drv.bz2'.
cannot build derivation
`/gnu/store/3fwk9l6xjgkac702figgn4ppfmlli5xh-files.drv': 1 dependencies
couldn't be built
cannot build derivation
`/gnu/store/mn3ii78ri2bsi47rjc5qwnjc7hrd0znn-home.drv': 1 dependencies couldn't
be built
guix home: error: build of
`/gnu/store/mn3ii78ri2bsi47rjc5qwnjc7hrd0znn-home.drv' failed
#+end_src
I ended up just package them up and that seems to be working
#+begin_src scheme
(define-module (plt home waybar)
#:use-module (gnu home services)
#:use-module (gnu packages bash)
#:use-module (gnu packages wm)
#:use-module (gnu services)
#:use-module (guix build-system copy)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (ice-9 format))
(define %source-dir (current-source-directory))
(define plt-waybar-custom-script
(package
(name "plt-waybar-custom-script")
(version "1.0.0")
(source (local-file (string-append %source-dir "/files/waybar")
#:recursive? #t
#:select? (lambda (file stat)
(string-suffix? ".sh" file))))
(build-system copy-build-system)
(arguments
`(#:install-plan
'(("modules-storage.sh" "bin/waybar-custom-storage")
("modules-mic.sh" "bin/waybar-custom-mic"))))
(native-inputs `())
(inputs `(("bash" ,bash))) ;; needs pactl
(propagated-inputs `())
(synopsis "Simple script to check the mic status")
(description
"Uses @code{pactl} to fetch the microphone status and return the status
in a
form @code{waybar} understands.")
(home-page "")
(license license:gpl3+)))
(define-public packages
(list
waybar
plt-waybar-custom-script
))
(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/storage.sh"
,storage-script)
)))))
#+end_src
--
s/Fred[re]+i[ck]+/Fredrik/g