Message ID | cover.1746682206.git.maxim.cournoyer@gmail.com |
---|---|
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 874A227BC4B; Thu, 8 May 2025 06:49:30 +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=-7.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_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 B731B27BC49 for <patchwork@mira.cbaines.net>; Thu, 8 May 2025 06:49:29 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1uCu80-0005bL-KE; Thu, 08 May 2025 01:49:04 -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 <Debian-debbugs@debbugs.gnu.org>) id 1uCu7z-0005b7-95 for guix-patches@gnu.org; Thu, 08 May 2025 01:49:03 -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 <Debian-debbugs@debbugs.gnu.org>) id 1uCu7z-000506-00 for guix-patches@gnu.org; Thu, 08 May 2025 01:49:03 -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:Date:From:To:Subject; bh=o8zMLNW917iqHFsrrdE0CPOwvuRCRJVVtF8t2BqXzPU=; b=IFfRl3rHK/FQhVYJH07AJ6V7FOYrsCj289fjRCob5TFA/jmNjI6qycYhZ+KRsnqXBnVgOt/8eZr+ndTahpPlqEuIZ76dHC24qFIcmWL4Eh1r56McII7oGV0c9AYOnY9PY2xFG1lqX1ZUxtVwLoxKBCL0L3xmio+baJ7lDEaKGpgDUrt8OKUljTxuBGgiuUq0n25Q9LYHYICcnDdCg37FRrOu+l8LtEkIEW8DK/y3O5B+8gWbCpPHgnfTl1ZTZglFqs1G10w9tEMmU79YY6GTRYJ6lWxl13fpwr7KomXtF+YDMv/cIHUfgtfbrZ7ciY6RwbTo6AJdPvPaAAUAWtNWHA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1uCu7y-0006B8-7Q; Thu, 08 May 2025 01:49:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78308] [PATCH 0/9] VTE integration support / Shell startup files refactor Resent-From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: liliana.prikler@gmail.com, maxim.cournoyer@gmail.com, noelopez@free.fr, vivien@planete-kraus.eu, guix-patches@gnu.org Resent-Date: Thu, 08 May 2025 05:49:01 +0000 Resent-Message-ID: <handler.78308.B.174668329723672@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78308 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78308@debbugs.gnu.org Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>, Liliana Marie Prikler <liliana.prikler@gmail.com>, Maxim Cournoyer <maxim.cournoyer@gmail.com>, =?utf-8?q?No=C3=A9?= Lopez <noelopez@free.fr>, Vivien Kraus <vivien@planete-kraus.eu> X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Liliana Marie Prikler <liliana.prikler@gmail.com>, Maxim Cournoyer <maxim.cournoyer@gmail.com>, =?utf-8?q?No=C3=A9?= Lopez <noelopez@free.fr>, Vivien Kraus <vivien@planete-kraus.eu> Received: via spool by submit@debbugs.gnu.org id=B.174668329723672 (code B ref -1); Thu, 08 May 2025 05:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 May 2025 05:48:17 +0000 Received: from localhost ([127.0.0.1]:52509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1uCu7E-00069k-TP for submit@debbugs.gnu.org; Thu, 08 May 2025 01:48:17 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56704) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <maxim.cournoyer@gmail.com>) id 1uCu7C-00069U-4s for submit@debbugs.gnu.org; Thu, 08 May 2025 01:48:14 -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 <maxim.cournoyer@gmail.com>) id 1uCu76-0005Z1-2x for guix-patches@gnu.org; Thu, 08 May 2025 01:48:08 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <maxim.cournoyer@gmail.com>) id 1uCu74-0004yU-Db for guix-patches@gnu.org; Thu, 08 May 2025 01:48:07 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-22e8e4423ecso5878625ad.0 for <guix-patches@gnu.org>; Wed, 07 May 2025 22:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746683283; x=1747288083; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=o8zMLNW917iqHFsrrdE0CPOwvuRCRJVVtF8t2BqXzPU=; b=PlnVSvRZJYGbhaC1DBVmgLVM1kusxEUvgd0qrIopgf6U/3wqDcHlpUEcsllpHnDj4a lBonazspwgi4lEnKR9YO7fY63IXZXJzJ20VfN/45ZJgOAe5EZIiTOL5mZXCoRfR7hB17 5gbm86CQnALyl9C4gyh4oeGTQXBy/8JUcma3cdfn5Pl1xgyUil5oB+IklF9RhhKtyCie jCdxZpm+0GHh8OQnHhcUB6ruLW56lizcRa7lSiV0FUJjhtFbsIHXsojAxQGGXvKB4l9o OxkhwwWfvN8HCcvSqH/JSvR5QdzoXid/jLf8HFDllaY3D4ArTmaXfFxCjgMlqmEUZA+t fIMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746683283; x=1747288083; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o8zMLNW917iqHFsrrdE0CPOwvuRCRJVVtF8t2BqXzPU=; b=HlY1aROxESxsJQ+XRnUydwa4ilAlye5Op6FdkljF768ANJhATNJwrGAI5aWVBG5Pau 2cxWh/hBiTmr8c8Oj7L7YWUR29v8FoCTQja/MVqmaPtKeNvMS3qGxub4QkiR5vvcN887 AGhmX2DCKIdQMgfB91+v4izmjcu9siB2MAUjO/wII+9BwYCoKfD3msqo8iNCyJTnfJ5D SlOnsGttmjHvteePwbxJcPq+WZQ+nxm5gReCxuRPLt0IPcFuJfj9Xo2EeAHt0RN8WGqG JG46mvnI/PAiDCgSFw2/oBFugY1pGFsOT2eAlbFAwlGEkN591DvpbjkKssH920F+6w8P JHCA== X-Gm-Message-State: AOJu0Yws/1tJZK3CupXHawYE4sWc5fS5pCAJX5gi70RX46KtxXdjSpeW 2DlKUWMCcYJCKwt+B4eJQbcxSvZXb2fbJbI6+hDgXtmiw5LQQBQlJNMnvA== X-Gm-Gg: ASbGnct2yoDHK/c/iKF1C69XC+SfML6LuiYD1UUZjcmObjDY2NfNtUlzObUWDoc/peB mUGXbQ8dgNgGK+fAzrS80w4oLCp6AQ/tERVkGE8BoTSo/2k68etrVF6vJAB9Td0HKY7stcLbWOR vu7CiLK9tGj3eLea/7sB2xkZTV3KadEMAaTJD85nyApKFI72dy09QDNasTcY62/PsdEUTwEcxc6 OB5BYk7ZQqArSOBJPzFTaPRm8F/Vph18IGfjxEOJJJ67cUw1cB/XSyJ7KHkEQsnaII35YNfMPWs TL678Jrn9IeIko8hUyT8D5KPBxnyFTOOMbUjfd35IR/oSSh1vDcpTffclZ+M X-Google-Smtp-Source: AGHT+IE25+pCHJfCPDaJeZnTAg5KlQsNewj3qVDYKOpp4L8xkcD2JYX9YfoOo9u4kEeLQXOqxZ8xMA== X-Received: by 2002:a17:903:3bcb:b0:220:ec62:7dc8 with SMTP id d9443c01a7336-22e85614060mr28878545ad.2.1746683283309; Wed, 07 May 2025 22:48:03 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-30ad4d2f15dsm1453426a91.18.2025.05.07.22.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 22:48:02 -0700 (PDT) From: Maxim Cournoyer <maxim.cournoyer@gmail.com> Date: Thu, 8 May 2025 14:47:54 +0900 Message-ID: <cover.1746682206.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=maxim.cournoyer@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=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 |
Series |
VTE integration support / Shell startup files refactor
|
|
Message
Maxim Cournoyer
May 8, 2025, 5:47 a.m. UTC
The aim of this series was ultimately to add VTE integration support out of the box, resolving <https://issues.guix.gnu.org/72172>. In order to do so, I introduce the new etc-profile-d-service-type and etc-bashrc-d-service-type service types. While at it, define SYS_BASHRC in our Bash package to treat /etc/bashrc as a first class startup file, and get rid of /etc/skel/.bashrc, whose functionality is moved to /etc/bashrc or /etc/bashrc.d/aliases.sh and /etc/bashrc.d/bash_completion.sh. To test, I've used: --8<---------------cut here---------------start------------->8--- make check-system TESTS='basic openssh dropbear' --8<---------------cut here---------------end--------------->8--- as well as live testing in a GNOME desktop VM to validate the VTE integration. Thank you, Maxim Cournoyer (9): system: Source scripts from the /etc/profile.d directory. services: Add etc-profile-d-service-type. gnu: bash: Define the SYS_BASHRC macro. system: Source scripts from the /etc/bashrc.d directory. services: Add etc-bashrc-d-service-type. system: Migrate sourcing bash_completion.sh to etc-bashrc-d-service-type. system: Factorize bashrc default configuration. services: Add vte-integration-service-type. services: Add vte-integration-service-type to %desktop-services. doc/guix.texi | 57 ++++++++++++++++- gnu/home/services/shells.scm | 14 ++--- gnu/packages/bash.scm | 20 ++++++ gnu/services.scm | 116 +++++++++++++++++++++++++++++++++++ gnu/services/base.scm | 5 +- gnu/services/desktop.scm | 4 ++ gnu/system.scm | 43 ++++++------- gnu/system/shadow.scm | 21 +++---- gnu/tests/base.scm | 45 +++++++++++++- 9 files changed, 278 insertions(+), 47 deletions(-) base-commit: 9d9a6291c4e61f3af71e94e549926bd9905e99db
Comments
Hi Maxim Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: > * etc/news.scm (channel-news): New entry. [...] > + (entry (commit "XXX") > + (title > + (en "New services for /etc/profile.d and /etc/bashrc.d")) > + (body > + (en "Two new Shepherd services, @code{etc-profile-d-service-type} and > +@code{etc-bashrc-d-service-type}, can now be used to configure and extend your > these are not Shepherd services, right? also, I wonder if `etc/profile` produced by `build-etc/profile` should also source files in corresponing `etc/profile.d`. This would allow packages install shell profile extensions and it would fix e.g. https://issues.guix.gnu.org/44997
Hi Sergey, Sergey Trofimov <sarg@sarg.org.ru> writes: > Hi Maxim > > Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: > >> * etc/news.scm (channel-news): New entry. > [...] >> + (entry (commit "XXX") >> + (title >> + (en "New services for /etc/profile.d and /etc/bashrc.d")) >> + (body >> + (en "Two new Shepherd services, @code{etc-profile-d-service-type} and >> +@code{etc-bashrc-d-service-type}, can now be used to configure and extend your >> > these are not Shepherd services, right? At the core, they are, but they are wrapped with some sugar in Guix, so perhaps I can say just 'services' or 'Guix services'. > also, I wonder if `etc/profile` produced by `build-etc/profile` should > also source files in corresponing `etc/profile.d`. This would allow > packages install shell profile extensions and it would fix e.g. > https://issues.guix.gnu.org/44997 That would be useful, but there's one issue I see, is that the Red Hat/Fedora have standardized on /etc/profile.d/ as the place to put any shell extension scripts, which are even sourced for example by /etc/bashrc, which is a bit odd to me: /etc/profile is for interactive login shells, and /etc/profile.d should logically follow, it seems. Having /etc/profile.d instead of /etc/bashrc.d also means that scripts placed there must be POSIX compliant or contain conditional guards for the specific Shell they target.
Hi Maxim, Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: >>> * etc/news.scm (channel-news): New entry. >> [...] >>> + (entry (commit "XXX") >>> + (title >>> + (en "New services for /etc/profile.d and /etc/bashrc.d")) >>> + (body >>> + (en "Two new Shepherd services, @code{etc-profile-d-service-type} and >>> +@code{etc-bashrc-d-service-type}, can now be used to configure and extend your >>> >> these are not Shepherd services, right? > > At the core, they are, but they are wrapped with some sugar in Guix, > Could you please explain this bit? As I see these are just computed files that produce `profile.d` and `bashrc.d` unions which are then sourced by a piece of code placed in a well-known file. When I read "shepherd", I expect that the service is managed with "herd". > > so perhaps I can say just 'services' or 'Guix services'. >> also, I wonder if `etc/profile` produced by `build-etc/profile` should >> also source files in corresponing `etc/profile.d`. This would allow >> packages install shell profile extensions and it would fix e.g. >> https://issues.guix.gnu.org/44997 > > That would be useful, but there's one issue I see, is that the Red > Hat/Fedora have standardized on /etc/profile.d/ as the place to put any > shell extension scripts, which are even sourced for example by > /etc/bashrc, which is a bit odd to me: /etc/profile is for interactive > login shells, and /etc/profile.d should logically follow, it seems. > > Having /etc/profile.d instead of /etc/bashrc.d also means that scripts > placed there must be POSIX compliant or contain conditional guards for > the specific Shell they target. It seems I've phrased it a bit vague. I was writing about `profile.d` directories in any guix profile (be it `guix home`, `guix shell` or whatever). What I propose is that `<...>/etc/profile` (produced by `build-etc/profile` procedure) would include the snippet to source `profile.d`. The snippet could find the dir relative to its own location so that the very same code could be placed as in the global file (/etc/profile) as in per-profile files.
Hi Sergey, Sergey Trofimov <sarg@sarg.org.ru> writes: > Hi Maxim, > > Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: > >>>> * etc/news.scm (channel-news): New entry. >>> [...] >>>> + (entry (commit "XXX") >>>> + (title >>>> + (en "New services for /etc/profile.d and /etc/bashrc.d")) >>>> + (body >>>> + (en "Two new Shepherd services, @code{etc-profile-d-service-type} and >>>> +@code{etc-bashrc-d-service-type}, can now be used to configure and extend your >>>> >>> these are not Shepherd services, right? >> >> At the core, they are, but they are wrapped with some sugar in Guix, >> > > Could you please explain this bit? As I see these are just computed > files that produce `profile.d` and `bashrc.d` unions which are then > sourced by a piece of code placed in a well-known file. When I read > "shepherd", I expect that the service is managed with "herd". Ah, you are right! Re-reading (info "(guix) Service Composition") made that clear to me. I always assumed services had to be sequenced by Shepherd no matter the type, but it seems it is Guix System that is in charge during the early boot here, when running the activation script, IIUC. >>> also, I wonder if `etc/profile` produced by `build-etc/profile` should >>> also source files in corresponing `etc/profile.d`. This would allow >>> packages install shell profile extensions and it would fix e.g. >>> https://issues.guix.gnu.org/44997 >> >> That would be useful, but there's one issue I see, is that the Red >> Hat/Fedora have standardized on /etc/profile.d/ as the place to put any >> shell extension scripts, which are even sourced for example by >> /etc/bashrc, which is a bit odd to me: /etc/profile is for interactive >> login shells, and /etc/profile.d should logically follow, it seems. >> >> Having /etc/profile.d instead of /etc/bashrc.d also means that scripts >> placed there must be POSIX compliant or contain conditional guards for >> the specific Shell they target. > > It seems I've phrased it a bit vague. I was writing about `profile.d` > directories in any guix profile (be it `guix home`, `guix shell` or > whatever). What I propose is that `<...>/etc/profile` (produced by > `build-etc/profile` procedure) would include the snippet to source > `profile.d`. The snippet could find the dir relative to its own location > so that the very same code could be placed as in the global file > (/etc/profile) as in per-profile files. Thank you for clarifying what you meant. So just rephrasing to make extra sure, what you would like to see is that every profile generated would have in their etc/profile generated file something sourcing its etc/profile.d/*.sh files, so that installing e.g. bash_completion in a profile would automatically have its etc/profile.d/bash_completion.sh file sourced, correct? I'm not sure how useful that would be, because IIRC the $profile/etc/profile of a generated profile is only ever sourced: 1. When it appears at /etc/profile, e.g. mapped there within a container 2. The shell is started as a login shell, e.g. 'bash --login' Note the --login requirement; which would not be in effect for example when entering a 'guix shell' (which spawns 'sh') by default. The etc/profile could be sourced manually, of course, but that seems to defeat the purpose of having it there in the first place. Another idea would be to have /etc/bashrc source /etc/profile.d like done in Fedora; that's a bit odd and I don't like it much for reasons explained earlier, but it has the benefit of being compatible with the packages like flatpak and vte that install things under etc/profile.d to extend the non-login shells as well. That could be made to work automatically for the fixed location like /run/current-system/profile/etc/profile.d for system-installed packages as well as $HOME/.profile/etc/profile.d/, and even for non-containerized environments via $GUIX_ENVIRONMENT/etc/profile.d/. It wouldn't work in containerized environment; this would need adding a /etc/bashrc inside the container that would source $GUIX_ENVIROMNENT/etc/profile.d.
Hi Maxim, Maxim Cournoyer <maxim.cournoyer@gmail.com> writes: [...] >>>> also, I wonder if `etc/profile` produced by `build-etc/profile` should >>>> also source files in corresponing `etc/profile.d`. This would allow >>>> packages install shell profile extensions and it would fix e.g. >>>> https://issues.guix.gnu.org/44997 >>> >>> That would be useful, but there's one issue I see, is that the Red >>> Hat/Fedora have standardized on /etc/profile.d/ as the place to put any >>> shell extension scripts, which are even sourced for example by >>> /etc/bashrc, which is a bit odd to me: /etc/profile is for interactive >>> login shells, and /etc/profile.d should logically follow, it seems. >>> >>> Having /etc/profile.d instead of /etc/bashrc.d also means that scripts >>> placed there must be POSIX compliant or contain conditional guards for >>> the specific Shell they target. >> >> It seems I've phrased it a bit vague. I was writing about `profile.d` >> directories in any guix profile (be it `guix home`, `guix shell` or >> whatever). What I propose is that `<...>/etc/profile` (produced by >> `build-etc/profile` procedure) would include the snippet to source >> `profile.d`. The snippet could find the dir relative to its own location >> so that the very same code could be placed as in the global file >> (/etc/profile) as in per-profile files. > > Thank you for clarifying what you meant. So just rephrasing to make > extra sure, what you would like to see is that every profile generated > would have in their etc/profile generated file something sourcing its > etc/profile.d/*.sh files, so that installing e.g. bash_completion in a > profile would automatically have its etc/profile.d/bash_completion.sh > file sourced, correct? Exactly. Basically, install the "for i in /etc/profile.d/*.sh; do" snippet adjusted to look for `profile.d` relative to current file. > > I'm not sure how useful that would be, because IIRC the > $profile/etc/profile of a generated profile is only ever sourced: > > 1. When it appears at /etc/profile, e.g. mapped there within a > container ... or is one of the default user profiles: --8<---------------cut here---------------start------------->8--- # from /etc/profile for profile in "$HOME/.guix-profile" \ "$HOME/.guix-home/profile" \ "$HOME/.config/guix/current" do if [ -f "$profile/etc/profile" ] then # Load the user profile's settings. GUIX_PROFILE="$profile" ; \ . "$profile/etc/profile" else # At least define this one so that basic things just work # when the user installs their first package. export PATH="$profile/bin:$PATH" fi done --8<---------------cut here---------------end--------------->8--- this alone is already helpful as it resolves the flatpak bug granted, custom profiles are not sourced by `/etc/profile`, but then it's a power-user territory and they'll sort it out themselves. > 2. The shell is started as a login shell, e.g. 'bash --login' > Note the --login requirement; which would not be in effect for example > when entering a 'guix shell' (which spawns 'sh') by default. The > etc/profile could be sourced manually, of course, but that seems to > defeat the purpose of having it there in the first place. > This is a tougher nut to crack, could be done separately. On a first glance it seems logical that 'guix shell' would start login shells, however this would lead to duplicated search paths as these would be set when starting the container and then when sourcing /etc/profile inside. It could be remedied with such steps: - Extract mandatory search path variables (PATH=, MANPATH=, etc) to a separate file (e.g. profile.env). - Prevent 'profile.env' files to be sourced twice: if [ "GUIX_PROFILE_<hash>_LOADED" -ne 1 ]; then export PATH=... ... GUIX_PROFILE_<hash>_LOADED=1 fi - 'guix/scripts/environment.scm' procedures should be adjusted to additionally set 'GUIX_PROFILE_<hash>_LOADED' env variable to avoid duplication of search paths > > Another idea would be to have /etc/bashrc source /etc/profile.d like > done in Fedora; that's a bit odd and I don't like it much for reasons > explained earlier, but it has the benefit of being compatible with the > packages like flatpak and vte that install things under etc/profile.d to > extend the non-login shells as well. I also don't like this idea. Why would non-login shells run `/etc/profile.d`? Aren't they launched in environment where login happened and therefore `/etc/profile` got applied already? > That could be made to work automatically for the fixed location like > /run/current-system/profile/etc/profile.d for system-installed > packages as well as $HOME/.profile/etc/profile.d/, and even for > non-containerized environments via $GUIX_ENVIRONMENT/etc/profile.d/. > It wouldn't work in containerized environment; this would need adding > a /etc/bashrc inside the container that would source > $GUIX_ENVIROMNENT/etc/profile.d.
Hi Sergey, Thanks for the brainstorm / ideas, even patch! [...] > I also don't like this idea. Why would non-login shells run > `/etc/profile.d`? Aren't they launched in environment where login > happened and therefore `/etc/profile` got applied already? That's what I initially thought, and I originally didn't see an immediate need for etc-bashrc-d-service-type, but upon testing with the /etc/profile.d/vte.sh file installed for example, at least in GNOME Console it wouldn't take effect. Perhaps the environment is cleaned up by GNOME Console and it expects the shell, e.g. Bash, to source /etc/profile.d/vte.sh from bashrc (GNOME Console starts the shell as an interactive, non-login shell). I had tested in an actual VM. Are you sure that it would help for the flatpak cases (have you actually tested it?). Reading flatpak.sh, I assume it would work, as long as flatpak is installed to the given profile, as it needs to be available on PATH when /etc/profile is sourced, which should be the case if the snippet is added below the existing variable exports in ~/.guix-profile/etc/profile (which contain PATH=). I'll try taking a look at your snippet. The guard avoiding double sourcing /etc/profile looks interesting, perhaps already useful to guard against bug#23118 for example?
Hi again, Sergey Trofimov <sarg@sarg.org.ru> writes: I just had a look a vte.sh, and I think I now understand why that particular one wouldn't work as /etc/profile.d/vte.sh: --8<---------------cut here---------------start------------->8--- # Not bash or zsh? [ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] || return 0 # Not an interactive shell? [[ $- == *i* ]] || return 0 # Not running under vte? [ "${VTE_VERSION:-0}" -ge 3405 ] || return 0 # TERM not supported? case "$TERM" in xterm*|vte*|gnome*) :;; *) return 0 ;; esac --8<---------------cut here---------------end--------------->8--- I guess at least the VTE_VERSION check would cause the script to return early for the login shell, which is not run from a VTE-powered terminal.