From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mIaSK7WnLGGtIwEAgWs5BA (envelope-from ) for ; Mon, 30 Aug 2021 11:41:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qIhIJ7WnLGH8EwAA1q6Kng (envelope-from ) for ; Mon, 30 Aug 2021 09:41:09 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1320C347F for ; Mon, 30 Aug 2021 11:41:09 +0200 (CEST) Received: from localhost ([::1]:58074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKdmu-00073B-2n for larch@yhetil.org; Mon, 30 Aug 2021 05:41:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKdmo-00072n-QY for guix-patches@gnu.org; Mon, 30 Aug 2021 05:41:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKdmo-0003u9-Fk for guix-patches@gnu.org; Mon, 30 Aug 2021 05:41:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKdmo-0003Lu-7B for guix-patches@gnu.org; Mon, 30 Aug 2021 05:41:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50208] [PATCH 0/4] Fixes and improvements for home-services Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 30 Aug 2021 09:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50208 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Oleg Pykhalov Cc: 50208@debbugs.gnu.org Received: via spool by 50208-submit@debbugs.gnu.org id=B50208.163031641912826 (code B ref 50208); Mon, 30 Aug 2021 09:41:02 +0000 Received: (at 50208) by debbugs.gnu.org; 30 Aug 2021 09:40:19 +0000 Received: from localhost ([127.0.0.1]:58179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKdm6-0003Ko-DK for submit@debbugs.gnu.org; Mon, 30 Aug 2021 05:40:18 -0400 Received: from mail-lf1-f43.google.com ([209.85.167.43]:34710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKdm3-0003KW-SL for 50208@debbugs.gnu.org; Mon, 30 Aug 2021 05:40:17 -0400 Received: by mail-lf1-f43.google.com with SMTP id z2so30045891lft.1 for <50208@debbugs.gnu.org>; Mon, 30 Aug 2021 02:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=tF1y4JPXNhLowBhdEF6ZfGbRhTDKaC3Gvi0cJZwHF1c=; b=qrWtZYIOS5HKAkfnksLHqi0nI9L6CAUnxrBA2jZf+YemOIopQprTt/cA0HJxw5e7ZO LQE6HcWcAKRFesaLila7TTSI37yXcfhrOJX/zZRF9E7jvNYNtNASl3Z+zV94JOKkoR6e f13ePZXbhcgD2hI4p+oD2ALNdWrtMPORNm1rW5fxiy6SjWW3xkHoxufz5VhQdSd4JKaz JMMHDh5L2G09+cOKBpFTx31tLDosjK2rc2+nsSnfcFB36fLFFp/jgpYcmR3g8+sQ5Ur1 Q7iEVods20hiTllWmZ7Z31GsKmiPgggLBN9iDdGuH4ZAeMJI9oyEEVYttnt7FTzLSZpH Iurw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=tF1y4JPXNhLowBhdEF6ZfGbRhTDKaC3Gvi0cJZwHF1c=; b=rvT5aIN3cqpxP8DQGRTx2FLrobrriiQwzpXSg6V/vzj1in1svqAlkvhYyoFlY+G+vO YT2eQmXoC9/RIanJYwglIgTyQhYfE0dAcySOgry/GP8XOosuoJ4YFfKA5+FZx8f0uds1 gT9F7asj1Is6BH2ai0+4CxK/u74EoUjioGWVSvvxXFPXmuRA5S2Vt/igDUjZ+AITZnv3 BIlUY6pSHe4n58L/4znQyiFIe9aYz5NReyW1O+LYBSydnLKdnclRNIRsCxFelELWXOwR aRMWcNp+2S4W7dEF1z4yWwxHSh3gRDz9YpNFCxrmTHVD4z9KFMCs7zR+Sj8KVZLKAjqK vDCQ== X-Gm-Message-State: AOAM531SfGCPp+YzTweE4ij5C2xtxv3CdJ6Rtkr/4tA9XwHzcPtqHZDX 6UQaKtjJZm/EibFkmkYRQ/a0JA== X-Google-Smtp-Source: ABdhPJwMq/068HX1q96zVM6lmKdt/J+o84Q9eiF5D0NgzS+Zbp4s7ieKX0t1DfHk7UEkU2G7QpY+YA== X-Received: by 2002:a05:6512:139c:: with SMTP id p28mr16770863lfa.523.1630316409584; Mon, 30 Aug 2021 02:40: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 t17sm1333030lfq.176.2021.08.30.02.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 02:40:08 -0700 (PDT) From: Andrew Tropin In-Reply-To: <87r1eg8obm.fsf@gmail.com> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> Date: Mon, 30 Aug 2021 12:40:05 +0300 Message-ID: <87fsur8e4q.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630316469; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=tF1y4JPXNhLowBhdEF6ZfGbRhTDKaC3Gvi0cJZwHF1c=; b=YPaYvsPtwLbEiU5iKyz1Ussy8phlq+sJhC9mahrj3az2mcM5XJxB0SVkytXUo4j3wBXG7b 29D3nyT/VkKh58zR1copkYcice8FHGWoKnrEuTlQBHwjqsys27762CriRujcUMwbh6Od7B soz4By2LTGgXhXpYQvttfmrDfAXxZQT7/UFBZIqot/G7VcRklORoMweeXIjlOitSRNlAh+ B52nWEKc434FB2brHmGQIBsK8gNDryUjs3ZWj0tDpBq7xCebgZagBc40j6KxGTcxXf2Ma3 sUnKibPW3qaKCHaSRt27KK0rahFkXQzm1wtl6DvMqmi5EApv+3j4el3YukvWdA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630316469; a=rsa-sha256; cv=none; b=g6s5ouEdEFRN0FSjrV88YoPN9Zwt4XooGv2dxHYf4UKsyMAw9BhWKR0HL80JiCUjq45bGj AARSBX+OOfPSQqWbmTcb6F+CjEVks6s2MLaQtghYiXqYxCdaai16hgPJVkgukSGYBNZAqO +Kp0ubs/SCn3kWVxTnNkQLMqraXFhBhYS1jNJtiXU5LvTjHo+7QpCoRCt9F3zAqw8/+jbj y7jbOUGjTQTYRBGKc7PozusA2Ycg4UaSjIIKLstqxEkYECWD2G6iGIc6ytGhGaeJiARReo YzEVOILD3rqGxFh5cc3cQHT5Ed0JsL7J23imcwQ5mtgjvL97AUGBgDhBPDJfWg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20150623.gappssmtp.com header.s=20150623 header.b=qrWtZYIO; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.02 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20150623.gappssmtp.com header.s=20150623 header.b=qrWtZYIO; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 1320C347F X-Spam-Score: -2.02 X-Migadu-Scanner: scn0.migadu.com X-TUID: u5Ti/nMDykz9 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable There are a few follow up patches for the current wip-guix-home branch: =2D Add utils ns with helpers for converting cases, which was missing. =2D Fix issue with creating first home-environment generation. =2D Add support to activation script for multiline values for environment variables. =2D Add a doc comment. The patches are attached to this messages. Andrew Tropin (4): home-services: Add utils module. home-services: symlink-manager: Properly handle 1st generation case home-services: activation: Add support for multiline env vars gnu: home: Add doc comment about the module gnu/home-services.scm | 4 +- gnu/home-services/shells.scm | 1 + gnu/home-services/symlink-manager.scm | 2 +- gnu/home-services/utils.scm | 77 +++++++++++++++++++++++++++ gnu/home.scm | 8 +++ 5 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 gnu/home-services/utils.scm =2D-=20 2.33.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-home-services-Add-utils-module.patch Content-Transfer-Encoding: quoted-printable From=2093ae498296b37e5b21b6a824d090b0898b870a39 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:17:11 +0300 Subject: [PATCH 1/4] home-services: Add utils module. * gnu/home-services/utils.scm (maybe-object->string object->snake-case-stri= ng) (object->snake-case-string): New variables. =2D-- gnu/home-services/shells.scm | 1 + gnu/home-services/utils.scm | 77 ++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 gnu/home-services/utils.scm diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm index b8065d28d2..ecb02098f7 100644 =2D-- a/gnu/home-services/shells.scm +++ b/gnu/home-services/shells.scm @@ -20,6 +20,7 @@ (define-module (gnu home-services shells) #:use-module (gnu services configuration) #:use-module (gnu home-services configuration) + #:use-module (gnu home-services utils) #:use-module (gnu home-services) #:use-module (gnu packages shells) #:use-module (gnu packages bash) diff --git a/gnu/home-services/utils.scm b/gnu/home-services/utils.scm new file mode 100644 index 0000000000..3e490a0515 =2D-- /dev/null +++ b/gnu/home-services/utils.scm @@ -0,0 +1,77 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; +;;; 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 . + +(define-module (gnu home-services utils) + #:use-module (ice-9 string-fun) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + + #:export (maybe-object->string + object->snake-case-string + object->camel-case-string)) + +(define (maybe-object->string object) + "Like @code{object->string} but don't do anyting if OBJECT already is +a string." + (if (string? object) + object + (object->string object))) + +;; Snake case: +(define* (object->snake-case-string object #:optional (style 'lower)) + "Convert the object OBJECT to the equivalent string in ``snake +case''. STYLE can be three `@code{lower}', `@code{upper}', or +`@code{capitalize}', defaults to `@code{lower}'. + +@example +(object->snake-case-string 'variable-name 'upper) +@result{} \"VARIABLE_NAME\" @end example" + (if (not (member style '(lower upper capitalize))) + (error 'invalid-style (format #f "~a is not a valid style" style)) + (let ((stringified (maybe-object->string object))) + (string-replace-substring + (cond + ((equal? style 'lower) stringified) + ((equal? style 'upper) (string-upcase stringified)) + (else (string-capitalize stringified))) + "-" "_")))) + +(define* (object->camel-case-string object #:optional (style 'lower)) + "Convert the object OBJECT to the equivalent string in ``camel case''. +STYLE can be three `@code{lower}', `@code{upper}', defaults to +`@code{lower}'. + +@example +(object->camel-case-string 'variable-name 'upper) +@result{} \"VariableName\" +@end example" + (if (not (member style '(lower upper))) + (error 'invalid-style (format #f "~a is not a valid style" style)) + (let ((stringified (maybe-object->string object))) + (cond + ((eq? style 'upper) + (string-concatenate + (map string-capitalize + (string-split stringified (cut eqv? <> #\-))))) + ((eq? style 'lower) + (let ((splitted-string (string-split stringified (cut eqv? <> #\= -)))) + (string-concatenate + (cons (first splitted-string) + (map string-capitalize + (cdr splitted-string)))))))))) =2D-=20 2.33.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-home-services-symlink-manager-Properly-handle-1st-ge.patch Content-Transfer-Encoding: quoted-printable From=20eebdfd72d2e20b18154f66fc0f84c723340e3b5f Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:23:48 +0300 Subject: [PATCH 2/4] home-services: symlink-manager: Properly handle 1st generation case =2D-- gnu/home-services/symlink-manager.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/syml= ink-manager.scm index dc409d2ae2..11f5d503d4 100644 =2D-- a/gnu/home-services/symlink-manager.scm +++ b/gnu/home-services/symlink-manager.scm @@ -102,7 +102,7 @@ appear only after all nested items already listed." (number->string (current-time)) "-guix-home-legacy-configs-backup= ")) =20 =2D (old-tree (if (file-exists? old-home) + (old-tree (if old-home ((simplify-file-tree "") (file-system-tree (string-append old-home "/files/."))) =2D-=20 2.33.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-home-services-activation-Add-support-for-multiline-e.patch Content-Transfer-Encoding: quoted-printable From=2025f61084e11fccc50dc1fbec3b28e7dea091e625 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:26:19 +0300 Subject: [PATCH 3/4] home-services: activation: Add support for multiline e= nv vars =2D-- gnu/home-services.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnu/home-services.scm b/gnu/home-services.scm index 16b9736d64..2a773496f0 100644 =2D-- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -324,7 +324,7 @@ extended with one gexp."))) #f)))) (if (file-exists? (he-init-file new-home)) (let* ((port ((@ (ice-9 popen) open-input-pipe) =2D (format #f "source ~a && env" + (format #f "source ~a && env -0" (he-init-file new-home)))) (result ((@ (ice-9 rdelim) read-delimited) "" port)) (vars (map (lambda (x) @@ -333,7 +333,7 @@ extended with one gexp."))) (string-drop x (1+ si))))) ((@ (srfi srfi-1) remove) string-null? =2D (string-split result #\newline))))) + (string-split result #\nul))))) (close-port port) (map (lambda (x) (setenv (car x) (cdr x))) vars) =20 =2D-=20 2.33.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0004-gnu-home-Add-doc-comment-about-the-module.patch Content-Transfer-Encoding: quoted-printable From=20ec05edf310609dd1424ce7bfdcaaf6758a77fe29 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:07:48 +0300 Subject: [PATCH 4/4] gnu: home: Add doc comment about the module =2D-- gnu/home.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gnu/home.scm b/gnu/home.scm index a53d27163d..f4c9359e25 100644 =2D-- a/gnu/home.scm +++ b/gnu/home.scm @@ -38,6 +38,14 @@ =20 home-environment-with-provenance)) =20 +;;; Comment: +;;; +;;; This module provides a record for managing +;;; per-user packages and configuration files in the similar way as +;;; do for system packages and configuration files. +;;; +;;; Code: + (define-record-type* home-environment make-home-environment home-environment? =2D-=20 2.33.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEsp3UACgkQIgjSCVjB 3rA/mw/8CNlwof5gj8DibO8CBvGN41PfNIgQh6K0388kXws+l0YkKtiqfe4U4S3L 5cvLCxuNmqra/jf2i9qYCOxokN1fkyJz1oBdJLkP7bKmuji3fj1VbbPka338xc2U B3h0ZmpJ3Ednzr/tCMdMA2Kx4XqYyktNPiLb65KOiVyHanuzvNag+kuw+js2c8wo BRArfkslYeq3mNeHbKE8XuItujeYTwgLnddgdtpFdWpl46U7TS3Md1uaCs+Od4cP PX1cN5XVX8lVWBdQ+1gbZyVZipMTYvREOAVNXXbWVETaektC1moGI7DAn42WtDu1 eo95Fd2Ke4fImnopS4rE9/qEBvexF04/7yR/fAz3kPCVVb4KEHTm57ez7tjDFF3f OWU2UlVxfL4Mq1Xe8raQsifFfpQRSUHHaM+Bg+L/f9DpU88bdbEh1kRbQO1ih/zU P/SAChAhDQw9i8vagZiJn1Q4rSITRJdljlqDPa1yxRp7/JV0QH7F1yb8AQbFF1c/ lxh79BI26EEOpL9QH9V62S9ChtMnN4EeLbadPtyzjh08mBnlAnb/7B5QjKB+XqBd WVM9r0yuOmYw+WJNxgmty28mfwfwYsKpcAvFtGdmT2BVDtAzIfYIzZA9PKRfy9da B09Pyvn+0MqhybjNguV7ns2SKfQJOyRKm9iD4BxPjYNH6BlRBao= =0AqG -----END PGP SIGNATURE----- --==-=-=--