mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-10 16:50:43 +02:00
services: Add etc-bashrc-d-service-type.
* gnu/services.scm (files->bashrc-d-directory) New procedure. (etc-bashrc-d-service-type): New service type. * doc/guix.texi (Service Reference): Document it. * gnu/tests/base.scm (test-basic-os): Test it. Change-Id: Ibbb0f684de7aee296adedbce5b1192786d661af2
This commit is contained in:
parent
42245040f6
commit
4c017ccfe5
3 changed files with 62 additions and 9 deletions
|
@ -47679,6 +47679,24 @@ usage may look like:
|
|||
@end example
|
||||
@end defvar
|
||||
|
||||
@defvar etc-bashrc-d-service-type
|
||||
The type of the @file{/etc/bashrc.d} service. This service is used to
|
||||
create files under @file{/etc/bashrc.d}. It takes as value a list of
|
||||
file-like objects, as can be produced with @code{local-file},
|
||||
@code{plain-file}, etc. Note that provided files whose file names do
|
||||
not end with @file{.sh} are @emph{not} added to @file{/etc/profile.d/}
|
||||
and are silently dropped. Package objects can also be provided directly
|
||||
to have their @file{etc/bashrc.d/*.sh} prefixed files added. An example
|
||||
usage may look like:
|
||||
|
||||
@example
|
||||
(use-package-modules gnome) ;for the `vte' package
|
||||
|
||||
(simple-service 'vte-integration etc-bashrc-d-service-type
|
||||
(list (file-append vte "/etc/profile.d/vte.sh")))
|
||||
@end example
|
||||
@end defvar
|
||||
|
||||
@defvar privileged-program-service-type
|
||||
Type for the ``privileged-program service''. This service collects lists of
|
||||
executable file names, passed as gexps, and adds them to the set of
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
extra-special-file
|
||||
etc-service-type
|
||||
etc-profile-d-service-type
|
||||
etc-bashrc-d-service-type
|
||||
etc-directory
|
||||
privileged-program-service-type
|
||||
setuid-program-service-type ; deprecated
|
||||
|
@ -988,6 +989,19 @@ two-elements list suitable for extending `etc-service-type'."
|
|||
scripts having the @file{.sh} file extension, to be sourced when users
|
||||
log in.")))
|
||||
|
||||
(define files->bashrc-d-directory
|
||||
(make-files->etc-directory "bashrc.d"))
|
||||
|
||||
(define etc-bashrc-d-service-type
|
||||
(service-type
|
||||
(inherit etc-profile-d-service-type)
|
||||
(name 'etc-bashrc-d)
|
||||
(extensions (list (service-extension etc-service-type
|
||||
files->bashrc-d-directory)))
|
||||
(description "A service for populating @file{/etc/bashrc.d/} with Bash
|
||||
scripts having the @file{.sh} file extension, to be sourced by interactive
|
||||
Bash shells.")))
|
||||
|
||||
(define (privileged-program->activation-gexp programs)
|
||||
"Return an activation gexp for privileged-program from PROGRAMS."
|
||||
(let ((programs
|
||||
|
|
|
@ -178,6 +178,19 @@ test -f /etc/profile.d/test_profile_d.sh
|
|||
test \"$PROFILE_D_OK\" = yes")
|
||||
marionette)))
|
||||
|
||||
(test-assert "/etc/bashrc.d is sourced"
|
||||
(zero? (marionette-eval
|
||||
'(system* "bash"
|
||||
;; Ensure Bash runs interactively.
|
||||
"--init-file"
|
||||
#$(plain-file "test_bashrc_d.sh"
|
||||
"\
|
||||
. /etc/bashrc
|
||||
set -e -x
|
||||
test -f /etc/bashrc.d/test_bashrc_d.sh
|
||||
test \"$BASHRC_D_OK\" = yes"))
|
||||
marionette)))
|
||||
|
||||
(test-equal "special files"
|
||||
'#$special-files
|
||||
(marionette-eval
|
||||
|
@ -585,7 +598,7 @@ functionality tests, using the given KERNEL.")
|
|||
(operating-system
|
||||
(inherit %simple-os)
|
||||
(kernel kernel)
|
||||
(services (cons (service
|
||||
(services (cons* (service
|
||||
etc-profile-d-service-type
|
||||
(list (plain-file
|
||||
"test_profile_d.sh"
|
||||
|
@ -593,6 +606,14 @@ functionality tests, using the given KERNEL.")
|
|||
(plain-file
|
||||
"invalid-name"
|
||||
"not a POSIX script -- ignore me")))
|
||||
(service
|
||||
etc-bashrc-d-service-type
|
||||
(list (plain-file
|
||||
"test_bashrc_d.sh"
|
||||
"export BASHRC_D_OK=yes\n")
|
||||
(plain-file
|
||||
"invalid-name"
|
||||
"not a Bash script -- ignore me")))
|
||||
%base-services)))
|
||||
#:imported-modules '((gnu services herd)
|
||||
(guix combinators))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue