GNU bug report logs - #49546
[PATCH v2 1/4] home-services: Add most essential home services

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Andrew Tropin <andrew@HIDDEN>; Keywords: patch; merged with #49419, #49547, #49548, #49549; dated Tue, 13 Jul 2021 18:19:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Merged 49419 49546 49547 49548 49549. Request was from Andrew Tropin <andrew@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 49546 <at> debbugs.gnu.org:


Received: (at 49546) by debbugs.gnu.org; 13 Jul 2021 18:25:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 13 14:25:08 2021
Received: from localhost ([127.0.0.1]:41992 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m3N5g-0000iL-J2
	for submit <at> debbugs.gnu.org; Tue, 13 Jul 2021 14:25:08 -0400
Received: from mail-lj1-f170.google.com ([209.85.208.170]:33306)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andrew@HIDDEN>) id 1m3N5e-0000hh-4m
 for 49546 <at> debbugs.gnu.org; Tue, 13 Jul 2021 14:25:07 -0400
Received: by mail-lj1-f170.google.com with SMTP id u14so20616590ljh.0
 for <49546 <at> debbugs.gnu.org>; Tue, 13 Jul 2021 11:25:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=trop-in.20150623.gappssmtp.com; s=20150623;
 h=from:to:subject:in-reply-to:references:date:message-id:mime-version;
 bh=wplT/anKtJ90t9XdWf50KxNrlIETcZgTjVwi+oJTmv4=;
 b=OjFad4KLqFcTZawvUuIf+17PRQ+4ismZ3wyRspa0pbEFP/Jc1GNTzd4suAiWbZ1DxB
 t+ZGXJGxIgFei3dAHmLPI097gO7ejVhgKDQc5/rvPNt4zNt8mxtjMBKLF3ZLLo74ATnO
 X/Qh60aTmuCcb51tI2q7pwCsr/lzO5WLo7IVE13HUGdYJ/e3pusc8NdLkSYV3WN/JWSE
 oeSJDkF3UPG+kjaoVreGEI8zvXUfh11maCrBBtW7Um8Xfj3GrL3BZ4eJ7Mtq+/GM/+cI
 V5UCHq9Bxoe4WoS1YIKx+fgacKw9v/qWbtbY+wbY5lSXov7kf0RYrpAfjd88+YR93eat
 OZYg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:in-reply-to:references:date
 :message-id:mime-version;
 bh=wplT/anKtJ90t9XdWf50KxNrlIETcZgTjVwi+oJTmv4=;
 b=uV3SAqdzVA3vNUUUNgg9PREIVxk5x5vt8C0ckvR80AK9QOg8jgrDiQzz2g43fK7CW2
 m8VFUtL1wE1oXRAyodBgi61JdDentbcBi5FMBYYe6ZHN4f7QGRSGDlcLJPyzolnOtUlG
 zQPkYCY0v6QBN+BvnNVSjt2/23oVkJrSMK5Ys5PV5j8EfRlJN9d/jrnFAJj8JzVmg3Nb
 dwgQYx3GMwiDHyCEeo6sJ8257KeEc10v5X1h5Tqk5LJe9+ApK6p0YxWbnX+NnZkRIsm6
 +br0hrEWmll1p02dytxOxVhxUqbcViP+TQWAJwQxl0ena+iAaCBq0XnPvvkIGYpHFmaB
 fRhA==
X-Gm-Message-State: AOAM532aQQGVjfvpA8ubCzV5NqL2F3ioHuMpYProrut0eNf4LngniIxG
 q+xMf9HUOl7gZouz3NWWG3FKtsfAWW4ZxA==
X-Google-Smtp-Source: ABdhPJwYakbNvM2+MxCqeOS/LAXRb7mzvBSpKCZcpA+RHEcEIbfkx0LI1ksZbU/T4A+dep6InZ/J4w==
X-Received: by 2002:a2e:9cc9:: with SMTP id g9mr5287077ljj.194.1626200699632; 
 Tue, 13 Jul 2021 11:24:59 -0700 (PDT)
Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92])
 by smtp.gmail.com with ESMTPSA id s3sm319332lfd.49.2021.07.13.11.24.58
 for <49546 <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 13 Jul 2021 11:24:58 -0700 (PDT)
From: Andrew Tropin <andrew@HIDDEN>
To: 49546 <at> debbugs.gnu.org
Subject: Re: bug#49546: Acknowledgement ([PATCH v2 1/4] home-services: Add
 most essential home services)
In-Reply-To: <handler.49546.B.16262002971832.ack <at> debbugs.gnu.org>
References: <878s2am68u.fsf@HIDDEN>
 <handler.49546.B.16262002971832.ack <at> debbugs.gnu.org>
Date: Tue, 13 Jul 2021 21:24:46 +0300
Message-ID: <87sg0ikr69.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 49546
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

help-debbugs@HIDDEN (GNU bug Tracking System) writes:

> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  guix-patches@HIDDEN
>
> If you wish to submit further information on this problem, please
> send it to 49546 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@HIDDEN unless you wish
> to report a problem with the Bug-tracking system.

It's strange, do I need to wait more, before replying to cover letter?

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmDt2m4PHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wWjUP/iA2IsxuxZwLN7XWaYph4sLCdLBqVcz+NyYO
9mJrzSdb4nQFh6JoLe7kh+9beZvGhVG94wCpVeK/ggzx46lWnXEa2smPpXsDzgSQ
qHRmYEYMLLkIW1wN4PsLxnrZzpfM/zHSx7sNWpHWeJJj3P+HbRl2QB8A5ANwp+Ep
3vs/7EWxq4F+ZCgm9OkQWiFmgKJP/qcbDTPKX1pD/anetWiRI+ySvpAZ8GTX924E
b6x901QgBMgvQMqaytEZAycH6g46Q6MNSNUW4et45yfymNFE9/bVgIeYsEQo43Sy
rvvsMlqmlD2FXODENTVmhmgjWgS5JKUWtfCTrYEbl7s8ohE04NWXDCLLyC4x2XPu
lFORuAfQyWMSO68KCgLJoU2crycNZemA4ktEgrBaDWbsoNc4LGNINTIug+QmnglG
QHYN8XnbE6SYbmrTHE/YkMPdQBE9e6rfVCR+qDEu34zDTI/hNiBNJIBWF4eYGITx
RCvJM5aN2X8DUB49rsbln4zZ1MlTL8gkpTR3ld+hl4j//iALVLMrC9saHZaiOrg1
yQdOVI/uZ28qTF47xCyY8ARQEA2eIDofnbIS1aHZ8N0fL3g07XfR7JuT3thcbSTm
7atkHp57bMiUK0bknvJ6L9ngymaFQIrnABOvz1+DpFb1u4IdM+U54e2uIBqxLZdz
5r+FiyjZ
=c3sr
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#49546; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Jul 2021 18:18:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 13 14:18:17 2021
Received: from localhost ([127.0.0.1]:41955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1m3Mz2-0000TR-J2
	for submit <at> debbugs.gnu.org; Tue, 13 Jul 2021 14:18:17 -0400
Received: from lists.gnu.org ([209.51.188.17]:40880)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <andrew@HIDDEN>) id 1m3Myz-0000TH-Vb
 for submit <at> debbugs.gnu.org; Tue, 13 Jul 2021 14:18:14 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36642)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <andrew@HIDDEN>) id 1m3Myz-0004Nk-Py
 for guix-patches@HIDDEN; Tue, 13 Jul 2021 14:18:13 -0400
Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:35581)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <andrew@HIDDEN>) id 1m3Myx-00079n-Ln
 for guix-patches@HIDDEN; Tue, 13 Jul 2021 14:18:13 -0400
Received: by mail-lj1-x22c.google.com with SMTP id 141so14828052ljj.2
 for <guix-patches@HIDDEN>; Tue, 13 Jul 2021 11:18:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=trop-in.20150623.gappssmtp.com; s=20150623;
 h=from:to:subject:in-reply-to:date:message-id:mime-version
 :content-transfer-encoding;
 bh=tfBClv/FCRsR0HdJJTBP+7HSsGD39vexKccgzPh04xQ=;
 b=fIxwTdfykvBTa98/WLbmmm654veURwYOOSkR5bAVtIOCDDy25zumgZ//kKpytE2c+I
 SHHppv3y52lADyyhFS+rc7O6LlJwpDpRhZVx5OLzSD0+eOiyuR2OL5jnNiboPlpfRA6K
 EPJFrlj2bQnRtF8CoeWe16bCbD4t0kdPWtlv6nBClmTCILM5vitHp+vUevOiXkU4oCNB
 bv3h36i/tAsd5S/t18uYvB7ELxlWDLWYkHwN4Dcx4J3pYieMVOvhcGYf9FrreBduUirO
 9QGModP/2gYc7K975UCmgHc7XY5szqhOwKq4JEhjnpbxitVvmQqtINdubvZF9DzlIUDT
 pFBg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:in-reply-to:date:message-id
 :mime-version:content-transfer-encoding;
 bh=tfBClv/FCRsR0HdJJTBP+7HSsGD39vexKccgzPh04xQ=;
 b=mZHlonjvuWvFY7UxfuFFDuUE256INoX/KwB11PXcalHRrW1he5hYIyaU2K2Ne+TbWr
 2q3KbDjNpLzo4ibRAovVnTMsoy1E3piIAeYf+wgZ8LKcU8LUiddViK2Q6Jfbbw/ltH4U
 0ZN1t79yWjD/0HuPr76oQdkt5DZXBv470TZupFCgF5UgEjnII6PDJxD8NgbpiNHc/ROq
 o5QXMAj9XHoJNKmpQHDuotTJw+shRzzeIZ6YrIcNdzi8iwGT1iix2spYnfODVHticUCk
 Uv2EQMGgFPE+iRX0ZDkWXZ6jDvN0kwJ6PX3IoghZoBrpjy+q0Zr84GDYgy8L/AuCHPie
 x3jg==
X-Gm-Message-State: AOAM530K2tP9iXvTLnoFkoyJsZ0bWVNWjA0oD4aupLFECx+zMXbVpOwz
 egp4H5WXl/PDQTVcP9ApB4t86wYa9GJ8Jw==
X-Google-Smtp-Source: ABdhPJwHAn9WljUNdFdUZDTIbvC4n1kZdQED2tS3tZ6bx9t185xhtAOMBsvmrMeHxPe/Ay8TRVZklQ==
X-Received: by 2002:a05:651c:1507:: with SMTP id
 e7mr5281528ljf.9.1626200289418; 
 Tue, 13 Jul 2021 11:18:09 -0700 (PDT)
Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92])
 by smtp.gmail.com with ESMTPSA id f14sm1985694ljk.42.2021.07.13.11.18.08
 for <guix-patches@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 13 Jul 2021 11:18:08 -0700 (PDT)
From: Andrew Tropin <andrew@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH v2 1/4] home-services: Add most essential home services
In-Reply-To: <87bl76m6b7.fsf@HIDDEN>
Date: Mon, 5 Jul 2021 18:37:13 +0300
Message-ID: <878s2am68u.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: none client-ip=2a00:1450:4864:20::22c;
 envelope-from=andrew@HIDDEN; helo=mail-lj1-x22c.google.com
X-Spam_score_int: 15
X-Spam_score: 1.5
X-Spam_bar: +
X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405,
 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001,
 SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.8 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: home-service-type is a root of home services DAG.
 home-profile-service-type
 is almost the same as profile-service-type,
 at least for now. home-environment-variables-service-type
 generates a @file{setup-environment} shell script, which is expected to be
 sourced by login shell or other program, which starts early and spawns all
 other proc [...] 
 Content analysis details:   (1.8 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 RCVD_IN_MSPIKE_H4      RBL: Very Good reputation (+4)
 [209.51.188.17 listed in wl.mailspike.net]
 -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,
 medium trust [209.51.188.17 listed in list.dnswl.org]
 0.0 SPF_NONE               SPF: sender does not publish an SPF Record
 2.1 DATE_IN_PAST_96_XX     Date: is 96 hours or more before Received:
 date -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: yoctocell.xyz (xyz)]
 0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.8 (/)


home-service-type is a root of home services DAG.

home-profile-service-type is almost the same as profile-service-type, at le=
ast
for now.

home-environment-variables-service-type generates a @file{setup-environment}
shell script, which is expected to be sourced by login shell or other progr=
am,
which starts early and spawns all other processes.  Home services for shells
automatically add code for sourcing this file, if person do not use those h=
ome
services they have to source this script manually in their's shell *profile
file (details described in the manual).

home-files-service-type is similar to etc-service-type, but doesn't extend
home-activation, because deploy mechanism for config files is pluggable and
can be different for different home environments: The default one is called
symlink-manager (will be introudced in a separate patch series), which crea=
tes
links for various dotfiles (like $XDG_CONFIG_HOME/$APP/...) to store, but is
possible to implement alternative approaches like read-only home from Julie=
n's
guix-home-manager.

home-run-on-first-login-service-type provides an @file{on-first-login} guile
script, which runs provided gexps once, when user makes first login.  It can
be used to start user's Shepherd and maybe some other process.  It relies on
assumption that /run/user/$UID will be created on login by some login
manager (elogind for example).

home-activation-service-type provides an @file{activate} guile script, which
do three main things:

- Sets environment variables to the values declared in
@file{setup-environment} shell script.  It's necessary, because user can set
for example XDG_CONFIG_HOME and it should be respected by activation gexp of
symlink-manager.

- Sets GUIX_NEW_HOME and possibly GUIX_OLD_HOME vars to paths in the store.
Later those variables can be used by activation gexps, for example by
symlink-manager or run-on-change services.

- Run all activation gexps provided by other home services.
---
 gnu/home-services.scm | 328 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 328 insertions(+)
 create mode 100644 gnu/home-services.scm

diff --git a/gnu/home-services.scm b/gnu/home-services.scm
new file mode 100644
index 0000000000..a89a061a81
--- /dev/null
+++ b/gnu/home-services.scm
@@ -0,0 +1,328 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright =C2=A9 2021 Andrew Tropin <andrew@HIDDEN>
+;;; Copyright =C2=A9 2021 Xinglu Chen <public@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu home-services)
+  #:use-module (gnu services)
+  #:use-module (guix channels)
+  #:use-module (guix monads)
+  #:use-module (guix store)
+  #:use-module (guix gexp)
+  #:use-module (guix profiles)
+  #:use-module (guix sets)
+  #:use-module (guix ui)
+  #:use-module (guix discovery)
+  #:use-module (guix diagnostics)
+
+  #:use-module (srfi srfi-1)
+  #:use-module (ice-9 match)
+
+  #:export (home-service-type
+	    home-profile-service-type
+	    home-environment-variables-service-type
+	    home-files-service-type
+	    home-run-on-first-login-service-type
+            home-activation-service-type)
+
+  #:re-export (service
+	       service-type
+	       service-extension))
+
+;;; Comment:
+;;;
+;;; This module is similar to (gnu system services) module, but
+;;; provides Home Services, which are supposed to be used for building
+;;; home-environment.
+;;;
+;;; Home Services use the same extension as System Services.  Consult
+;;; (gnu system services) module or manual for more information.
+;;;
+;;; Code:
+
+
+(define (home-derivation entries mextensions)
+  "Return as a monadic value the derivation of the 'home'
+directory containing the given entries."
+  (mlet %store-monad ((extensions (mapm/accumulate-builds identity
+                                                          mextensions)))
+    (lower-object
+     (file-union "home" (append entries (concatenate extensions))))))
+
+(define home-service-type
+  ;; This is the ultimate service type, the root of the home service
+  ;; DAG.  The service of this type is extended by monadic name/item
+  ;; pairs.  These items end up in the "home-environment directory" as
+  ;; returned by 'home-environment-derivation'.
+  (service-type (name 'home)
+                (extensions '())
+                (compose identity)
+                (extend home-derivation)
+		(default-value '())
+                (description
+                 "Build the home environment top-level directory,
+which in turn refers to everything the home environment needs: its
+packages, configuration files, activation script, and so on.")))
+
+(define (packages->profile-entry packages)
+  "Return a system entry for the profile containing PACKAGES."
+  ;; XXX: 'mlet' is needed here for one reason: to get the proper
+  ;; '%current-target' and '%current-target-system' bindings when
+  ;; 'packages->manifest' is called, and thus when the 'package-inputs'
+  ;; etc. procedures are called on PACKAGES.  That way, conditionals in th=
ose
+  ;; inputs see the "correct" value of these two parameters.  See
+  ;; <https://issues.guix.gnu.org/44952>.
+  (mlet %store-monad ((_ (current-target-system)))
+    (return `(("profile" ,(profile
+                           (content (packages->manifest
+                                     (map identity
+                                     ;;(options->transformation transforma=
tions)
+                                     (delete-duplicates packages eq?))))))=
))))
+
+;; MAYBE: Add a list of transformations for packages.  It's better to
+;; place it in home-profile-service-type to affect all profile
+;; packages and prevent conflicts, when other packages relies on
+;; non-transformed version of package.
+(define home-profile-service-type
+  (service-type (name 'home-profile)
+                (extensions
+                 (list (service-extension home-service-type
+                                          packages->profile-entry)))
+                (compose concatenate)
+                (extend append)
+                (description
+                 "This is the @dfn{home profile} and can be found in
+@file{~/.guix-home/profile}.  It contains packages and
+configuration files that the user has declared in their
+@code{home-environment} record.")))
+
+(define (environment-variables->setup-environment-script vars)
+  "Return a file that can be sourced by a POSIX compliant shell which
+initializes the environment.  The file will source the home
+environment profile, set some default environment variables, and set
+environment variables provided in @code{vars}.  @code{vars} is a list
+of pairs (@code{(key . value)}), @code{key} is a string and
+@code{value} is a string or gexp.
+
+If value is @code{#f} variable will be omitted.
+If value is @code{#t} variable will be just exported.
+For any other, value variable will be set to the @code{value} and
+exported."
+  (define (warn-about-duplicate-defenitions)
+    (fold
+     (lambda (x acc)
+       (when (equal? (car x) (car acc))
+	 (warning
+	  (G_ "duplicate definition for `~a' environment variable ~%") (car x)))
+       x)
+     (cons "" "")
+     (sort vars (lambda (a b)
+		  (string<? (car a) (car b))))))
+
+  (warn-about-duplicate-defenitions)
+  (with-monad
+   %store-monad
+   (return
+    `(("setup-environment"
+       ;; TODO: It's necessary to source ~/.guix-profile too
+       ;; on foreign distros
+       ,(apply mixed-text-file "setup-environment"
+	       "\
+HOME_ENVIRONMENT=3D$HOME/.guix-home
+GUIX_PROFILE=3D\"$HOME_ENVIRONMENT/profile\"
+PROFILE_FILE=3D\"$HOME_ENVIRONMENT/profile/etc/profile\"
+[ -f $PROFILE_FILE ] && . $PROFILE_FILE
+
+case $XDG_DATA_DIRS in
+  *$HOME_ENVIRONMENT/profile/share*) ;;
+  *) export XDG_DATA_DIRS=3D$HOME_ENVIRONMENT/profile/share:$XDG_DATA_DIRS=
 ;;
+esac
+case $MANPATH in
+  *$HOME_ENVIRONMENT/profile/share/man*) ;;
+  *) export MANPATH=3D$HOME_ENVIRONMENT/profile/share/man:$MANPATH
+esac
+case $INFOPATH in
+  *$HOME_ENVIRONMENT/profile/share/info*) ;;
+  *) export INFOPATH=3D$HOME_ENVIRONMENT/profile/share/info:$INFOPATH ;;
+esac
+case $XDG_CONFIG_DIRS in
+  *$HOME_ENVIRONMENT/profile/etc/xdg*) ;;
+  *) export XDG_CONFIG_DIRS=3D$HOME_ENVIRONMENT/profile/etc/xdg:$XDG_CONFI=
G_DIRS ;;
+esac
+case $XCURSOR_PATH in
+  *$HOME_ENVIRONMENT/profile/share/icons*) ;;
+  *) export XCURSOR_PATH=3D$HOME_ENVIRONMENT/profile/share/icons:$XCURSOR_=
PATH ;;
+esac
+
+"
+
+	       (append-map
+		(match-lambda
+		  ((key . #f)
+		   '())
+		  ((key . #t)
+		   (list "export " key "\n"))
+		  ((key . value)
+                   (list "export " key "=3D" value "\n")))
+		vars)))))))
+
+(define home-environment-variables-service-type
+  (service-type (name 'home-environment-variables)
+                (extensions
+                 (list (service-extension
+			home-service-type
+                        environment-variables->setup-environment-script)))
+                (compose concatenate)
+                (extend append)
+		(default-value '())
+                (description "Set the environment variables.")))
+
+(define (files->files-directory files)
+  "Return a @code{files} directory that contains FILES."
+  (define (assert-no-duplicates files)
+    (let loop ((files files)
+               (seen (set)))
+      (match files
+        (() #t)
+        (((file _) rest ...)
+         (when (set-contains? seen file)
+           (raise (formatted-message (G_ "duplicate '~a' entry for files/")
+                                     file)))
+         (loop rest (set-insert file seen))))))
+
+  ;; Detect duplicates early instead of letting them through, eventually
+  ;; leading to a build failure of "files.drv".
+  (assert-no-duplicates files)
+
+  (file-union "files" files))
+
+(define (files-entry files)
+  "Return an entry for the @file{~/.guix-home/files}
+directory containing FILES."
+  (with-monad %store-monad
+    (return `(("files" ,(files->files-directory files))))))
+
+(define home-files-service-type
+  (service-type (name 'home-files)
+                (extensions
+                 (list (service-extension home-service-type
+                                          files-entry)))
+                (compose concatenate)
+                (extend append)
+		(default-value '())
+                (description "Configuration files for programs that
+will be put in @file{~/.guix-home/files}.")))
+
+(define (compute-on-first-login-script _ gexps)
+  (gexp->script
+   "on-first-login"
+   #~(let* ((xdg-runtime-dir (or (getenv "XDG_RUNTIME_DIR")
+				 (format #f "/run/user/~a" (getuid))))
+	    (flag-file-path (string-append
+			     xdg-runtime-dir "/on-first-login-executed"))
+	    (touch (lambda (file-name)
+		     (call-with-output-file file-name (const #t)))))
+       ;; XDG_RUNTIME_DIR dissapears on logout, that means such trick
+       ;; allows to launch on-first-login script on first login only
+       ;; after complete logout/reboot.
+       (when (not (file-exists? flag-file-path))
+	 (begin #$@gexps (touch flag-file-path))))))
+
+(define (on-first-login-script-entry m-on-first-login)
+  "Return, as a monadic value, an entry for the on-first-login script
+in the home environment directory."
+  (mlet %store-monad ((on-first-login m-on-first-login))
+	(return `(("on-first-login" ,on-first-login)))))
+
+(define home-run-on-first-login-service-type
+  (service-type (name 'home-run-on-first-login)
+                (extensions
+                 (list (service-extension
+			home-service-type
+                        on-first-login-script-entry)))
+                (compose identity)
+                (extend compute-on-first-login-script)
+		(default-value #f)
+                (description "Run gexps on first user login.  Can be
+extended with one gexp.")))
+
+
+(define (compute-activation-script init-gexp gexps)
+  (gexp->script
+   "activate"
+   #~(let* ((he-init-file (lambda (he) (string-append he "/setup-environme=
nt")))
+            (he-path (string-append (getenv "HOME") "/.guix-home"))
+            (new-home-env (getenv "GUIX_NEW_HOME"))
+            (new-home (or new-home-env
+                          ;; Path of the activation file if called interac=
tively
+                          (dirname (car (command-line)))))
+            (old-home-env (getenv "GUIX_OLD_HOME"))
+            (old-home (or old-home-env
+                          (if (file-exists? (he-init-file he-path))
+                              (readlink he-path)
+                              #f))))
+       (if (file-exists? (he-init-file new-home))
+           (let* ((port   ((@ (ice-9 popen) open-input-pipe)
+		           (format #f "source ~a && env"
+                                   (he-init-file new-home))))
+	          (result ((@ (ice-9 rdelim) read-delimited) "" port))
+	          (vars (map (lambda (x)
+                               (let ((si (string-index x #\=3D)))
+                                 (cons (string-take x si)
+                                       (string-drop x (1+ si)))))
+			     ((@ (srfi srfi-1) remove)
+			      string-null?
+                              (string-split result #\newline)))))
+	     (close-port port)
+	     (map (lambda (x) (setenv (car x) (cdr x))) vars)
+
+             (setenv "GUIX_NEW_HOME" new-home)
+             (setenv "GUIX_OLD_HOME" old-home)
+
+             #$@gexps
+
+             ;; Do not unset env variable if it was set outside.
+             (unless new-home-env (setenv "GUIX_NEW_HOME" #f))
+             (unless old-home-env (setenv "GUIX_OLD_HOME" #f)))
+           (format #t "\
+Activation script was either called or loaded by file from this direcotry:
+~a
+It doesn't seem that home environment is somewhere around.
+Make sure that you call ./activate by symlink from -home store item.\n"
+                   new-home)))))
+
+(define (activation-script-entry m-activation)
+  "Return, as a monadic value, an entry for the activation script
+in the home environment directory."
+  (mlet %store-monad ((activation m-activation))
+    (return `(("activate" ,activation)))))
+
+(define home-activation-service-type
+  (service-type (name 'home-activation)
+                (extensions
+                 (list (service-extension
+			home-service-type
+                        activation-script-entry)))
+                (compose identity)
+                (extend compute-activation-script)
+		(default-value #f)
+                (description "Run gexps to activate the current
+generation of home environment and update the state of the home
+directory.  @command{activate} script automatically called during
+reconfiguration or generation switching.  This service can be extended
+with one gexp, but many times, and all gexps must be idempotent.")))
+
--=20
2.32.0





Acknowledgement sent to Andrew Tropin <andrew@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#49546; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 13 Jul 2021 18:30:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.