From patchwork Mon May 19 00:29:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 42737 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9905C27BC4A; Mon, 19 May 2025 01:30:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4B06727BC49 for ; Mon, 19 May 2025 01:30:41 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uGoOS-0003Lq-2W; Sun, 18 May 2025 20:30:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uGoOP-0003KS-He for guix-patches@gnu.org; Sun, 18 May 2025 20:30:09 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uGoOO-00013i-E8; Sun, 18 May 2025 20:30:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=jKm/JoMD9BTK8p0SJlD/aTlE5AJQXIw2PtkqDrcoc5s=; b=JrjADe4hjrhT+ZoYFb57JbS/mdoJ0NeYE4i7q7vZ3VrWTpIaoQUsr7rteokrC/FL7OU1iHSz+Y9x/u73JHSdYOtpYycimUUYXth6bF87dqWUaWWaV+cqazXUAx8jmCsjzvTys0tT5gTwF0NI7DsaLt8ZJ5UWWUxRtjJl4Fb6xLgkeXHPaRoz4ElN352Bm8E0umRkR4Pk2VApwIL5AepSV8P0LzuzKe7HDsMgO1blXjynxA2Mnn1hOhk/hJWzsRdfYxNdtn6cnfdibEniMQbBR80afV/IxzimEYUm+kiOBDrL3+xja/A7MOwwttswOy2bAL4DUD04QbcWyIyXp4TTyQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uGoON-0006pv-3B; Sun, 18 May 2025 20:30:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78308] [PATCH v3 05/10] services: Add etc-bashrc-d-service-type. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, rutherther@ditigal.xyz, lgcoelho@disroot.org, gabriel@erlikon.ch, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Mon, 19 May 2025 00:30:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78308 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78308@debbugs.gnu.org Cc: Maxim Cournoyer , Maxim Cournoyer , Rutherther , Luis Guilherme Coelho , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= X-Debbugs-Original-Xcc: Maxim Cournoyer , Rutherther , Luis Guilherme Coelho , Gabriel Wicki , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 78308-submit@debbugs.gnu.org id=B78308.174761460225881 (code B ref 78308); Mon, 19 May 2025 00:30:07 +0000 Received: (at 78308) by debbugs.gnu.org; 19 May 2025 00:30:02 +0000 Received: from localhost ([127.0.0.1]:34031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGoOE-0006ig-HS for submit@debbugs.gnu.org; Sun, 18 May 2025 20:30:02 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:45471) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uGoO5-0006hE-9Z for 78308@debbugs.gnu.org; Sun, 18 May 2025 20:29:53 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7426c44e014so3872942b3a.3 for <78308@debbugs.gnu.org>; Sun, 18 May 2025 17:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747614582; x=1748219382; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jKm/JoMD9BTK8p0SJlD/aTlE5AJQXIw2PtkqDrcoc5s=; b=LELt4I/oa2uBWBd583Pklaiz9iIBvEuvt8fenpsuqEFon7MNbS/rq1VXwRJtyWD8t7 j87lyoxm7Jwaq/x8BaiYoZIAa3T9qg8yN2R+MijFN4WsDzJ4h4Vp66H94M6afzC8rp+K vFvhG5E9X69scsjfoKMEbUj8KlkANLI7rdUgso7kqH9SiBICWNoyyfo4Y81lw2wOVjrP T/dO6AQrwULGDzUn7g1bYt2rvKdoyyrGshaO/mwBrHVBZmtoOcL2QlP+3vZbN181i//4 p98Ei3qZu3ExjoJK2Bxa6azvJGymG9Xgl7RG+5MHlvQZLNVhQp5PItwyf9Qt9ourTqDh n03g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747614582; x=1748219382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jKm/JoMD9BTK8p0SJlD/aTlE5AJQXIw2PtkqDrcoc5s=; b=we7pN5lXuAh3bVCRBjHew0q7cnxmWRXmCXspZDfOsqYeNdwcThOUtXBo+Cp6/0KKff Xb85hAUDTV8JA4DizdxxxkExqqGdh5PYUyLGrr+Mc/qqQGLSBp2wZ3Gpl8OP0S8HylIx sY/g+3hZc3y6W4kh390Eimt4+mzP5cv58xzU9zvk99/sUVos7qFZSLTDpbEXGTHYQDRP JZgn3Z9rujMbrfbBiIkj0pU30L1vsVZl4AHmnSZTTkdCy/45jvk34kIlz46CrcqUBVs+ 1Q8DWhyj9ImI8eRIseXqRG3wReNlBtafkPMMaR/JhzYdqjl1eqqaQxkry7Y7pYqgI7gH EXuQ== X-Gm-Message-State: AOJu0YxI1mnWc5IkB+KfR33DrykZvAyT5Qg/Eb72p6T6z8Z77qGsYmHX mnqs9LW3ahlFZHtBwvhWUY69BGs8xVo0R9Ypsn+tMbIqkD7JCNFjNTiTWyxN/Q== X-Gm-Gg: ASbGncsByvU/gIVU121xC4VYJU/CiNFogYP3sONQBmxrChspVegEeyKn2U8T++dsG6M e/qURBbLTr4z6lujjhdaR1Xa1LxuPMo02pVQLegbiuVFtRHM857AiZo8z2iJ601H1+XypBvLkA7 w9CmNcJ/VBvdLD++ZX35ZW1Z0Ni9C392b//F4wT7D0K/A3P2RbkEyEpmYfP0VZKyZxXTD/1/8S/ a2hAmkMvaCXvMiW39X7gQ6vRr2EZBImgkpc88EE9AgsPdV6Vgej5GBVAq0IceqsrWiey/JuPvVj Kq6ce3BgH8lh5/+UTFzMw+hGVEDR2sidDBbvHovQZdi/Fq/CbEf2WHVITGuXSN1pfnG7dmgOwMx hLUBzaw== X-Google-Smtp-Source: AGHT+IHMW4S0ifgMiyPM0xJyR3BEJeK7rJDDWXOtozH/DpNXWu87/TYld3dPfQ7s26uZfwmtc1xzog== X-Received: by 2002:aa7:888e:0:b0:742:39fa:13df with SMTP id d2e1a72fcca58-742a98a2520mr15236378b3a.19.1747614582382; Sun, 18 May 2025 17:29:42 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a970c882sm5254027b3a.55.2025.05.18.17.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 May 2025 17:29:41 -0700 (PDT) From: Maxim Cournoyer Date: Mon, 19 May 2025 09:29:03 +0900 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 --- doc/guix.texi | 18 ++++++++++++++++++ gnu/services.scm | 14 ++++++++++++++ gnu/tests/base.scm | 39 ++++++++++++++++++++++++++++++--------- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index b236a358a1f..927e9243bfb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -47645,6 +47645,24 @@ Service Reference @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 + +(service 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 diff --git a/gnu/services.scm b/gnu/services.scm index 8584b16ac5c..7083c88c130 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -123,6 +123,7 @@ (define-module (gnu services) 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 @@ (define etc-profile-d-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 diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 09fc91383df..0f31c152e0f 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm @@ -178,6 +178,19 @@ (define* (run-basic-test os command #:optional (name "basic") 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,15 +598,23 @@ (define* (test-basic-os #:optional (kernel linux-libre)) (operating-system (inherit %simple-os) (kernel kernel) - (services (cons (service - etc-profile-d-service-type - (list (plain-file - "test_profile_d.sh" - "export PROFILE_D_OK=yes\n") - (plain-file - "invalid-name" - "not a POSIX script -- ignore me"))) - %base-services))) + (services (cons* (service + etc-profile-d-service-type + (list (plain-file + "test_profile_d.sh" + "export PROFILE_D_OK=yes\n") + (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)))) (vm (virtual-machine os)))