From unknown Thu Jun 19 13:56:43 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#50208 <50208@debbugs.gnu.org> To: bug#50208 <50208@debbugs.gnu.org> Subject: Status: [PATCH] home-services: Add symlink-manager Reply-To: bug#50208 <50208@debbugs.gnu.org> Date: Thu, 19 Jun 2025 20:56:43 +0000 retitle 50208 [PATCH] home-services: Add symlink-manager reassign 50208 guix-patches submitter 50208 Andrew Tropin severity 50208 normal tag 50208 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 26 02:59:11 2021 Received: (at submit) by debbugs.gnu.org; 26 Aug 2021 06:59:11 +0000 Received: from localhost ([127.0.0.1]:48258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJ9Ly-0000th-Se for submit@debbugs.gnu.org; Thu, 26 Aug 2021 02:59:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:60222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJ9Lv-0000tX-MV for submit@debbugs.gnu.org; Thu, 26 Aug 2021 02:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJ9Lv-0003Re-5Q for guix-patches@gnu.org; Thu, 26 Aug 2021 02:59:07 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:42912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJ9Ls-0004LB-Vr for guix-patches@gnu.org; Thu, 26 Aug 2021 02:59:06 -0400 Received: by mail-lj1-x22b.google.com with SMTP id h1so3233160ljl.9 for ; Wed, 25 Aug 2021 23:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=lpore3BqW/kYSGHygM+p5rde5zecCbH4eBzFAyONhgg=; b=MtBAz++oKtHZPsT+CkgMiDHB9vJMEmc89Xks4msQDkA8R6K0p6qhPhF3nDNCqHZRhX DF6TJRS+IWV62nBBc3hLVB7lZ4tGN1jVgt/zz0fxsU1XYtCiwyJRrsZwQy1R0bhaOncH Qe/+JN8EfBkLEPoFRzWbh4BUq5vgixxvp2HIOp91+Djmnif0e4N9NAlOIzYfhARIsCk8 h8RSB14PlyB1O4QeSC+R02ivCm5r1HHd1qoxSQ7xOqxTF1kQtDYUaHVDNbw2rdxRSi+Q +/pV8FkzY6Hg+yaGf6dXcx9sf7zIUX93ybPwFK7z0wjo48K3YRJcwhLLdWFZgJFcakt9 lteg== 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:date:message-id:mime-version; bh=lpore3BqW/kYSGHygM+p5rde5zecCbH4eBzFAyONhgg=; b=iUP7mS8ckgAlomHzEOCP/hxGH3elSTgTOI8Oy3aGZHfbQVvOwjbyqTDyEve9IiS/CK ced7y4z9/6RM6iOLri78bax5ViVSamR354djjZeRCtNAyJ8AbkkQjJ498WCLWORSkMJl gX9gFnK/NEoTAZ69Shnibu+TO85Fz0YTnlsKF3nr0Xkr6jR8Dw/WDcNh8dpbL3K3vov+ 1pfmns/cMJvY2YVtbJBXrfo+LScTjDmfbK90ZWj6UNdALVSmzXsVekQC8M8a4w7axsdU I7H7s7TsqEGo1vDUlUM4NJYOrSvdHj+AL8OzmDBuSCFRukruwhOkXuseT/AI4X09yAck fJiw== X-Gm-Message-State: AOAM532mxWJYQ4UTYaDbdAbKop0H0qNNI4tYwamvM0My3ncK9e43fbtT aPMU1JZAAVDrjvjsdAsWE35hK59sSDvIhw== X-Google-Smtp-Source: ABdhPJwj6ZJ/k4UT1qKrLaiWzg6yGRJHSd+8nj1soB8Ki1ttIaNO4gXrAgSoIjZ+C9yH2gv5i8D/bQ== X-Received: by 2002:a2e:9e05:: with SMTP id e5mr1777206ljk.166.1629961142044; Wed, 25 Aug 2021 23:59:02 -0700 (PDT) Received: from localhost ([109.252.93.92]) by smtp.gmail.com with ESMTPSA id r193sm226247lff.187.2021.08.25.23.59.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 23:59:01 -0700 (PDT) From: Andrew Tropin To: guix-patches@gnu.org Subject: [PATCH] home-services: Add symlink-manager Date: Thu, 26 Aug 2021 09:39:38 +0300 Message-ID: <87bl5kbsk8.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: none client-ip=2a00:1450:4864:20::22b; envelope-from=andrew@trop.in; helo=mail-lj1-x22b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =2D-- This patch is targeted against wip-guix-home branch. It's not a part of any patch series to make sure it will get enough attenti= on, because it's most unpure part of the Guix Home and operates on user's files. gnu/home-services/symlink-manager.scm | 248 ++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 gnu/home-services/symlink-manager.scm diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/syml= ink-manager.scm new file mode 100644 index 0000000000..f13c9f4dbe =2D-- /dev/null +++ b/gnu/home-services/symlink-manager.scm @@ -0,0 +1,248 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 symlink-manager) + #:use-module (gnu home-services) + #:use-module (guix gexp) + + #:export (home-symlink-manager-service-type)) + +;;; Comment: +;;; +;;; symlink-manager cares about configuration files: it backups files +;;; created by user, removes symlinks and directories created by +;;; previous generation, and creates new directories and symlinks to +;;; configs according to content of files/ directory of current home +;;; environment generation (created by home-files-service). +;;; +;;; Code: + +(define (update-symlinks-script) + (program-file + "update-symlinks" + #~(begin + (use-modules (ice-9 ftw) + (ice-9 curried-definitions) + (ice-9 match) + (srfi srfi-1)) + (define ((simplify-file-tree parent) file) + "Convert the result produced by `file-system-tree' to less +verbose and more suitable for further processing format. + +Extract dir/file info from stat and compose a relative path to the +root of the file tree. + +Sample output: + +((dir . \".\") + ((dir . \"config\") + ((dir . \"config/fontconfig\") + (file . \"config/fontconfig/fonts.conf\")) + ((dir . \"config/isync\") + (file . \"config/isync/mbsyncrc\")))) +" + (match file + ((name stat) `(file . ,(string-append parent name))) + ((name stat children ...) + (cons `(dir . ,(string-append parent name)) + (map (simplify-file-tree + (if (equal? name ".") + "" + (string-append parent name "/"))) + children))))) + + (define ((file-tree-traverse preordering) node) + "Traverses the file tree in different orders, depending on PREORDERING. + +if PREORDERING is @code{#t} resulting list will contain folders before +files located in those folders, otherwise folders will appear only +after all nested items already listed." + (let ((prepend (lambda (a b) (append b a)))) + (match node + (('file . path) (list node)) + ((('dir . path) . rest) + ((if preordering append prepend) + (list (cons 'dir path)) + (append-map (file-tree-traverse preordering) rest)))))) + + (use-modules (guix build utils)) + + (let* ((he-path (string-append (getenv "HOME") "/.guix-home")) + (new-he-tmp-path (string-append he-path ".new")) + (new-home (getenv "GUIX_NEW_HOME"))) + (symlink new-home new-he-tmp-path) + (rename-file new-he-tmp-path he-path)) + + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.config"))) + + (he-path (string-append (getenv "HOME") "/.guix-home")) + (new-he-tmp-path (string-append he-path ".new")) + + (files-path (string-append he-path "/files")) + ;; Leading dot is required, because files itself is symlink and + ;; to make file-system-tree works it should be a directory. + (files-dir-path (string-append files-path "/.")) + (new-files-path (string-append new-he-tmp-path "/files")) + (new-files-dir-path (string-append files-path "/.")) + + (home-path (getenv "HOME")) + (backup-dir (string-append home-path "/" + (number->string (current-time)) + "-guix-home-legacy-configs-backup")) + + (old-tree (if (file-exists? files-dir-path) + ((simplify-file-tree "") + (file-system-tree files-dir-path)) + #f)) + (new-tree ((simplify-file-tree "") + (file-system-tree new-files-dir-path))) + + (get-source-path + (lambda (path) + (readlink (string-append files-path "/" path)))) + + (get-target-path + (lambda (path) + (string-append home-path "/." path))) + + (get-backup-path + (lambda (path) + (string-append backup-dir "/." path))) + + (directory? + (lambda (path) + (equal? (stat:type (stat path)) 'directory))) + + (empty-directory? + (lambda (dir) + (equal? (scandir dir) '("." "..")))) + + (symlink-to-store? + (lambda (path) + (and + (equal? (stat:type (lstat path)) 'symlink) + (store-file-name? (readlink path))))) + + (backup-file + (lambda (path) + (mkdir-p backup-dir) + (format #t "Backing up ~a..." (get-target-path path)) + (mkdir-p (dirname (get-backup-path path))) + (rename-file (get-target-path path) (get-backup-path path)) + (display " done\n"))) + + (cleanup-symlinks + (lambda () + (let ((to-delete ((file-tree-traverse #f) old-tree))) + (display + "Cleaning up symlinks from previous home-environment.\n\n") + (map + (match-lambda + (('dir . ".") + (display "Cleanup finished.\n\n")) + + (('dir . path) + (if (and + (file-exists? (get-target-path path)) + (directory? (get-target-path path)) + (empty-directory? (get-target-path path))) + (begin + (format #t "Removing ~a..." + (get-target-path path)) + (rmdir (get-target-path path)) + (display " done\n")) + (format + #t "Skipping ~a (not an empty directory)... done\n" + (get-target-path path)))) + + (('file . path) + (when (file-exists? (get-target-path path)) + ;; DO NOT remove the file if it was modified + ;; by user (not a symlink to the /gnu/store + ;; anymore) it will be backed up later during + ;; create-symlinks phase. + (if (symlink-to-store? (get-target-path path)) + (begin + (format #t "Removing ~a..." (get-target-path path)) + (delete-file (get-target-path path)) + (display " done\n")) + (format + #t + "Skipping ~a (not a symlink to store)... done\n" + (get-target-path path)))))) + to-delete)))) + + (create-symlinks + (lambda () + (let ((to-create ((file-tree-traverse #t) new-tree))) + (map + (match-lambda + (('dir . ".") + (display + "New symlinks to home-environment will be created soon.\n") + (format + #t "All conflicting files will go to ~a.\n\n" backup-dir)) + + (('dir . path) + (let ((target-path (get-target-path path))) + (when (and (file-exists? target-path) + (not (directory? target-path))) + (backup-file path)) + + (if (file-exists? target-path) + (format + #t "Skipping ~a (directory already exists)... done\n" + target-path) + (begin + (format #t "Creating ~a..." target-path) + (mkdir target-path) + (display " done\n"))))) + + (('file . path) + (when (file-exists? (get-target-path path)) + (backup-file path)) + (format #t "Symlinking ~a -> ~a..." + (get-target-path path) (get-source-path path)) + (symlink (get-source-path path) (get-target-path path)) + (display " done\n"))) + to-create))))) + + (when old-tree + (cleanup-symlinks)) + + (create-symlinks) + + (display " done\nFinished updating symlinks.\n\n"))))) + + +(define (update-symlinks-gexp _) + #~(primitive-load #$(update-symlinks-script))) + +(define home-symlink-manager-service-type + (service-type (name 'home-symlink-manager) + (extensions + (list + (service-extension + home-activation-service-type + update-symlinks-gexp))) + (default-value #f) + (description "Provide an @code{update-symlinks} +script, which create and remove symlinks on every activation. If the +target is occupied by a file created by user, back it up."))) =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEnO6cPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wy8QQAICPi55NlYod4+OKRJJTrzqpNzWeIBdzbzlu 6Jh9f3+eKhY4FJhDaO6Os8+FOMDUZOwbt2XLQiJuJIsHaTtzfoSAaL1eTTHtcOdp uyjBnTVvqfhjj3C6Zu9YQYWlKfAkxmQLmTNoU51J1QcaqKi3Xz8N/usvVQFIQZhr Z9zvK7bSv2UNhudxmJmG2cBNv1t3ZW1SrRzk5WgLnGG4itYgzD7+sE5HZh5LszIx byTQOJ2Xd8D/C4+pXTXU+i8Yfxxcontux0wDUuaGTA6RGIyy02ccDb4mEMTsUocV qlX81hN8dH37cADH5qfAQKAQPUdglMrf4P+SOuctpFpLSYT00gV8XRTpa1WKXZej wbYJmdVJFZ22YP5Ix5QS22PrqluULnngN+q0K5dPwW7rek/g6vXeNDcuzQXLpg7q QYgOziPXKcnstFSVJn0v7s9/NQCYumOs2I8lK1lkHKSRrqZtuLsh1mXb2kthE2Bp e8CNVeUjMxm8zH/mnpEntsh6Bvp9NRNtSkaV8Lbd3yQypJ4ngbzfaRsWLKY2+qGu axoqz9R6RqziCeK/6LzlQl7Ciur2RBZzO/YpkWYoPTFql6UXbp15cwrWLnNgy4Zw j6CfuJCHiLdOxuQ2akERbb1X440r7KCkWZTAzehJUfmKYV5hjhNjJsUSqPSZSXb4 S2ZW7JUz =Td/5 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 26 06:58:52 2021 Received: (at 50208) by debbugs.gnu.org; 26 Aug 2021 10:58:52 +0000 Received: from localhost ([127.0.0.1]:48482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJD5v-0000oA-Kq for submit@debbugs.gnu.org; Thu, 26 Aug 2021 06:58:52 -0400 Received: from mail-lf1-f50.google.com ([209.85.167.50]:33583) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJD5r-0000nt-IX for 50208@debbugs.gnu.org; Thu, 26 Aug 2021 06:58:50 -0400 Received: by mail-lf1-f50.google.com with SMTP id p38so6062488lfa.0 for <50208@debbugs.gnu.org>; Thu, 26 Aug 2021 03:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=nNPvqS6wAdcNIUfBSWSmXIyAVMzV2aQa3UBP686KD1w=; b=nFzW0k+iewNWYbdsYXLhP6+qV5BoW86n3UVg5Q2KAEmj6LuIOSL0bO8JTmbPNX2jpX yGg3FSLMFkgWw6zzBPV60eGupZRaX4KhSLHqkVyWu26M7vmfKcQhtzM66ZScZ9oU6kFm liqHNmT9Qyy7GVJ77wk2J5YP+PxjloDKe8KMIMGhntus7rhLHXfrA2doXuDGR56iaPI8 c6XN1bp0JSns4YMEcnpINrIsKvmjzsZO9AayRQhn7V4h4OYRqcZ1cJPC3fSq/bK823mf RbDREbgpcQJICaeWFJD92357sPY5VHcpJ/0+2cad53u/NOM8KeGRaACZ7p9TwUHxLXqp 9LwQ== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=nNPvqS6wAdcNIUfBSWSmXIyAVMzV2aQa3UBP686KD1w=; b=MNKOPccLBkJwjpGuAUHDpVhzCy9gIvQWXgkXaz8EBKdNmkWlSjlI+2j7hFw4ClXCxV BYg01kI3pEqEKnTCnMBR7dDyxCRHAtHxHvcQgjvJfUtZwfP3yN0NxEBDG1y72TZntOTr 6IrCL/l8eSD2/SwPY4ErS0pTYfx23OKT7tHb2mtX9EQh0WDww7sfcicQxw0dxgsZaS++ Ipg6g6lqnW5L+/tXSiy145eJ4gmYytBhIc45N87yNOU04tcfCaPnJFAFXVtX67CmzTPI NYgMEiGm3mPkypiYKXHX/RKB57YOqqVZhguL3MAeXOnzOU0SqQ9MCdfjaBhEUUtKurtw sC+A== X-Gm-Message-State: AOAM532ggPTyJnrbPscfe/TfXVng8QVDJEisqJ0zAekLnna51491d1a+ uUBlFOyjKipd+x+56KXs4T3OkcRder4= X-Google-Smtp-Source: ABdhPJzJo3/YeTZq4Sh8PLEO0v6qgJe6QwTCaD6hUxNvY+pA7LNxQ2AmRARIE01J+oG+R6Izpm6h1w== X-Received: by 2002:ac2:44dc:: with SMTP id d28mr2390825lfm.246.1629975520883; Thu, 26 Aug 2021 03:58:40 -0700 (PDT) Received: from guixsd ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id u2sm304879lji.82.2021.08.26.03.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 03:58:39 -0700 (PDT) From: Oleg Pykhalov To: Andrew Tropin Subject: Re: [bug#50208] [PATCH] home-services: Add symlink-manager References: <87bl5kbsk8.fsf@trop.in> Date: Thu, 26 Aug 2021 13:58:37 +0300 In-Reply-To: <87bl5kbsk8.fsf@trop.in> (Andrew Tropin's message of "Thu, 26 Aug 2021 09:39:38 +0300") Message-ID: <87r1eg8obm.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: Hi Andrew, Andrew Tropin writes: > --- > This patch is targeted against wip-guix-home branch. > > It's not a part of any patch series to make sure it will get enough attention, > because it's most unpure part of the Guix Home and ope [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (go.wigust[at]gmail.com) 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.50 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.50 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Andrew, Andrew Tropin writes: > --- > This patch is targeted against wip-guix-home branch. > > It's not a part of any patch series to make sure it will get enough atten= tion, > because it's most unpure part of the Guix Home and operates on user's fil= es. > > gnu/home-services/symlink-manager.scm | 248 ++++++++++++++++++++++++++ > 1 file changed, 248 insertions(+) > create mode 100644 gnu/home-services/symlink-manager.scm > [=E2=80=A6] I applied your patch, replaces tabs with spaces, modified commit message according to GNU standards, added the file to gnu/local.mk for compilation (I forgot to do it for previous patch series, apologies). I would like to squash the patch for home-services.scm with a previous series (hope force push will work), but I should ask you could I do it? Otherwise I could just push two patches to wip-guix-home. Updated patches are attached below. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-gnu-Compile-home-services.patch Content-Transfer-Encoding: quoted-printable From=2099f1b412fd76d9813dccc96cf30a943375d0d5a8 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 26 Aug 2021 13:18:54 +0300 Subject: [PATCH 1/2] gnu: Compile home-services. This commit follows b784de19. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services.scm. =2D-- gnu/local.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/gnu/local.mk b/gnu/local.mk index 14cd1cc6ad..bd3aed77e8 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -72,6 +72,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/bootloader/u-boot.scm \ %D%/bootloader/depthcharge.scm \ %D%/ci.scm \ + %D%/home-services.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.32.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0002-home-services-Add-symlink-manager.patch Content-Transfer-Encoding: quoted-printable From=208938342edec4dda6ff2b7b5d47f63809bb309084 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Thu, 26 Aug 2021 09:39:38 +0300 Subject: [PATCH 2/2] home-services: Add symlink-manager. * gnu/home-services/symlink-manager.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add this. Signed-off-by: Oleg Pykhalov =2D-- gnu/home-services/symlink-manager.scm | 247 ++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 248 insertions(+) create mode 100644 gnu/home-services/symlink-manager.scm diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/syml= ink-manager.scm new file mode 100644 index 0000000000..47fee8db3b =2D-- /dev/null +++ b/gnu/home-services/symlink-manager.scm @@ -0,0 +1,247 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 symlink-manager) + #:use-module (gnu home-services) + #:use-module (guix gexp) + #:export (home-symlink-manager-service-type)) + +;;; Comment: +;;; +;;; symlink-manager cares about configuration files: it backups files +;;; created by user, removes symlinks and directories created by +;;; previous generation, and creates new directories and symlinks to +;;; configs according to content of files/ directory of current home +;;; environment generation (created by home-files-service). +;;; +;;; Code: + +(define (update-symlinks-script) + (program-file + "update-symlinks" + #~(begin + (use-modules (ice-9 ftw) + (ice-9 curried-definitions) + (ice-9 match) + (srfi srfi-1)) + (define ((simplify-file-tree parent) file) + "Convert the result produced by `file-system-tree' to less +verbose and more suitable for further processing format. + +Extract dir/file info from stat and compose a relative path to the +root of the file tree. + +Sample output: + +((dir . \".\") + ((dir . \"config\") + ((dir . \"config/fontconfig\") + (file . \"config/fontconfig/fonts.conf\")) + ((dir . \"config/isync\") + (file . \"config/isync/mbsyncrc\")))) +" + (match file + ((name stat) `(file . ,(string-append parent name))) + ((name stat children ...) + (cons `(dir . ,(string-append parent name)) + (map (simplify-file-tree + (if (equal? name ".") + "" + (string-append parent name "/"))) + children))))) + + (define ((file-tree-traverse preordering) node) + "Traverses the file tree in different orders, depending on PREORD= ERING. + +if PREORDERING is @code{#t} resulting list will contain folders before +files located in those folders, otherwise folders will appear only +after all nested items already listed." + (let ((prepend (lambda (a b) (append b a)))) + (match node + (('file . path) (list node)) + ((('dir . path) . rest) + ((if preordering append prepend) + (list (cons 'dir path)) + (append-map (file-tree-traverse preordering) rest)))))) + + (use-modules (guix build utils)) + + (let* ((he-path (string-append (getenv "HOME") "/.guix-home")) + (new-he-tmp-path (string-append he-path ".new")) + (new-home (getenv "GUIX_NEW_HOME"))) + (symlink new-home new-he-tmp-path) + (rename-file new-he-tmp-path he-path)) + + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.config= "))) + + (he-path (string-append (getenv "HOME") "/.guix-home")) + (new-he-tmp-path (string-append he-path ".new")) + + (files-path (string-append he-path "/files")) + ;; Leading dot is required, because files itself is symlink = and + ;; to make file-system-tree works it should be a directory. + (files-dir-path (string-append files-path "/.")) + (new-files-path (string-append new-he-tmp-path "/files")) + (new-files-dir-path (string-append files-path "/.")) + + (home-path (getenv "HOME")) + (backup-dir (string-append home-path "/" + (number->string (current-time)) + "-guix-home-legacy-configs-backup= ")) + + (old-tree (if (file-exists? files-dir-path) + ((simplify-file-tree "") + (file-system-tree files-dir-path)) + #f)) + (new-tree ((simplify-file-tree "") + (file-system-tree new-files-dir-path))) + + (get-source-path + (lambda (path) + (readlink (string-append files-path "/" path)))) + + (get-target-path + (lambda (path) + (string-append home-path "/." path))) + + (get-backup-path + (lambda (path) + (string-append backup-dir "/." path))) + + (directory? + (lambda (path) + (equal? (stat:type (stat path)) 'directory))) + + (empty-directory? + (lambda (dir) + (equal? (scandir dir) '("." "..")))) + + (symlink-to-store? + (lambda (path) + (and + (equal? (stat:type (lstat path)) 'symlink) + (store-file-name? (readlink path))))) + + (backup-file + (lambda (path) + (mkdir-p backup-dir) + (format #t "Backing up ~a..." (get-target-path path)) + (mkdir-p (dirname (get-backup-path path))) + (rename-file (get-target-path path) (get-backup-path path= )) + (display " done\n"))) + + (cleanup-symlinks + (lambda () + (let ((to-delete ((file-tree-traverse #f) old-tree))) + (display + "Cleaning up symlinks from previous home-environment.\= n\n") + (map + (match-lambda + (('dir . ".") + (display "Cleanup finished.\n\n")) + + (('dir . path) + (if (and + (file-exists? (get-target-path path)) + (directory? (get-target-path path)) + (empty-directory? (get-target-path path))) + (begin + (format #t "Removing ~a..." + (get-target-path path)) + (rmdir (get-target-path path)) + (display " done\n")) + (format + #t "Skipping ~a (not an empty directory)... do= ne\n" + (get-target-path path)))) + + (('file . path) + (when (file-exists? (get-target-path path)) + ;; DO NOT remove the file if it was modified + ;; by user (not a symlink to the /gnu/store + ;; anymore) it will be backed up later during + ;; create-symlinks phase. + (if (symlink-to-store? (get-target-path path)) + (begin + (format #t "Removing ~a..." (get-target-pat= h path)) + (delete-file (get-target-path path)) + (display " done\n")) + (format + #t + "Skipping ~a (not a symlink to store)... don= e\n" + (get-target-path path)))))) + to-delete)))) + + (create-symlinks + (lambda () + (let ((to-create ((file-tree-traverse #t) new-tree))) + (map + (match-lambda + (('dir . ".") + (display + "New symlinks to home-environment will be created = soon.\n") + (format + #t "All conflicting files will go to ~a.\n\n" back= up-dir)) + + (('dir . path) + (let ((target-path (get-target-path path))) + (when (and (file-exists? target-path) + (not (directory? target-path))) + (backup-file path)) + + (if (file-exists? target-path) + (format + #t "Skipping ~a (directory already exists)= ... done\n" + target-path) + (begin + (format #t "Creating ~a..." target-path) + (mkdir target-path) + (display " done\n"))))) + + (('file . path) + (when (file-exists? (get-target-path path)) + (backup-file path)) + (format #t "Symlinking ~a -> ~a..." + (get-target-path path) (get-source-path pat= h)) + (symlink (get-source-path path) (get-target-path pa= th)) + (display " done\n"))) + to-create))))) + + (when old-tree + (cleanup-symlinks)) + + (create-symlinks) + + (display " done\nFinished updating symlinks.\n\n"))))) + + +(define (update-symlinks-gexp _) + #~(primitive-load #$(update-symlinks-script))) + +(define home-symlink-manager-service-type + (service-type (name 'home-symlink-manager) + (extensions + (list + (service-extension + home-activation-service-type + update-symlinks-gexp))) + (default-value #f) + (description "Provide an @code{update-symlinks} +script, which create and remove symlinks on every activation. If the +target is occupied by a file created by user, back it up."))) diff --git a/gnu/local.mk b/gnu/local.mk index bd3aed77e8..91c3b0da3d 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -73,6 +73,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/bootloader/depthcharge.scm \ %D%/ci.scm \ %D%/home-services.scm \ + %D%/home-services/symlink-manager.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.32.0 --=-=-= Content-Type: text/plain Oleg. --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEnc90UHGdvLndpZ3Vz dEBnbWFpbC5jb20ACgkQFn+OpQAa+pzy+hAApLF5W6wXdnWEntQAu8Qxa6NEeu5+ IPMd7W/i/WnUaON2N5uyLjHS+k2INLz7bPZCtEkJXMMV9eOPgb0g9GuwHvnjOmjj DdUIkDxInn1wVyDkyg5ca0BK5DEo/y+N9LfXQKhLfr5Tg25LTerxXcYBrtCqNJSI TqgkTu/E8zcwwwZgcSkLHf3ebnIhvhW86/ErP8plFe1zUZo3SU2s5PBJ3FEjyCga JbGXdBanxEzHqDYBiDTn0/ADwy41qJhnxzwc1J/jZHo08xtuw3VMqGd04tPGQtVg ohoRQZNj39tTlXZTfm+Zxc2zuBInESc90iR2FrD3be1YnFypCSTj3ipFmArC26Ze YbMK4HWb3mUGn8Oip+ufJBEbr8+x3L90e8bTMfTVHz0IXf0XjDHewpWuCiDa5FY8 zFGaO3cyVDnAOXebQ1yugDwU0u8Z7v2Ciuk3Bn6qwt9uAy/52KiWkxh9BJpoJPLS XvxlyLWnHg7FsiQgA4x+I/3Q75HkZ0e/dQAiKei31L2deUtTSEi6Pzn0QPvCQEBt 2SWEbqAuqWvyWmBjeOGFjardw9JC6+1l56XnAZ7FEsSqtnmqPbtBQcPBCGqSLxuA YhDvX3sLEJDK6xXV06z6EGwWfRgoZTm9HV1rqa4x6ZMj0vZuPKviSYWCTS3/m/ks 9zjiWST/yhsutSQ= =pGCs -----END PGP SIGNATURE----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 00:33:52 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 04:33:52 +0000 Received: from localhost ([127.0.0.1]:51004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJTYt-0007NG-Ui for submit@debbugs.gnu.org; Fri, 27 Aug 2021 00:33:52 -0400 Received: from mail-lf1-f52.google.com ([209.85.167.52]:35459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJTYr-0007Mq-KL for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 00:33:51 -0400 Received: by mail-lf1-f52.google.com with SMTP id l2so3594598lfp.2 for <50208@debbugs.gnu.org>; Thu, 26 Aug 2021 21:33:49 -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=T76qf50hJAHVB2rM5sp6gToOymALr/ROBduf/R40+xA=; b=apX4MNM2B1428shfGMSPIaPTZHpTVPvygMuz7p+eSzT28di3iuVcWYOV4dowX9aesB +Bew+4VeGn/mNlE4Aitp0CfVGxJ00LjZT/Yex3XG9jJAuqHIk9vH/GDnEu/14QhiR4WE 8c49293r2YBxAsyiAXkAplDp5tOOigVKqPchOhV5a5ANPWpFT/755MzAIE2u/lBgry+a wk7T99VmQCYNkI7QjqOcOton5v8BpnQlbrdfM56QvG5GEZGg3tPfmg5EbCeT458Q4hpC 1G/jQlro1730g+ZxYHjHTHOKaZ0wk15fOyRz8F/WXPJ9kHl3G1lZejP180krUZZzH3+L ubQg== 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=T76qf50hJAHVB2rM5sp6gToOymALr/ROBduf/R40+xA=; b=UWwH7/ykUY0I2Ns66lW/HxcAqOXKahv5Kyhv5GK1ts69S/yixN5OR0oD0KfkuT4aio 3VmMD/rvS4BkzDjk5MXRMp345+UYvsKAh7+0REdBjuXhIZXwQKNyp27omk7IA5HNDrGL YyvEqLQyIlHERf59p+3ea8DT/7DamsEUcPQdQ+4JLJpDXBt4JfcnNRUTcfjk22AIRFua QMo39If9oBpYfRFcznPh4szOQ/nZaDY8VyfEHAP0U66jH/c3/2YLtGxfOH8TYYA5uD48 a6Daqri3jLTfrJQ13TiA9FzF5we7f5DryWDYlBRkXN0XFDIbrweycK6xaX3AzYwk04zQ gbxQ== X-Gm-Message-State: AOAM531Zh6n/MxpCv1ZS52CZlCBetrrrDZv0zgPBIgbkgZmmdMILS1iN JkhpjVHVpn7x4UgxuWhA2PLZsA== X-Google-Smtp-Source: ABdhPJzpH4bcE8G2aVpgGFN5Rn2ZZKyg72VDpyDgmVBgQmtZ9TXC6uMk24vfCK9qGI9kHPF4qQx/Ww== X-Received: by 2002:a19:c107:: with SMTP id r7mr5251872lff.29.1630038823548; Thu, 26 Aug 2021 21:33:43 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id o4sm359369lfi.186.2021.08.26.21.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 21:33:42 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: Re: [bug#50208] [PATCH] home-services: Add symlink-manager In-Reply-To: <87r1eg8obm.fsf@gmail.com> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> Date: Fri, 27 Aug 2021 07:31:24 +0300 Message-ID: <87k0k7fqzn.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: On 2021-08-26 13:58, Oleg Pykhalov wrote: > Hi Andrew, > > Andrew Tropin writes: > >> --- >> This patch is targeted against wip-guix-home branch. >> >> It's not a part of any patch series to make sure it will get enough atten [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.52 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.52 listed in list.dnswl.org] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-26 13:58, Oleg Pykhalov wrote: > Hi Andrew, > > Andrew Tropin writes: > >> --- >> This patch is targeted against wip-guix-home branch. >> >> It's not a part of any patch series to make sure it will get enough atte= ntion, >> because it's most unpure part of the Guix Home and operates on user's fi= les. >> >> gnu/home-services/symlink-manager.scm | 248 ++++++++++++++++++++++++++ >> 1 file changed, 248 insertions(+) >> create mode 100644 gnu/home-services/symlink-manager.scm >> > > [=E2=80=A6] > > I applied your patch, replaces tabs with spaces, modified commit message > according to GNU standards, added the file to gnu/local.mk for > compilation (I forgot to do it for previous patch series, apologies). > Thank you! > > > I would like to squash the patch for home-services.scm with a previous > series (hope force push will work), but I should ask you could I do it? > Otherwise I could just push two patches to wip-guix-home. > Yes, squash works for me. >=20 > Updated patches are attached below. > > From 99f1b412fd76d9813dccc96cf30a943375d0d5a8 Mon Sep 17 00:00:00 2001 > From: Oleg Pykhalov > Date: Thu, 26 Aug 2021 13:18:54 +0300 > Subject: [PATCH 1/2] gnu: Compile home-services. > > This commit follows b784de19. > > * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services.scm. > --- > gnu/local.mk | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gnu/local.mk b/gnu/local.mk > index 14cd1cc6ad..bd3aed77e8 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -72,6 +72,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/bootloader/u-boot.scm \ > %D%/bootloader/depthcharge.scm \ > %D%/ci.scm \ > + %D%/home-services.scm \ > %D%/image.scm \ > %D%/packages.scm \ > %D%/packages/abduco.scm \ > --=20 > 2.32.0 > > From 8938342edec4dda6ff2b7b5d47f63809bb309084 Mon Sep 17 00:00:00 2001 > From: Andrew Tropin > Date: Thu, 26 Aug 2021 09:39:38 +0300 > Subject: [PATCH 2/2] home-services: Add symlink-manager. > > * gnu/home-services/symlink-manager.scm: New file. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add this. > > Signed-off-by: Oleg Pykhalov > --- > gnu/home-services/symlink-manager.scm | 247 ++++++++++++++++++++++++++ > gnu/local.mk | 1 + > 2 files changed, 248 insertions(+) > create mode 100644 gnu/home-services/symlink-manager.scm > > diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/sy= mlink-manager.scm > new file mode 100644 > index 0000000000..47fee8db3b > --- /dev/null > +++ b/gnu/home-services/symlink-manager.scm > @@ -0,0 +1,247 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2021 Andrew Tropin > +;;; Copyright =C2=A9 2021 Xinglu Chen > +;;; > +;;; 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 symlink-manager) > + #:use-module (gnu home-services) > + #:use-module (guix gexp) > + #:export (home-symlink-manager-service-type)) > + > +;;; Comment: > +;;; > +;;; symlink-manager cares about configuration files: it backups files > +;;; created by user, removes symlinks and directories created by > +;;; previous generation, and creates new directories and symlinks to > +;;; configs according to content of files/ directory of current home > +;;; environment generation (created by home-files-service). > +;;; > +;;; Code: > + > +(define (update-symlinks-script) > + (program-file > + "update-symlinks" > + #~(begin > + (use-modules (ice-9 ftw) > + (ice-9 curried-definitions) > + (ice-9 match) > + (srfi srfi-1)) > + (define ((simplify-file-tree parent) file) > + "Convert the result produced by `file-system-tree' to less > +verbose and more suitable for further processing format. > + > +Extract dir/file info from stat and compose a relative path to the > +root of the file tree. > + > +Sample output: > + > +((dir . \".\") > + ((dir . \"config\") > + ((dir . \"config/fontconfig\") > + (file . \"config/fontconfig/fonts.conf\")) > + ((dir . \"config/isync\") > + (file . \"config/isync/mbsyncrc\")))) > +" > + (match file > + ((name stat) `(file . ,(string-append parent name))) > + ((name stat children ...) > + (cons `(dir . ,(string-append parent name)) > + (map (simplify-file-tree > + (if (equal? name ".") > + "" > + (string-append parent name "/"))) > + children))))) > + > + (define ((file-tree-traverse preordering) node) > + "Traverses the file tree in different orders, depending on PREO= RDERING. > + > +if PREORDERING is @code{#t} resulting list will contain folders before > +files located in those folders, otherwise folders will appear only > +after all nested items already listed." > + (let ((prepend (lambda (a b) (append b a)))) > + (match node > + (('file . path) (list node)) > + ((('dir . path) . rest) > + ((if preordering append prepend) > + (list (cons 'dir path)) > + (append-map (file-tree-traverse preordering) rest)))))) > + > + (use-modules (guix build utils)) > + > + (let* ((he-path (string-append (getenv "HOME") "/.guix-home")) > + (new-he-tmp-path (string-append he-path ".new")) > + (new-home (getenv "GUIX_NEW_HOME"))) > + (symlink new-home new-he-tmp-path) > + (rename-file new-he-tmp-path he-path)) > + > + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") > + (string-append (getenv "HOME") "/.conf= ig"))) > + > + (he-path (string-append (getenv "HOME") "/.guix-home")) > + (new-he-tmp-path (string-append he-path ".new")) > + > + (files-path (string-append he-path "/files")) > + ;; Leading dot is required, because files itself is symlin= k and > + ;; to make file-system-tree works it should be a directory. > + (files-dir-path (string-append files-path "/.")) > + (new-files-path (string-append new-he-tmp-path "/files")) > + (new-files-dir-path (string-append files-path "/.")) > + > + (home-path (getenv "HOME")) > + (backup-dir (string-append home-path "/" > + (number->string (current-time)) > + "-guix-home-legacy-configs-back= up")) > + > + (old-tree (if (file-exists? files-dir-path) > + ((simplify-file-tree "") > + (file-system-tree files-dir-path)) > + #f)) > + (new-tree ((simplify-file-tree "") > + (file-system-tree new-files-dir-path))) > + > + (get-source-path > + (lambda (path) > + (readlink (string-append files-path "/" path)))) > + > + (get-target-path > + (lambda (path) > + (string-append home-path "/." path))) > + > + (get-backup-path > + (lambda (path) > + (string-append backup-dir "/." path))) > + > + (directory? > + (lambda (path) > + (equal? (stat:type (stat path)) 'directory))) > + > + (empty-directory? > + (lambda (dir) > + (equal? (scandir dir) '("." "..")))) > + > + (symlink-to-store? > + (lambda (path) > + (and > + (equal? (stat:type (lstat path)) 'symlink) > + (store-file-name? (readlink path))))) > + > + (backup-file > + (lambda (path) > + (mkdir-p backup-dir) > + (format #t "Backing up ~a..." (get-target-path path)) > + (mkdir-p (dirname (get-backup-path path))) > + (rename-file (get-target-path path) (get-backup-path pa= th)) > + (display " done\n"))) > + > + (cleanup-symlinks > + (lambda () > + (let ((to-delete ((file-tree-traverse #f) old-tree))) > + (display > + "Cleaning up symlinks from previous home-environment= .\n\n") > + (map > + (match-lambda > + (('dir . ".") > + (display "Cleanup finished.\n\n")) > + > + (('dir . path) > + (if (and > + (file-exists? (get-target-path path)) > + (directory? (get-target-path path)) > + (empty-directory? (get-target-path path))) > + (begin > + (format #t "Removing ~a..." > + (get-target-path path)) > + (rmdir (get-target-path path)) > + (display " done\n")) > + (format > + #t "Skipping ~a (not an empty directory)... = done\n" > + (get-target-path path)))) > + > + (('file . path) > + (when (file-exists? (get-target-path path)) > + ;; DO NOT remove the file if it was modified > + ;; by user (not a symlink to the /gnu/store > + ;; anymore) it will be backed up later during > + ;; create-symlinks phase. > + (if (symlink-to-store? (get-target-path path)) > + (begin > + (format #t "Removing ~a..." (get-target-p= ath path)) > + (delete-file (get-target-path path)) > + (display " done\n")) > + (format > + #t > + "Skipping ~a (not a symlink to store)... d= one\n" > + (get-target-path path)))))) > + to-delete)))) > + > + (create-symlinks > + (lambda () > + (let ((to-create ((file-tree-traverse #t) new-tree))) > + (map > + (match-lambda > + (('dir . ".") > + (display > + "New symlinks to home-environment will be create= d soon.\n") > + (format > + #t "All conflicting files will go to ~a.\n\n" ba= ckup-dir)) > + > + (('dir . path) > + (let ((target-path (get-target-path path))) > + (when (and (file-exists? target-path) > + (not (directory? target-path))) > + (backup-file path)) > + > + (if (file-exists? target-path) > + (format > + #t "Skipping ~a (directory already exist= s)... done\n" > + target-path) > + (begin > + (format #t "Creating ~a..." target-path) > + (mkdir target-path) > + (display " done\n"))))) > + > + (('file . path) > + (when (file-exists? (get-target-path path)) > + (backup-file path)) > + (format #t "Symlinking ~a -> ~a..." > + (get-target-path path) (get-source-path p= ath)) > + (symlink (get-source-path path) (get-target-path = path)) > + (display " done\n"))) > + to-create))))) > + > + (when old-tree > + (cleanup-symlinks)) > + > + (create-symlinks) > + > + (display " done\nFinished updating symlinks.\n\n"))))) > + > + > +(define (update-symlinks-gexp _) > + #~(primitive-load #$(update-symlinks-script))) > + > +(define home-symlink-manager-service-type > + (service-type (name 'home-symlink-manager) > + (extensions > + (list > + (service-extension > + home-activation-service-type > + update-symlinks-gexp))) > + (default-value #f) > + (description "Provide an @code{update-symlinks} > +script, which create and remove symlinks on every activation. If the > +target is occupied by a file created by user, back it up."))) > diff --git a/gnu/local.mk b/gnu/local.mk > index bd3aed77e8..91c3b0da3d 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -73,6 +73,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/bootloader/depthcharge.scm \ > %D%/ci.scm \ > %D%/home-services.scm \ > + %D%/home-services/symlink-manager.scm \ > %D%/image.scm \ > %D%/packages.scm \ > %D%/packages/abduco.scm \ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEoap0PHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wIMUQAJV91sfCTBkpIkgem3U+nsy2sZPxhd4rxAo+ jEPmn5+rCE5KF+lZ7g6yKmYeWZKP4Z5vzC3u2xmeGhp0+W/Yh1lAwswXgMd6X7g6 SpXLSAoxE5C81VrkdED9h3dD/0cGZeHEg4tRUxGGuLE7p3A6cZe5R8yLNFq3Zw5M O9XInHNVBk2UKivZwFavMvlbt4tTjM8b5W3CtA1ysSl1mwTZY/RitwYkXb+85EMh FRyEgW9lnAjY+8qr4mlcm1jhRRND3MJ2Puyvh7H+hrIyiKcqBH7CPFlTzmhcXW3x Ry3NHS5m3qVH7cmKF1vh6IZWYT3NCxgvzpmRSV+SKePfoToPLVpt4PPOQbiJ5N91 ddOgcL6xrLUCU7nw1jvms+KU2b6p6q/hW8amvvA07HAW0FHdmyuZWNzVfuKYUOIz 9BhhClR8KXDovFQm+K5s+1LUM7x/VLN+6M2LuupT5hLF5MmhGFalsGdBkKIdE/VP wNCyZRsfI7/rQ0/PPeOyhpFa7GWmDztMavlDKbKWEg86QhK0dsk3YSrmUc5on99L RFeWa+xvm5TG3RtJbco0SpWS3R+A+aKHll09OhJLCUjb+ElSDxJWehni8m0bmn47 irE3ftR7XMlosCyy3CmH8xTb4auUrhpuoRHrwumhnZTyefhO9Mq87bbmEmD5ef99 UGVU5uOq =7B4U -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 02:49:37 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 06:49:38 +0000 Received: from localhost ([127.0.0.1]:51136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVgD-0004gh-S5 for submit@debbugs.gnu.org; Fri, 27 Aug 2021 02:49:37 -0400 Received: from mail-lj1-f181.google.com ([209.85.208.181]:44646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVg8-0004gQ-2D for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 02:49:32 -0400 Received: by mail-lj1-f181.google.com with SMTP id s3so9655659ljp.11 for <50208@debbugs.gnu.org>; Thu, 26 Aug 2021 23:49:27 -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=YopK3csMdkHMidDdLDN3z8nPR/f3AZFDP5o6ruECjRo=; b=jCQPZblN7q6Ql0FBEyFuE1t3qt3T4WE3Ny6ToJlcGLMawvNJioV5hBBXLHGGeMY7s6 WZevCoSaY2TDDmYEoHaAv3Dk5gYvCojOCytHm8SxB37vGjdRu3BqkMSCeU9caTy6xuZF gZlziZ89e5JDLEnxVKILBoLTa30alUk3vFgvQC7ya7f3szcymWeT1xvXYDHEL4DZFiHy dCuNSmR1BFObH4cE9txJuLC0Plj0V//mF4Tjl00bHKWZ5E2i+tuFYYX/5FO2BtVeRQ49 v4nLTSWPzePnFUPj6ETPxL5qruTV9gRCZNt5vNpBeGe7qmr0APLpmzAOCrGLg+/KBljG 2vWg== 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=YopK3csMdkHMidDdLDN3z8nPR/f3AZFDP5o6ruECjRo=; b=oSIHYgOl5zIpQgLDYh6DrpXT6UBJKr9gmWSACBwjkiK8Cn0jeb9484KAUfdb0dvKoV 6psn+DqR2Jdb7NrUDWe0NNrcsEAtfwMVpzbv93mb3tI5OcWSzaHLk1CfIx0D5Y5NwKg7 uP1Q6q8fBC8FFi3PIrCkbA1JA3qedt2+ID2Qr8f617j9To/acrTx9CuHEdBVsNLP5lkV j8ghqoBebQ3QPp++GHHRcAoxkM0xUGcTf6iyolxwc0A/B/UpAs/7cDjEWk97dxr9p5A8 8IMaftMr06RbePv7yvHzZWhkQCVku7OWu3DRn2q6o+E7OpY2+EPe2osBjVna5twEr12n IDOA== X-Gm-Message-State: AOAM532a2/9dvhGwKuL+oPvDa4jmwnjNqhb9yeah2jNlT3cEr/5Ziekv nA2MD2YKuChsm6obDHLtouJenA== X-Google-Smtp-Source: ABdhPJxlSBjh88yHkw3crdsrClA/w4l7HQI1qG5OP6euQtpkpRrk3SUY+3y3szrHUdwcdQ0wigQmBg== X-Received: by 2002:a2e:8808:: with SMTP id x8mr6522519ljh.220.1630046961800; Thu, 26 Aug 2021 23:49:21 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id a3sm579630ljj.122.2021.08.26.23.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 23:49:21 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 0/5] Add home-environment and related services In-Reply-To: <87r1eg8obm.fsf@gmail.com> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> Date: Fri, 27 Aug 2021 09:49:17 +0300 Message-ID: <871r6ffklu.fsf@trop.in> 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: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2021-08-26 13:58, Oleg Pykhalov wrote: > I applied your patch, replaces tabs with spaces, modified commit message > according to GNU standards, added the file to gnu/local.mk for > compilation (I forgot to do it for previous patch series, apologies). > > > I would like to squash the patch for home-services.scm with a previous > series (hope force push will work), but I should ask you could I do it? > Otherwise I could just push two patches to wip-guix-home. > > Updated patches are attached below. On top of the patches above I made a new patch series, which introduces home-environment and a set of default services, which are expected to be present in most Guix Home configurations. Andrew Tropin (5): home-services: Add fontutils. home-services: Add helper functions for service configurations. home-services: Add shells. home-services: Add xdg. home: Add home-environment. gnu/home-services/configuration.scm | 63 +++ gnu/home-services/fontutils.scm | 65 +++ gnu/home-services/shells.scm | 637 ++++++++++++++++++++++++++++ gnu/home-services/xdg.scm | 475 +++++++++++++++++++++ gnu/home.scm | 97 +++++ gnu/local.mk | 5 + 6 files changed, 1342 insertions(+) create mode 100644 gnu/home-services/configuration.scm create mode 100644 gnu/home-services/fontutils.scm create mode 100644 gnu/home-services/shells.scm create mode 100644 gnu/home-services/xdg.scm create mode 100644 gnu/home.scm =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEoiu0PHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wL/wP/2J1+8Ya8Z+oL1lElfilioUCKr4GyJgQ5TlM DPSONpDawn7/4DV4eXTQEASWhJAlz/rkQOv+Ffl896ZntZJ+Gd+t1ZkxPq926+iR B9uyH4TqJZobSClEv2zSMgCA7VbMjDYpPEgPrOe/PUUsTkZgwIKsFTZCMqqmjptF Qb0ZIrDpUHt1YlqdvQLNpdX6QFFCEp7mVyIilIvYjdgoBSk0/nfZ4rPc/GESdRJH EmgYJnQm6FMxugfPia+9EtjXBB7I/N1w+YGfJeeFoWq+OSGuc/AkQnKshvKi3YUb 2K5HxrHyDunp4HTe45uzrSTkaC2WZfm6IPDy6TADTSbqV5ZjN66QSnNnSVDW0vLy l++PI+weg6M0wlJw1DygDhSkCkS1seiMHN2LzVmEL+SKMNuNfpKKkgvmVxaWc8ot kiQUaWiTuYwYWt3d1QwyvMEj9kwWTU95Mi3qK/v6Ugw/pmdpTOjYM1qFH+pxyffv VZKzbmqH904pYzmasfJhCyMOSY0SZinyVpAp+ztdPzqOuVPyW4vkc9t+kgEGcpRO 8dxum5WiKZViQgZ6RrGmTLZnsAeknDHsoP43YVLIL7dWe2TLBnMZRUHYHZgjTRYm NJhpMXTqxsVytK7Q31CUb5Te8WhwrkbZ5Mkj6UBetdZ6+EENq9cHpNgJS6S2Wulw gLS667aL =+QZd -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 02:52:17 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 06:52:17 +0000 Received: from localhost ([127.0.0.1]:51144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVir-0004lI-Dc for submit@debbugs.gnu.org; Fri, 27 Aug 2021 02:52:17 -0400 Received: from mail-lf1-f53.google.com ([209.85.167.53]:39677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVio-0004l5-CZ for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 02:52:15 -0400 Received: by mail-lf1-f53.google.com with SMTP id m28so12291704lfj.6 for <50208@debbugs.gnu.org>; Thu, 26 Aug 2021 23:52:14 -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=eLyXhxJPmm/YYN4NQ4JRserX+J1vPnUR9sNXJxtgNN0=; b=YBuj/+m+A6fB1rvDENIGjOnqCpZ4caJPtQnB8malo3DJQLEamQvFPjK3jdrUPDM2nv l3xKgefB8M5trrRDuQ9D9x96Cem2FhD64YbteMhpsvHX9G/s7lnMmOhELrUraYSStXyb KBLNPlBCMqsjylsLp4IxJ8RXopfz3+tEa9M65J9YnWz1TcNhefmSdznSLNMszXnE+xQr k02IJxUbtDuQU8OaBNGCoYgMi1FftucElwhlwdfYQlqGMTAUY0So28xlW9102G2SrWRX yxMeRvTlxuT6/iaRWe1ZmkKDOhMFn3wdTtnsbg8mtmGdCW1zmR3OQr9kcGxdAAdrFhq3 07Iw== 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=eLyXhxJPmm/YYN4NQ4JRserX+J1vPnUR9sNXJxtgNN0=; b=UUT4CLtXsEtKHJaSNZCVUGIupaHRNGw6g1N4etH/FL3+v/gHj52yVihIZmJ3ZPlcPN ORp2KM0gL2CB2krgoHfowZ+M3PME/Q4V3J45+xctVp/ejWXlU7dESoAoYrJNOtVU+Swe 4oqYKWaGQ3FG7rToWQbwIzvM1zbZZ6Toepz8UT/Vuem3cnsD0rNMBvdtUYd4NzQjspZ5 HQfC4wp0Wx5WEBi2GhE5L+l3QYTAupIZJD8IQidBC4GRgLylEEgtf1NlJbJS7QGbDliu VKE4Rz1OM2B67mzldGniIUGmSxTYwjjHSsNKFPtI534jskaaP6ssImOAqLQ1w5xdG4gz ArDA== X-Gm-Message-State: AOAM530BZbg60ZcB1p09nkuroisB3g1bXroGgLJXSDaKn1vxC6OO6QgP m0v8+hVNM+5bVcG8p4BEkl4+VbvN73L57A== X-Google-Smtp-Source: ABdhPJy8UbnMnLew2N+wZJoi0fzQL7QRlQiMbpvKtAw1KLjV/O7C+vKrXbbPmjQgK/G3QI9K6sSrkQ== X-Received: by 2002:ac2:51dd:: with SMTP id u29mr5482790lfm.171.1630047128281; Thu, 26 Aug 2021 23:52:08 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id k35sm507496lfv.227.2021.08.26.23.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 23:52:07 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 1/5] home-services: Add fontutils. In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 09:52:04 +0300 Message-ID: <87y28ne5wr.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: * gnu/home-services/fontutils.scm (home-fontconfig-service-type): New variable. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/fontutils.scm. --- gnu/home-services/fontutils.scm | 65 +++++++++ [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.53 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.53 listed in list.dnswl.org] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable * gnu/home-services/fontutils.scm (home-fontconfig-service-type): New variable. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/fontutils.scm. =2D-- gnu/home-services/fontutils.scm | 65 +++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 66 insertions(+) create mode 100644 gnu/home-services/fontutils.scm diff --git a/gnu/home-services/fontutils.scm b/gnu/home-services/fontutils.= scm new file mode 100644 index 0000000000..28bfc3d3f7 =2D-- /dev/null +++ b/gnu/home-services/fontutils.scm @@ -0,0 +1,65 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 fontutils) + #:use-module (gnu home-services) + #:use-module (gnu packages fontutils) + #:use-module (guix gexp) + + #:export (home-fontconfig-service-type)) + +;;; Commentary: +;;; +;;; Services related to fonts. home-fontconfig service provides +;;; fontconfig configuration, which allows fc-* utilities to find +;;; fonts in Guix Home's profile and regenerates font cache on +;;; activation. +;;; +;;; Code: + +(define (add-fontconfig-config-file he-symlink-path) + `(("config/fontconfig/fonts.conf" + ,(mixed-text-file + "fonts.conf" + " + + + ~/.guix-home/profile/share/fonts +")))) + +(define (regenerate-font-cache-gexp _) + `(("profile/share/fonts" + ,#~(system* #$(file-append fontconfig "/bin/fc-cache") "-fv")))) + +(define home-fontconfig-service-type + (service-type (name 'home-fontconfig) + (extensions + (list (service-extension + home-files-service-type + add-fontconfig-config-file) + (service-extension + home-run-on-change-service-type + regenerate-font-cache-gexp) + (service-extension + home-profile-service-type + (const (list fontconfig))))) + (default-value #f) + (description + "Provides configuration file for fontconfig and make +fc-* utilities aware of font packages installed in Guix Home's profile."))) diff --git a/gnu/local.mk b/gnu/local.mk index 91c3b0da3d..e25ff3db53 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -74,6 +74,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/ci.scm \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ + %D%/home-services/fontutils.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEoi5QPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6w6QgP/1wfBHS66EnoqZAUOJIWOq/2yHYsE4QXos58 mLwpbG5bqBhMYaSQLX80b432s/uvG4CghqfuH3jo/JrIJ0T70Yo90ENF/tMZ3VOw V3UKb1mCmGhkKZ9btP30UXFbmqMDHKJRNGsPhZLl/TtpoZC/ScAwg6wIBItM3Hxm 7DeSuOVD/jdirgPnoqrZ3LtZwk8SXgDB/b8CXDTyBIYbdzGP+6UjafeDf393VVY5 eqoWsLrHAtudtyb3oJXGMlqQS3axm+T6VEWkomrbS0lGTnS9CMdo56gmGFxNobCK Bd8R0LCMFOWZO2xw2SLfltZKlzbWPoQknPTIPL4ZbDM9MrJg9uuu4K8T27YinV6y m/vsNrpxL3daQ9kOmDLs3/ABha6zj4KWoO3MFc2vU38HKfAi+nvTEbug5CKXn9LR tQmBmeICGWhst0lCl7MHQzVIHIT6EvGCaWfKa7e9Hq4fRYFDs/Yd6BIkQtUS0x+f s9Gwl11Ai4DsIpRUqLsQSAVQpfU2FxdqNLCXQ59rPRzqRvgO2CICLosH0/+amMGC i4NO7reH9bOn3mmqr51JQkuQctsKypYDpsqRpb/M+Gfk4lNu5bd0GdAEcenS7iWz DqhukhOuIHeCT5DtUedvJUrDPuBw8+NM6RcHrs2ZdBgDOq9RO5gjdYN297J6dBAz 4QttUKjz =Z4DY -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 02:59:08 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 06:59:08 +0000 Received: from localhost ([127.0.0.1]:51152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVpU-0004v1-Ge for submit@debbugs.gnu.org; Fri, 27 Aug 2021 02:59:08 -0400 Received: from mail-lf1-f54.google.com ([209.85.167.54]:37878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVpS-0004uU-VA for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 02:59:07 -0400 Received: by mail-lf1-f54.google.com with SMTP id k5so12373645lfu.4 for <50208@debbugs.gnu.org>; Thu, 26 Aug 2021 23:59:06 -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=CNoa8R/wqF/C7RwVlyD3UBuiSq8rb3we2L7ipIXqM2Q=; b=YljrfKclsA1JJ31Q6qbcI8/0D4FuJNW3R3H65JgQq/YIHf3BSjtsiKPF9UaoYOFToP j7lN0kNh1ieXnZ/KgBJ3rColtKw6RMbjIouC+ZAAnGTR4ltOy66fZ2SVW/nGgfmB5Kvv u2VvXW6gOl0GSmlNC7MUSnthSfk6gBzjYyfSwNu0gkAXzyqlrvAFXByxseoHK4kcv7RU syAKEYa4CkePXfcTneWKD2eZmABv5v4HuU2D7I7JsqnGE9CkRGSCW6qSm/H9ssuZNrWz mu2en/gPYKtkDnbeOW3iW2Jrj9prrfCqPz4Meosrgp2d2rlW7MLYDaiy2fgns8x7AvTa X/eQ== 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=CNoa8R/wqF/C7RwVlyD3UBuiSq8rb3we2L7ipIXqM2Q=; b=U9Hm0uW7vWq+/cI+8uD4Q+JXyUR5/cwousZsvFc1Z28afXXFLGcCDzkHzub3Bgt9f0 gx6uvEFV48yzhS3YHSBl8iEWWkVHYdnSbn4NGwJHREB5ITyr5a2U2QnMsBViYUyDFx5d I+tLjQrbGXDLg3CYErYCP3gAk0K46+kYfEtCzu3jQ5t2b1UVAUR9OEngTxqrRBYqRzTw gteAC5h7Xq+Qch0Sh81p3VnW2f8Lola28EQXYV/cxdZzLxQpchldVJblacTUzU95BkVT cLFVeBjpgVpx5nsN+ZPj2DDCNfTGO1BA8SahJio2E9aYwFWCQRE9bJOCtJxKeTNxBDmQ QVTA== X-Gm-Message-State: AOAM5336w7K2qHvp9zcWyXej4EX9Xc4exbtfxoVj6PLvbYwVzv874UER KayPOgYWUaUbM1uIqo8jUN0ckg== X-Google-Smtp-Source: ABdhPJwK3N0R1yX013BXDalL4fJB6nFyhx+oPjn+ZZAeMdJwQ04cwxYqeU++f63jSAp3tEVkcLPWAQ== X-Received: by 2002:a05:6512:12c8:: with SMTP id p8mr2057763lfg.208.1630047540587; Thu, 26 Aug 2021 23:59:00 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id z4sm508790lfu.164.2021.08.26.23.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 23:58:59 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 2/5] home-services: Add helper functions for service configurations. In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 09:58:56 +0300 Message-ID: <87v93re5lb.fsf@trop.in> 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: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * gnu/home-services/configuration.scm (helper functions): New variables. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/configuration.scm. =2D-- gnu/home-services/configuration.scm | 63 +++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 64 insertions(+) create mode 100644 gnu/home-services/configuration.scm diff --git a/gnu/home-services/configuration.scm b/gnu/home-services/config= uration.scm new file mode 100644 index 0000000000..b7487fc49f =2D-- /dev/null +++ b/gnu/home-services/configuration.scm @@ -0,0 +1,63 @@ +(define-module (gnu home-services configuration) + #:use-module (gnu services configuration) + #:use-module (guix gexp) + #:use-module (srfi srfi-1) + + #:export (filter-configuration-fields + + interpose + list-of + + list-of-strings? + alist? + string-or-gexp? + serialize-string-or-gexp + text-config? + serialize-text-config)) + +(define* (filter-configuration-fields configuration-fields fields + #:optional negate?) + "Retrieve the fields listed in FIELDS from CONFIGURATION-FIELDS. +If NEGATE? is @code{#t}, retrieve all fields except FIELDS." + (filter (lambda (field) + (let ((member? (member (configuration-field-name field) fields= ))) + (if (not negate?) member? (not member?)))) + configuration-fields)) + + +(define* (interpose ls #:optional (delimiter "\n") (grammar 'infix)) + "Same as @code{string-join}, but without join and string, returns an +DELIMITER interposed LS. Support 'infix and 'suffix GRAMMAR values." + (when (not (member grammar '(infix suffix))) + (raise + (formatted-message + (G_ "The GRAMMAR value must be 'infix or 'suffix, but ~a provided.") + grammar))) + (fold-right (lambda (e acc) + (cons e + (if (and (null? acc) (eq? grammar 'infix)) + acc + (cons delimiter acc)))) + '() ls)) + +(define (list-of pred?) + "Return a procedure that takes a list and check if all the elements of +the list result in @code{#t} when applying PRED? on them." + (lambda (x) + (if (list? x) + (every pred? x) + #f))) + + +(define list-of-strings? + (list-of string?)) + +(define alist? list?) + +(define (string-or-gexp? sg) (or (string? sg) (gexp? sg))) +(define (serialize-string-or-gexp field-name val) "") + +(define (text-config? config) + (and (list? config) (every string-or-gexp? config))) +(define (serialize-text-config field-name val) + #~(string-append #$@(interpose val "\n" 'suffix))) diff --git a/gnu/local.mk b/gnu/local.mk index e25ff3db53..e24da4716f 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,6 +75,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ + %D%/home-services/configuration.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEojTEPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6w5KwQAIn8zBbexmoWqzsuj+wS2O21tGLzq+MiB6eW cG+WISSz7O477aqiosFraIOFNbn3OELbQW9w5C/+ZN79KHSOr4JzhriENlrQ3BQR cqTVVsygr1Dp5IYllyf2fbIbH50c6iozFmzU8Ga8aE8v6SHOYT/z9yTx1TjwAhEC NqdvhHBIMM+vVu+NFYrKXPLndFKGDb6+8aL83gCDMu7T6+fFdFbGxltbVuruJ2dR CWbqDc+Q18XXxTlj13xIjzFgZL8hivpjlQ+IBVsPWYqCc7NnjxF5LtvtG7WV+Gwl +/LEIQwJEOYYTFC+ursuU0om9+LLIyMIxzLGA4kVmocp32bcWnmlc33SP2xuP2j+ lti4c9yCbglCirfFvtbxK+f8MXm4deAyzbZRMjQIcTq6NsMjFiWs4kq4uvbiMara DyKK8/XuBWCJ9C2R9AdpcDUP43qpWdP0m36DPvil+MU4wqzVIXYMnx91YO4scGVw Pjx9UbARIxHuYGZ1Qwwsh6BcLsytwCXiG5FAovnkpxX2IP28h/kPp4rjQM067Ijc QMAKSPvcG0gT/ZnaYsPoh3YtS6yad456g/af2tDR7yauXyHY9Jctrhhx8ZTb0St7 AvxhhULdwOB8PsRolLxooBJXOd1xxTwOKkPRgJiNUMAVUddlSA3g9ZEsCvL7SpmD johGmvf7 =vo+E -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 03:03:19 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 07:03:19 +0000 Received: from localhost ([127.0.0.1]:51166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVtT-00053C-9O for submit@debbugs.gnu.org; Fri, 27 Aug 2021 03:03:18 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:34461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVtQ-00052w-8M for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 03:03:13 -0400 Received: by mail-lf1-f47.google.com with SMTP id z2so12425747lft.1 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 00:03:12 -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=kFkAQq51sY6nnz0UzrjbQb5vPCTDMxq0alEm43CDP/g=; b=xHbwATZ6uWJ8PdJNRb8jUO575orsBtFsHV7vV21bVVlFw3k7GHtisO5CHwAl0KIzux RkKY4Zz4xUnHeTUzbP5KfjaA1VwQ0XHZZtmhNsAnpsB2TbM8b4X5/zkWhNj05STJ+YP4 HLRPeUnRUDQFiP2WcfDTkjzoLGZ6jmsjUrv0fofBScBJQPaZVdpmVAaLAgJ/gCLhzCYl CaxQmrLV6RcY/qgliHxhnecuc/XC2bDjNR5LFnVIdA2VugAKrTH1VHX9udnUsLvLQ9nn bRJnAjeegETEyf+9SdXlYGUGWAgfagEM9O9UPL+X9zXdrXg6XKR9nUiYXoYP15BCOUS3 eP8A== 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=kFkAQq51sY6nnz0UzrjbQb5vPCTDMxq0alEm43CDP/g=; b=YWXHL2ZZh87fO6mi81gYEfmF68l0exPmzPiHdD/A6riIfUTeEgKbDblqI2P3kQCZKZ jGjCvygn5kOp8NU3g18DWx6wx6gDp4B1Zpu9RJXkCR3TZ4mPAutLtyocZF7IXzgdS7rS xnv1eqMb1tTS03s9/64gO5OYptpgTNdb1qwsK86+kmaJPqUsmXYdUC9iyA1WftQeNiy/ d6XDIMkYazCLCb6MuJGnK5rqoJdFjMQSD7eRe2n6qT8VXpheYESsrk7DdZbMpmaLTIiS 5fTBhSuqrUEJFwTFMAH4S3V0iNkyCvwuhUPN1Yal5FBhxcg1TBoLIjcLwG3v5RbcAMMs XH2Q== X-Gm-Message-State: AOAM531bbdXot3R5u5cn0tyWWomLOcMMXyrmneRsqT2sxjjvJjYmzU5L yySp5ja7k3F5IXOeOe5jhkrVEsfVsixSBw== X-Google-Smtp-Source: ABdhPJxIPBH1SyXvScMJraROLn1Xwp8+lyFzf8fQzmd0UtXjMDCGm9ZXvuyp1GfpNXVmi3nSyir24Q== X-Received: by 2002:a19:4f1a:: with SMTP id d26mr5427643lfb.377.1630047786281; Fri, 27 Aug 2021 00:03:06 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id e8sm582872ljj.132.2021.08.27.00.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 00:03:05 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 3/5] home-services: Add shells. In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 10:03:02 +0300 Message-ID: <87r1efe5eh.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: * gnu/home-services/shells.scm (home-shell-profile-service-type, home-shell-profile-configuration) (home-bash-service-type, home-bash-configuration, home-bash-extension) (home-zsh-service-type, home-z [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.47 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.47 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable * gnu/home-services/shells.scm (home-shell-profile-service-type, home-shell-profile-configuration) (home-bash-service-type, home-bash-configuration, home-bash-extension) (home-zsh-service-type, home-zsh-configuration, home-zsh-extension) (home-fish-service-type, home-fish-configuration, home-fish-extension): New variables. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/shells.scm. =2D-- gnu/home-services/shells.scm | 637 +++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 638 insertions(+) create mode 100644 gnu/home-services/shells.scm diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm new file mode 100644 index 0000000000..0643019361 =2D-- /dev/null +++ b/gnu/home-services/shells.scm @@ -0,0 +1,637 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 shells) + #:use-module (gnu services configuration) + #:use-module (gnu home-services configuration) + #:use-module (gnu home-services) + #:use-module (gnu packages shells) + #:use-module (gnu packages bash) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (ice-9 match) + + #:export (home-shell-profile-service-type + home-shell-profile-configuration + + home-bash-service-type + home-bash-configuration + home-bash-extension + + home-zsh-service-type + home-zsh-configuration + home-zsh-extension + + home-fish-service-type + home-fish-configuration + home-fish-extension)) + +;;; Commentary: +;;; +;;; This module contains shell related services like Zsh. +;;; +;;; Code: + + +;;; +;;; Shell profile. +;;; + +(define path? string?) +(define (serialize-path field-name val) val) + +(define-configuration home-shell-profile-configuration + (profile + (text-config '()) + "\ +@code{home-shell-profile} is instantiated automatically by +@code{home-environment}, DO NOT create this service manually, it can +only be extended. + +@code{profile} is a list of strings or gexps, which will go to +@file{~/.profile}. By default @file{~/.profile} contains the +initialization code, which have to be evaluated by login shell to make +home-environment's profile avaliable to the user, but other commands +can be added to the file if it is really necessary. + +In most cases shell's configuration files are preferred places for +user's customizations. Extend home-shell-profile service only if you +really know what you do.")) + +(define (add-shell-profile-file config) + `(("profile" + ,(mixed-text-file + "shell-profile" + "\ +HOME_ENVIRONMENT=3D$HOME/.guix-home +. $HOME_ENVIRONMENT/setup-environment +$HOME_ENVIRONMENT/on-first-login\n" + (serialize-configuration + config + (filter-configuration-fields + home-shell-profile-configuration-fields '(profile))))))) + +(define (add-profile-extensions config extensions) + (home-shell-profile-configuration + (inherit config) + (profile + (append (home-shell-profile-configuration-profile config) + extensions)))) + +(define home-shell-profile-service-type + (service-type (name 'home-shell-profile) + (extensions + (list (service-extension + home-files-service-type + add-shell-profile-file))) + (compose concatenate) + (extend add-profile-extensions) + (default-value (home-shell-profile-configuration)) + (description "Create @file{~/.profile}, which is used +for environment initialization of POSIX compliant login shells. This +service type can be extended with a list of strings or gexps."))) + +(define (serialize-boolean field-name val) "") +(define (serialize-posix-env-vars field-name val) + #~(string-append + #$@(map + (match-lambda + ((key . #f) + "") + ((key . #t) + #~(string-append "export " #$key "\n")) + ((key . value) + #~(string-append "export " #$key "=3D" #$value "\n"))) + val))) + + +;;; +;;; Zsh. +;;; + +(define-configuration home-zsh-configuration + (package + (package zsh) + "The Zsh package to use.") + (xdg-flavor? + (boolean #t) + "Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes +@file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}. +Shell startup process will continue with +@file{$XDG_CONFIG_HOME/zsh/.zshenv}.") + (environment-variables + (alist '()) + "Association list of environment variables to set for the Zsh session." + serialize-posix-env-vars) + (zshenv + (text-config '()) + "List of strings or gexps, which will be added to @file{.zshenv}. +Used for setting user's shell environment variables. Must not contain +commands assuming the presence of tty or producing output. Will be +read always. Will be read before any other file in @env{ZDOTDIR}.") + (zprofile + (text-config '()) + "List of strings or gexps, which will be added to @file{.zprofile}. +Used for executing user's commands at start of login shell (In most +cases the shell started on tty just after login). Will be read before +@file{.zlogin}.") + (zshrc + (text-config '()) + "List of strings or gexps, which will be added to @file{.zshrc}. +Used for executing user's commands at start of interactive shell (The +shell for interactive usage started by typing @code{zsh} or by +terminal app or any other program).") + (zlogin + (text-config '()) + "List of strings or gexps, which will be added to @file{.zlogin}. +Used for executing user's commands at the end of starting process of +login shell.") + (zlogout + (text-config '()) + "List of strings or gexps, which will be added to @file{.zlogout}. +Used for executing user's commands at the exit of login shell. It +won't be read in some cases (if the shell terminates by exec'ing +another process for example).")) + +(define (add-zsh-configuration config) + (let* ((xdg-flavor? (home-zsh-configuration-xdg-flavor? config))) + + (define prefix-file + (cut string-append + (if xdg-flavor? + "config/zsh/." + "") <>)) + + (define (filter-fields field) + (filter-configuration-fields home-zsh-configuration-fields + (list field))) + + (define (serialize-field field) + (serialize-configuration + config + (filter-fields field))) + + (define (file-if-not-empty field) + (let ((file-name (symbol->string field)) + (field-obj (car (filter-fields field)))) + (if (not (null? ((configuration-field-getter field-obj) config))) + `(,(prefix-file file-name) + ,(mixed-text-file + file-name + (serialize-field field))) + '()))) + + (filter + (compose not null?) + `(,(if xdg-flavor? + `("zshenv" + ,(mixed-text-file + "auxiliary-zshenv" + (if xdg-flavor? + "source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zshenv\= n" + ""))) + '()) + (,(prefix-file "zshenv") + ,(mixed-text-file + "zshenv" + (if xdg-flavor? + "export ZDOTDIR=3D${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n" + "") + (serialize-field 'zshenv) + (serialize-field 'environment-variables))) + (,(prefix-file "zprofile") + ,(mixed-text-file + "zprofile" + "\ +# Setups system and user profiles and related variables +source /etc/profile +# Setups home environment profile +source ~/.profile + +# It's only necessary if zsh is a login shell, otherwise profiles will +# be already sourced by bash +" + (serialize-field 'zprofile))) + + ,@(list (file-if-not-empty 'zshrc) + (file-if-not-empty 'zlogin) + (file-if-not-empty 'zlogout)))))) + +(define (add-zsh-packages config) + (list (home-zsh-configuration-package config))) + +(define-configuration/no-serialization home-zsh-extension + (environment-variables + (alist '()) + "Association list of environment variables to set.") + (zshrc + (text-config '()) + "List of strings or gexps.") + (zshenv + (text-config '()) + "List of strings or gexps.") + (zprofile + (text-config '()) + "List of strings or gexps.") + (zlogin + (text-config '()) + "List of strings or gexps.") + (zlogout + (text-config '()) + "List of strings or gexps.")) + +(define (home-zsh-extensions original-config extension-configs) + (home-zsh-configuration + (inherit original-config) + (environment-variables + (append (home-zsh-configuration-environment-variables original-config) + (append-map + home-zsh-extension-environment-variables extension-configs))) + (zshrc + (append (home-zsh-configuration-zshrc original-config) + (append-map + home-zsh-extension-zshrc extension-configs))) + (zshenv + (append (home-zsh-configuration-zshenv original-config) + (append-map + home-zsh-extension-zshenv extension-configs))) + (zprofile + (append (home-zsh-configuration-zprofile original-config) + (append-map + home-zsh-extension-zprofile extension-configs))) + (zlogin + (append (home-zsh-configuration-zlogin original-config) + (append-map + home-zsh-extension-zlogin extension-configs))) + (zlogout + (append (home-zsh-configuration-zlogout original-config) + (append-map + home-zsh-extension-zlogout extension-configs))))) + +(define home-zsh-service-type + (service-type (name 'home-zsh) + (extensions + (list (service-extension + home-files-service-type + add-zsh-configuration) + (service-extension + home-profile-service-type + add-zsh-packages))) + (compose identity) + (extend home-zsh-extensions) + (default-value (home-zsh-configuration)) + (description "Install and configure Zsh."))) + + +;;; +;;; Bash. +;;; + +(define-configuration home-bash-configuration + (package + (package bash) + "The Bash package to use.") + (guix-defaults? + (boolean #t) + "Add sane defaults like reading @file{/etc/bashrc}, coloring output +for @code{ls} provided by guix to @file{.bashrc}.") + (environment-variables + (alist '()) + "Association list of environment variables to set for the Bash session." + serialize-posix-env-vars) + (bash-profile + (text-config '()) + "List of strings or gexps, which will be added to @file{.bash_profile}. +Used for executing user's commands at start of login shell (In most +cases the shell started on tty just after login). @file{.bash_login} +won't be ever read, because @file{.bash_profile} always present.") + (bashrc + (text-config '()) + "List of strings or gexps, which will be added to @file{.bashrc}. +Used for executing user's commands at start of interactive shell (The +shell for interactive usage started by typing @code{bash} or by +terminal app or any other program).") + (bash-logout + (text-config '()) + "List of strings or gexps, which will be added to @file{.bash_logout}. +Used for executing user's commands at the exit of login shell. It +won't be read in some cases (if the shell terminates by exec'ing +another process for example).")) + +;; TODO: Use value from (gnu system shadow) +(define guix-bashrc + "\ +# Bash initialization for interactive non-login shells and +# for remote shells (info \"(bash) Bash Startup Files\"). + +# Export 'SHELL' to child processes. Programs such as 'screen' +# honor it and otherwise use /bin/sh. +export SHELL + +if [[ $- !=3D *i* ]] +then + # We are being invoked from a non-interactive shell. If this + # is an SSH session (as in \"ssh host command\"), source + # /etc/profile so we get PATH and other essential variables. + [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile + + # Don't do anything else. + return +fi + +# Source the system-wide file. +source /etc/bashrc + +# Adjust the prompt depending on whether we're in 'guix environment'. +if [ -n \"$GUIX_ENVIRONMENT\" ] +then + PS1=3D'\\u@\\h \\w [env]\\$ ' +else + PS1=3D'\\u@\\h \\w\\$ ' +fi +alias ls=3D'ls -p --color=3Dauto' +alias ll=3D'ls -l' +alias grep=3D'grep --color=3Dauto'\n") + +(define (add-bash-configuration config) + (define (filter-fields field) + (filter-configuration-fields home-bash-configuration-fields + (list field))) + + (define (serialize-field field) + (serialize-configuration + config + (filter-fields field))) + + (define* (file-if-not-empty field #:optional (extra-content #f)) + (let ((file-name (symbol->string field)) + (field-obj (car (filter-fields field)))) + (if (or extra-content + (not (null? ((configuration-field-getter field-obj) config))= )) + `(,(object->snake-case-string file-name) + ,(mixed-text-file + (object->snake-case-string file-name) + (if extra-content extra-content "") + (serialize-field field))) + '()))) + + (filter + (compose not null?) + `(("bash_profile" + ,(mixed-text-file + "bash_profile" + "\ +# Setups system and user profiles and related variables +# /etc/profile will be sourced by bash automatically +# Setups home environment profile +if [ -f ~/.profile ]; then source ~/.profile; fi + +# Honor per-interactive-shell startup file +if [ -f ~/.bashrc ]; then source ~/.bashrc; fi +" + (serialize-field 'bash-profile) + (serialize-field 'environment-variables))) + + ,@(list (file-if-not-empty + 'bashrc + (if (home-bash-configuration-guix-defaults? config) + guix-bashrc + #f)) + (file-if-not-empty 'bash-logout))))) + +(define (add-bash-packages config) + (list (home-bash-configuration-package config))) + +(define-configuration/no-serialization home-bash-extension + (environment-variables + (alist '()) + "Association list of environment variables to set.") + (bash-profile + (text-config '()) + "List of strings or gexps.") + (bashrc + (text-config '()) + "List of strings or gexps.") + (bash-logout + (text-config '()) + "List of strings or gexps.")) + +(define (home-bash-extensions original-config extension-configs) + (home-bash-configuration + (inherit original-config) + (environment-variables + (append (home-bash-configuration-environment-variables original-config) + (append-map + home-bash-extension-environment-variables extension-configs))) + (bash-profile + (append (home-bash-configuration-bash-profile original-config) + (append-map + home-bash-extension-bash-profile extension-configs))) + (bashrc + (append (home-bash-configuration-bashrc original-config) + (append-map + home-bash-extension-bashrc extension-configs))) + (bash-logout + (append (home-bash-configuration-bash-logout original-config) + (append-map + home-bash-extension-bash-logout extension-configs))))) + +(define home-bash-service-type + (service-type (name 'home-bash) + (extensions + (list (service-extension + home-files-service-type + add-bash-configuration) + (service-extension + home-profile-service-type + add-bash-packages))) + (compose identity) + (extend home-bash-extensions) + (default-value (home-bash-configuration)) + (description "Install and configure GNU Bash."))) + + +;;; +;;; Fish. +;;; + +(define (serialize-fish-aliases field-name val) + #~(string-append + #$@(map (match-lambda + ((key . value) + #~(string-append "alias " #$key " \"" #$value "\"\n")) + (_ "")) + val))) + +(define (serialize-fish-abbreviations field-name val) + #~(string-append + #$@(map (match-lambda + ((key . value) + #~(string-append "abbr --add " #$key " " #$value "\n")) + (_ "")) + val))) + +(define (serialize-fish-env-vars field-name val) + #~(string-append + #$@(map (match-lambda + ((key . #f) + "") + ((key . #t) + #~(string-append "set " #$key "\n")) + ((key . value) + #~(string-append "set " #$key " " #$value "\n"))) + val))) + +(define-configuration home-fish-configuration + (package + (package fish) + "The Fish package to use.") + (config + (text-config '()) + "List of strings or gexps, which will be added to +@file{$XDG_CONFIG_HOME/fish/config.fish}.") + (environment-variables + (alist '()) + "Association list of environment variables to set in Fish." + serialize-fish-env-vars) + (aliases + (alist '()) + "Association list of aliases for Fish, both the key and the value +should be a string. An alias is just a simple function that wraps a +command, If you want something more akin to @dfn{aliases} in POSIX +shells, see the @code{abbreviations} field." + serialize-fish-aliases) + (abbreviations + (alist '()) + "Association list of abbreviations for Fish. These are words that, +when typed in the shell, will automatically expand to the full text." + serialize-fish-abbreviations)) + +(define (fish-files-service config) + `(("config/fish/config.fish" + ,(mixed-text-file + "fish-config.fish" + #~(string-append "\ +# if we haven't sourced the login config, do it +status --is-login; and not set -q __fish_login_config_sourced +and begin + + set --prepend fish_function_path " + #$fish-foreign-env + "/share/fish/functions + fenv source $HOME/.profile + set -e fish_function_path[1] + + set -g __fish_login_config_sourced 1 + +end\n\n") + (serialize-configuration + config + home-fish-configuration-fields))))) + +(define (fish-profile-service config) + (list (home-fish-configuration-package config))) + +(define-configuration/no-serialization home-fish-extension + (config + (text-config '()) + "List of strings or gexps for extending the Fish initialization file.") + (environment-variables + (alist '()) + "Association list of environment variables to set.") + (aliases + (alist '()) + "Association list of Fish aliases.") + (abbreviations + (alist '()) + "Association list of Fish abbreviations.")) + +(define (home-fish-extensions original-config extension-configs) + (home-fish-configuration + (inherit original-config) + (config + (append (home-fish-configuration-config original-config) + (append-map + home-fish-extension-config extension-configs))) + (environment-variables + (append (home-fish-configuration-environment-variables original-config) + (append-map + home-fish-extension-environment-variables extension-configs))) + (aliases + (append (home-fish-configuration-aliases original-config) + (append-map + home-fish-extension-aliases extension-configs))) + (abbreviations + (append (home-fish-configuration-abbreviations original-config) + (append-map + home-fish-extension-abbreviations extension-configs))))) + +;; TODO: Support for generating completion files +;; TODO: Support for installing plugins +(define home-fish-service-type + (service-type (name 'home-fish) + (extensions + (list (service-extension + home-files-service-type + fish-files-service) + (service-extension + home-profile-service-type + fish-profile-service))) + (compose identity) + (extend home-fish-extensions) + (default-value (home-fish-configuration)) + (description "\ +Install and configure Fish, the friendly interactive shell."))) + + +(define (generate-home-shell-profile-documentation) + (generate-documentation + `((home-shell-profile-configuration + ,home-shell-profile-configuration-fields)) + 'home-shell-profile-configuration)) + +(define (generate-home-bash-documentation) + (generate-documentation + `((home-bash-configuration + ,home-bash-configuration-fields)) + 'home-bash-configuration)) + +(define (generate-home-zsh-documentation) + (generate-documentation + `((home-zsh-configuration + ,home-zsh-configuration-fields)) + 'home-zsh-configuration)) + +(define (generate-home-fish-documentation) + (string-append + (generate-documentation + `((home-fish-configuration + ,home-fish-configuration-fields)) + 'home-fish-configuration) + "\n\n" + (generate-documentation + `((home-fish-extension + ,home-fish-extension-fields)) + 'home-fish-extension))) + +;; (display (generate-home-shell-profile-documentation)) +;; (display (generate-home-bash-documentation)) +;; (display (generate-home-zsh-documentation)) diff --git a/gnu/local.mk b/gnu/local.mk index e24da4716f..dc0e732114 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -76,6 +76,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ %D%/home-services/configuration.scm \ + %D%/home-services/shells.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEojiYPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wQg0P/3p4X/z2of3V2xDBLb6/RFUf8Zd/IJMdLsZm GYIYdR161AGe4VNfg3eqi+/gKaRkDOPIlLq07C8hLAWCddi8nvcSjXUgvIqd1lcD zZDI3psu1rxPwbq5GpF67rnZAI+ddr6x33z5ALOWlpOtOVqLLp9nYRTodJD1NjJC RB75LLEdoGYc1HOwsPYMAgPEPKWQ/HH1K7FI6HW269ez9mtLZj5ERjcSmlDK3oDY s30gqr+Kfg291VlgVTMb4ksOf+pzoZjafZih1qTShmOpUPsLriDv6iNYG5AehxN6 TUGBAIVm0m+yyUCEiTVrQnuZz3jDAOpFkQdxdcxPTtahavVObPaRjpmNPXcnzuTg ZwPo5tvZtIuejQ5oyDNqXqDIukQyYEr48IoT939+DGnV/B5x2Y6jr+9TMDJ9sx3b u9KmsjWvav28hepJmZwC5Ejl5wEA0lSrZOO8OwXu8au0GSLW+7r8r+T1drfBgRg1 FHrq3B3O6l5Zn1HVqGtnJXvGsSWERxzbAFH3yUyA9Oke0rFy6QGgRCog6sldqme8 Zm1YMmuGX4jWJ6dG0hIvlM5EGltGgwZ6tg+swLxem8XWuvIw7PLn2Gf7Gv9Y7Xd/ YaSMGCa7EQ3BFWlREIaKka+t3AYxxY7v3DO2mUA9buq4HfO1SWdQAn5ANmbwNSAz N+TbNVNT =vu+M -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 03:07:07 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 07:07:07 +0000 Received: from localhost ([127.0.0.1]:51172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVx8-000593-AA for submit@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:07 -0400 Received: from mail-lf1-f48.google.com ([209.85.167.48]:46761) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVx6-00058W-E4 for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:01 -0400 Received: by mail-lf1-f48.google.com with SMTP id b4so12297788lfo.13 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 00:07:00 -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=gmoMZIrynZ5Vwl10BB60DvhXTBZob5pPvdtZxvYUdbc=; b=rVIXyCq+rqCTp41aBiQUBV6/Qsu5F+3CuIzdXkl8W63A/Y25jIcv6NbG+Bs/bycA64 rypAqpyyL/EoXz8RQmqvN0tCZvVa5DLxJf745IabvcpUi06veS7wX72mG5AHj08lKnIv gYN0Io/npZwqmJP007gnYkEbZW0xYcpT7gVFh/tU2OucNgvjFflTkJUuCxVZc2yzquko Tv9FJf1qheq5ajPA+kKEjKDFtrSflzoUfuk2Z1RxCjp0OjdtoeBDFA0fdTaglplhYyO9 0zA9UMfbdgv/dlST6agoD15YThkvt1f8Rd9BWasMAjOEC9Fg6dtfn3H4gLC+s7VZmxth jBWw== 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=gmoMZIrynZ5Vwl10BB60DvhXTBZob5pPvdtZxvYUdbc=; b=PZWzxdQXW41vrxfDK9OzlqTMyo3OdOg2PTux9dfOMt44teELRVnI4kfgv1W0Ne4Qk3 j5LZAMxoBUFnp4WDHchM+x/N/EFkgMzuQ/bw0GC6FcfxMEz8pv1o1RI4VbM8J+/JlQem Fg7y4IDvkUYTEPYCjeOAjI3RBpXx0xVEqPlkIU3E2n+LCwzsapdj4xNdnfjndTsaWm0z 24XewF+v/+k9oHMbmopPd4c/8aWmkBkV0HugFNcSgnaR7wqFG/4hh2FOzJQgUXfo6UpG R5aIosDG2vzBB4x1IjgiAolTpqNLYjU/PZr2KrBZpJMyma0uJiaQ2GEJ1Tgy4AqDWScq NnIA== X-Gm-Message-State: AOAM532naSM8FUIZVeW0lFGjUQLyaX3aiYbWqjMC1jgeeCC/oNYyB/Bv UpC+u55APzOVyxkyMCPvIlNUWy1L3oVMgA== X-Google-Smtp-Source: ABdhPJw79qYRx+CemY3Mq9/YKTcvZ7Zcd3R1a+p4578qrM2iL5pdgX4dvS8SnggYXc/EcghBYKXKCg== X-Received: by 2002:ac2:4312:: with SMTP id l18mr5903188lfh.602.1630048013936; Fri, 27 Aug 2021 00:06:53 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id i5sm588355ljm.33.2021.08.27.00.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 00:06:53 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 4/5] home-services: Add xdg. In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 10:06:50 +0300 Message-ID: <87o89je585.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: * gnu/home-services/xdg.scm (home-xdg-base-directories-service-type) (home-xdg-base-directories-configuration) (home-xdg-base-directories-configuration?) (home-xdg-user-directories-service-type) (home [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.48 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.48 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable * gnu/home-services/xdg.scm (home-xdg-base-directories-service-type) (home-xdg-base-directories-configuration) (home-xdg-base-directories-configuration?) (home-xdg-user-directories-service-type) (home-xdg-user-directories-configuration) (home-xdg-user-directories-configuration?) (xdg-desktop-action, xdg-desktop-entry) (home-xdg-mime-applications-service-type) (home-xdg-mime-applications-configuration): New variables. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/xdg.scm. =2D-- gnu/home-services/xdg.scm | 475 ++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 476 insertions(+) create mode 100644 gnu/home-services/xdg.scm diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm new file mode 100644 index 0000000000..acacaa1218 =2D-- /dev/null +++ b/gnu/home-services/xdg.scm @@ -0,0 +1,475 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 xdg) + #:use-module (gnu services configuration) + #:use-module (gnu home-services configuration) + #:use-module (gnu home-services) + #:use-module (gnu packages freedesktop) + #:use-module (gnu home-services-utils) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (guix i18n) + + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (rnrs enums) + + #:export (home-xdg-base-directories-service-type + home-xdg-base-directories-configuration + home-xdg-base-directories-configuration? + + home-xdg-user-directories-service-type + home-xdg-user-directories-configuration + home-xdg-user-directories-configuration? + + xdg-desktop-action + xdg-desktop-entry + home-xdg-mime-applications-service-type + home-xdg-mime-applications-configuration)) + +;;; Commentary: +;; +;; This module contains services related to XDG directories and +;; applications. +;; +;; - XDG base directories +;; - XDG user directories +;; - XDG MIME applications +;; +;;; Code: + + +;;; +;;; XDG base directories. +;;; + +(define (serialize-path field-name val) "") +(define path? string?) + +(define-configuration home-xdg-base-directories-configuration + (cache-home + (path "$HOME/.cache") + "Base directory for programs to store user-specific non-essential +(cached) data. Files in this directory can be deleted anytime without +loss of important data.") + (config-home + (path "$HOME/.config") + "Base directory for programs to store configuration files. +Some programs store here log or state files, but it's not desired, +this directory should contain static configurations.") + (data-home + (path "$HOME/.local/share") + "Base directory for programs to store architecture independent +read-only shared data, analogus to @file{/usr/share}, but for user.") + (runtime-dir + (path "${XDG_RUNTIME_DIR:-/run/user/$UID}") + "Base directory for programs to store user-specific runtime files, +like sockets.") + (log-home + (path "$HOME/.local/var/log") + "Base directory for programs to store log files, analogus to +@file{/var/log}, but for user. It is not a part of XDG Base Directory +Specification, but helps to make implementation of home services more +consistent.") + (state-home + (path "$HOME/.local/var/lib") + "Base directory for programs to store state files, like databases, +analogus to @file{/var/lib}, but for user. It is not a part of XDG +Base Directory Specification, but helps to make implementation of home +services more consistent.")) + +(define (home-xdg-base-directories-environment-variables-service config) + (map + (lambda (field) + (cons (format + #f "XDG_~a" + (object->snake-case-string (configuration-field-name field) 'u= pper)) + ((configuration-field-getter field) config))) + home-xdg-base-directories-configuration-fields)) + +(define (ensure-xdg-base-dirs-on-activation config) + #~(map (lambda (xdg-base-dir-variable) + ((@@ (guix build utils) mkdir-p) + (getenv + xdg-base-dir-variable))) + '#$(map (lambda (field) + (format + #f "XDG_~a" + (object->snake-case-string + (configuration-field-name field) 'upper))) + home-xdg-base-directories-configuration-fields))) + +(define (last-extension-or-cfg config extensions) + "Picks configuration value from last provided extension. If there +are no extensions use configuration instead." + (or (and (not (null? extensions)) (last extensions)) config)) + +(define home-xdg-base-directories-service-type + (service-type (name 'home-xdg-base-directories) + (extensions + (list (service-extension + home-environment-variables-service-type + home-xdg-base-directories-environment-variables-se= rvice) + (service-extension + home-activation-service-type + ensure-xdg-base-dirs-on-activation))) + (default-value (home-xdg-base-directories-configuration)) + (compose identity) + (extend last-extension-or-cfg) + (description "Configure XDG base directories. This +service introduces two additional variables @env{XDG_STATE_HOME}, +@env{XDG_LOG_HOME}. They are not a part of XDG specification, at +least yet, but are convinient to have, it improves the consistency +between different home services. The services of this service-type is +instantiated by default, to provide non-default value, extend the +service-type (using @code{simple-service} for example)."))) + +(define (generate-home-xdg-base-directories-documentation) + (generate-documentation + `((home-xdg-base-directories-configuration + ,home-xdg-base-directories-configuration-fields)) + 'home-xdg-base-directories-configuration)) + + +;;; +;;; XDG user directories. +;;; + +(define (serialize-string field-name val) + ;; The path has to be quoted + (format #f "XDG_~a_DIR=3D\"~a\"\n" + (object->snake-case-string field-name 'upper) val)) + +(define-configuration home-xdg-user-directories-configuration + (desktop + (string "$HOME/Desktop") + "Default ``desktop'' directory, this is what you see on your +desktop when using a desktop environment, +e.g. GNOME (@pxref{XWindow,,,guix.info}).") + (documents + (string "$HOME/Documents") + "Default directory to put documents like PDFs.") + (download + (string "$HOME/Downloads") + "Default directory downloaded files, this is where your Web-broser +will put downloaded files in.") + (music + (string "$HOME/Music") + "Default directory for audio files.") + (pictures + (string "$HOME/Pictures") + "Default directory for pictures and images.") + (publicshare + (string "$HOME/Public") + "Default directory for shared files, which can be accessed by other +users on local machine or via network.") + (templates + (string "$HOME/Templates") + "Default directory for templates. They can be used by graphical +file manager or other apps for creating new files with some +pre-populated content.") + (videos + (string "$HOME/Videos") + "Default directory for videos.")) + +(define (home-xdg-user-directories-files-service config) + `(("config/user-dirs.conf" + ,(mixed-text-file + "user-dirs.conf" + "enabled=3DFalse\n")) + ("config/user-dirs.dirs" + ,(mixed-text-file + "user-dirs.dirs" + (serialize-configuration + config + home-xdg-user-directories-configuration-fields))))) + +(define (home-xdg-user-directories-activation-service config) + (let ((dirs (map (lambda (field) + ((configuration-field-getter field) config)) + home-xdg-user-directories-configuration-fields))) + #~(let ((ensure-dir + (lambda (path) + (mkdir-p + ((@@ (ice-9 string-fun) string-replace-substring) + path "$HOME" (getenv "HOME")))))) + (display "Creating XDG user directories...") + (map ensure-dir '#$dirs) + (display " done\n")))) + +(define home-xdg-user-directories-service-type + (service-type (name 'home-xdg-user-directories) + (extensions + (list (service-extension + home-files-service-type + home-xdg-user-directories-files-service) + (service-extension + home-activation-service-type + home-xdg-user-directories-activation-service))) + (default-value (home-xdg-user-directories-configuration)) + (description "Configure XDG user directories. To +disable a directory, point it to the $HOME."))) + +(define (generate-home-xdg-user-directories-documentation) + (generate-documentation + `((home-xdg-user-directories-configuration + ,home-xdg-user-directories-configuration-fields)) + 'home-xdg-user-directories-configuration)) + + +;;; +;;; XDG MIME applications. +;;; + +;; Example config +;; +;; (home-xdg-mime-applications-configuration +;; (added '((x-scheme-handler/magnet . torrent.desktop))) +;; (default '((inode/directory . file.desktop))) +;; (removed '((inode/directory . thunar.desktop))) +;; (desktop-entries +;; (list (xdg-desktop-entry +;; (file "file") +;; (name "File manager") +;; (type 'application) +;; (config +;; '((exec . "emacsclient -c -a emacs %u")))) +;; (xdg-desktop-entry +;; (file "text") +;; (name "Text editor") +;; (type 'application) +;; (config +;; '((exec . "emacsclient -c -a emacs %u"))) +;; (actions +;; (list (xdg-desktop-action +;; (action 'create) +;; (name "Create an action") +;; (config +;; '((exec . "echo hi")))))))))) + +;; See +;; +;; + +(define (serialize-alist field-name val) + (define (serialize-mimelist-entry key val) + (let ((val (cond + ((list? val) + (string-join (map maybe-object->string val) ";")) + ((or (string? val) (symbol? val)) + val) + (else (raise (formatted-message + (G_ "\ +The value of an XDG MIME entry must be a list, string or symbol, was given= ~a") + val)))))) + (format #f "~a=3D~a\n" key val))) + + (define (merge-duplicates alist acc) + "Merge values that have the same key. + +@example +(merge-duplicates '((key1 . value1) + (key2 . value2) + (key1 . value3) + (key1 . value4)) '()) + +@result{} ((key1 . (value4 value3 value1)) (key2 . value2)) +@end example" + (cond + ((null? alist) acc) + (else (let* ((head (first alist)) + (tail (cdr alist)) + (key (first head)) + (value (cdr head)) + (duplicate? (assoc key acc))) + (if duplicate? + ;; XXX: This will change the order of things, + ;; though, it shouldn't be a problem for XDG MIME. + (merge-duplicates + tail + (alist-cons key + (cons value (maybe-list (cdr duplicate?))) + (alist-delete key acc))) + (merge-duplicates tail (cons head acc))))))) + + (string-append (if (equal? field-name 'default) + "\n[Default Applications]\n" + (format #f "\n[~a Associations]\n" + (string-capitalize (symbol->string field-name= )))) + (generic-serialize-alist string-append + serialize-mimelist-entry + (merge-duplicates val '())))) + +(define xdg-desktop-types (make-enumeration + '(application + link + directory))) + +(define (xdg-desktop-type? type) + (unless (enum-set-member? type xdg-desktop-types) + (raise (formatted-message + (G_ "XDG desktop type must be of of ~a, was given: ~a") + (list->human-readable-list (enum-set->list xdg-desktop-types)) + type)))) + +;; TODO: Add proper docs for this +;; XXX: 'define-configuration' require that fields have a default +;; value. +(define-record-type* + xdg-desktop-action make-xdg-desktop-action + xdg-desktop-action? + (action xdg-desktop-action-action) ; symbol + (name xdg-desktop-action-name) ; string + (config xdg-desktop-action-config ; alist + (default '()))) + +(define-record-type* + xdg-desktop-entry make-xdg-desktop-entry + xdg-desktop-entry? + ;; ".desktop" will automatically be added + (file xdg-desktop-entry-file) ; string + (name xdg-desktop-entry-name) ; string + (type xdg-desktop-entry-type) ; xdg-desktop-type + (config xdg-desktop-entry-config ; alist + (default '())) + (actions xdg-desktop-entry-actions ; list of + (default '()))) + +(define desktop-entries? (list-of xdg-desktop-entry?)) +(define (serialize-desktop-entries field-name val) "") + +(define (serialize-xdg-desktop-entry entry) + "Return a tuple of the file name for ENTRY and the serialized +configuration." + (define (format-config key val) + (let ((val (cond + ((list? val) + (string-join (map maybe-object->string val) ";")) + ((boolean? val) + (if val "true" "false")) + (else val))) + (key (string-capitalize (maybe-object->string key)))) + (list (if (string-suffix? key "?") + (string-drop-right key (- (string-length key) 1)) + key) + "=3D" val "\n"))) + + (define (serialize-alist config) + (generic-serialize-alist identity format-config config)) + + (define (serialize-xdg-desktop-action action) + (match action + (($ action name config) + `(,(format #f "[Desktop Action ~a]\n" + (string-capitalize (maybe-object->string action))) + ,(format #f "Name=3D~a\n" name) + ,@(serialize-alist config))))) + + (match entry + (($ file name type config actions) + (list (if (string-suffix? file ".desktop") + file + (string-append file ".desktop")) + `("[Desktop Entry]\n" + ,(format #f "Name=3D~a\n" name) + ,(format #f "Type=3D~a\n" + (string-capitalize (symbol->string type))) + ,@(serialize-alist config) + ,@(append-map serialize-xdg-desktop-action actions)))))) + +(define-configuration home-xdg-mime-applications-configuration + (added + (alist '()) + "An association list of MIME types and desktop entries which indicate +that the application should used to open the specified MIME type. The +value has to be string, symbol, or list of strings or symbols, this +applies to the `@code{default}', and `@code{removed}' fields as well.") + (default + (alist '()) + "An association list of MIME types and desktop entries which indicate +that the application should be the default for opening the specified +MIME type.") + (removed + (alist '()) + "An association list of MIME types and desktop entries which indicate +that the application cannot open the specified MIME type.") + (desktop-entries + (desktop-entries '()) + "A list of XDG desktop entries to create. See +@code{xdg-desktop-entry}.")) + +(define (home-xdg-mime-applications-files-service config) + (define (add-xdg-desktop-entry-file entry) + (let ((file (first entry)) + (config (second entry))) + (list (format #f "local/share/applications/~a" file) + (apply mixed-text-file + (format #f "xdg-desktop-~a-entry" file) + config)))) + + (append + `(("config/mimeapps.list" + ,(mixed-text-file + "xdg-mime-appplications" + (serialize-configuration + config + home-xdg-mime-applications-configuration-fields)))) + (map (compose add-xdg-desktop-entry-file serialize-xdg-desktop-entry) + (home-xdg-mime-applications-configuration-desktop-entries config))= )) + +(define (home-xdg-mime-applications-extension old-config extension-configs) + (define (extract-fields config) + ;; return '(added default removed desktop-entries) + (list (home-xdg-mime-applications-configuration-added config) + (home-xdg-mime-applications-configuration-default config) + (home-xdg-mime-applications-configuration-removed config) + (home-xdg-mime-applications-configuration-desktop-entries config= ))) + + (define (append-configs elem acc) + (list (append (first elem) (first acc)) + (append (second elem) (second acc)) + (append (third elem) (third acc)) + (append (fourth elem) (fourth acc)))) + + ;; TODO: Implement procedure to check for duplicates without + ;; sacrificing performance. + ;; + ;; Combine all the alists from 'added', 'default' and 'removed' + ;; into one big alist. + (let ((folded-configs (fold append-configs + (extract-fields old-config) + (map extract-fields extension-configs)))) + (home-xdg-mime-applications-configuration + (added (first folded-configs)) + (default (second folded-configs)) + (removed (third folded-configs)) + (desktop-entries (fourth folded-configs))))) + +(define home-xdg-mime-applications-service-type + (service-type (name 'home-xdg-mime-applications) + (extensions + (list (service-extension + home-files-service-type + home-xdg-mime-applications-files-service))) + (compose identity) + (extend home-xdg-mime-applications-extension) + (default-value (home-xdg-mime-applications-configuration)) + (description + "Configure XDG MIME applications, and XDG desktop entries= ."))) diff --git a/gnu/local.mk b/gnu/local.mk index dc0e732114..8c44c143af 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -77,6 +77,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/home-services/fontutils.scm \ %D%/home-services/configuration.scm \ %D%/home-services/shells.scm \ + %D%/home-services/xdg.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEojwoPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wQuMP/2pHUeQeM7CHlRcGaHcsT6UTogIOJ75Rx643 WNoc01gsjDo4CVIUAXpAMSuOnuWMNvPM9pg42PPvECy1fIxPiZG+ebcLgR2ZdFWR BIfhoqKKEx0sUrutvdsBZT6uZeeiJTJYZrGmUzMjDC5ksbV3Ja9FsaQrzg/nuWn5 GIusoalXPqj2AEmcBjjprrLQ5y763LT5hzQkRRZxpO42VKn/OsQEHSftNKstYYMt SJEWvVvtmPhcZW5oElOy+LPB4Xm22lrYXgWpaXj0E9dpspzDamsviGYG109idS8w TS06eoJg9V/JAov7hMj18ScvmACBZGLOcPNQ45I33quWEQ7zNCNik0oEFyUYSEfy 2rN926FVAbrx/Lbst/7sxTQF0yq5Q9GGDUNJVV44I1U2buKmdO23ztCviMVEZC7E kcTUIzDOUZOfEgzx0fbaVFBgXv+7MMAiSMItre/iu+xHQybfRkBUTZyxnqp8u1kO /WjFVHERIK5sJgS9k1sGEmOj6l2GMAs80QpMxQYX95cJkxS076IrESNUlUrIHn4P lryn+/XWkzxXIyTq4B3Lx/aOfU4pH7Z2PzOM/L9LKrAgn9K9NdmAGXQwiuo55N+L 1zCAZ8u76Vch3UEk/8xR+iVKv+zmAlTB9bnPW7jABvd9faBWbnR3FMST8Mbc78HT c3qbftsT =/Yh0 -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 03:07:46 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 07:07:47 +0000 Received: from localhost ([127.0.0.1]:51175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVxq-0005A1-Dh for submit@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:46 -0400 Received: from mail-lj1-f174.google.com ([209.85.208.174]:33431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJVxp-00059o-72 for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 03:07:45 -0400 Received: by mail-lj1-f174.google.com with SMTP id s12so9851407ljg.0 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 00:07:45 -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=LlG0vkpHel4BIBrogJDjIPYyNwcyYajjndC5aD91k7g=; b=JmOIFUWID3xO3XEQAdHawezvDJemOn+ZW2JLSqcyoIRXCPSbCRVV50nhpofl/nlgJ9 JLJ/y3AoMd8ZYwIsFyXjLOQdq4mXVOVrPzx6s4dzy5sp2i3i1sOi4WY3qcau02tFHJ4w ZvShlOKGfKlNSmv6hyE8d7mL5lHX9h2nRn8cJ8jouSKo57irrSpS52JIfI/8rH4O8o+0 HS08m+8xiJWJFsXvxxYjhHxVH1nArQBnlmv1DtPud2jhseamQDkmCe7yRn2QjCUiMWV8 9CXvjIV72yKXZk7BtcffuAPIl20QF/+fqJ4kakUeMPW8sdw3mqJ+Z+otNKVwGprzbz1V bmlQ== 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=LlG0vkpHel4BIBrogJDjIPYyNwcyYajjndC5aD91k7g=; b=XQP1/XckIDPszUSLNpu/CnD6X09/wYHSqT42VOfCxbAVgLNT/13RByYdLXxWD+H7c2 ja//z76AaCzAplbrH9zE3THgFm3ljhcN1JBGqLwMYcn40VTWI/1f9cL4LvP+GQb9+K6F O5C/Zdtz4qbyI1zBGWVO5pmlR9ck2wEvm+Y/pNo1K7htfiFd4O2zjP5GJJE8FDhwbg7g P9ufPUS+el6CEbUK78EyYu+xgGvyX7+xXrJItcaQ7+PSxAShf5WuSjAN1J4xmgrvoUhi DHcU/z945clGGzD92snjKTfv5QeFxYFoJHvSVPDEiLZKjC1+kxNDGSFfTG96IJdSJo/K p+Rw== X-Gm-Message-State: AOAM5318Z950G8lYxKmcoINop6x7AKJz1cpa0UoPC+hnqlDv83MuSQJU Z481MWVdCezIwFjAY/Off9GJobxZGbo8Tg== X-Google-Smtp-Source: ABdhPJwH/aNNNuf9tDi1ZPVXXIqAXoak9kk1vXzBcu+oPw+ZHzTDODs81k6cw0x2n3bUxv5Dnu7NHg== X-Received: by 2002:a2e:97cf:: with SMTP id m15mr6367577ljj.125.1630048059129; Fri, 27 Aug 2021 00:07:39 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id f30sm509986lfj.219.2021.08.27.00.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 00:07:38 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH 5/5] home: Add home-environment. In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 10:07:35 +0300 Message-ID: <87lf4ne56w.fsf@trop.in> 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: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable * gnu/home.scm (home-environment, home-environment?, this-home-environment) (home-environment-derivation, home-environment-user-services) (home-environment-essential-services, home-environment-services) (home-environment-location, home-environment-with-provenance): New variable= s. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home.scm. =2D-- gnu/home.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 98 insertions(+) create mode 100644 gnu/home.scm diff --git a/gnu/home.scm b/gnu/home.scm new file mode 100644 index 0000000000..220cc49846 =2D-- /dev/null +++ b/gnu/home.scm @@ -0,0 +1,97 @@ +;;; GNU Guix --- Functional package management for GNU +;;; 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) + #:use-module (gnu home-services) + #:use-module (gnu home-services symlink-manager) + #:use-module (gnu home-services shells) + #:use-module (gnu home-services xdg) + #:use-module (gnu home-services fontutils) + #:use-module (gnu services) + #:use-module (guix records) + #:use-module (guix diagnostics) + + #:export (home-environment + home-environment? + this-home-environment + + home-environment-derivation + home-environment-user-services + home-environment-essential-services + home-environment-services + home-environment-location + + home-environment-with-provenance)) + +(define-record-type* home-environment + make-home-environment + home-environment? + this-home-environment + + (packages home-environment-packages ; list of (PACKAGE OUTPU= T...) + (default '())) + + (essential-services home-environment-essential-services ; list of servic= es + (thunked) + (default (home-environment-default-essential-services + this-home-environment))) + (services home-environment-user-services + (default '())) + + (location home-environment-location ; + (default (and=3D> (current-source-location) + source-properties->location)) + (innate))) + +(define (home-environment-default-essential-services he) + "Return the list of essential services for home environment." + (list + (service home-run-on-first-login-service-type) + (service home-activation-service-type) + (service home-environment-variables-service-type) + + (service home-symlink-manager-service-type) + + (service home-fontconfig-service-type) + (service home-xdg-base-directories-service-type) + (service home-shell-profile-service-type) + + (service home-service-type) + (service home-profile-service-type (home-environment-packages he)))) + +(define* (home-environment-services he) + "Return all the services of home environment." + (instantiate-missing-services + (append (home-environment-user-services he) + (home-environment-essential-services he)))) + +(define* (home-environment-derivation he) + "Return a derivation that builds OS." + (let* ((services (home-environment-services he)) + (home (fold-services services + #:target-type home-service-type))) + (service-value home))) + +(define* (home-environment-with-provenance he config-file) + "Return a variant of HE that stores its own provenance information, +including CONFIG-FILE, if available. This is achieved by adding an instan= ce +of HOME-PROVENANCE-SERVICE-TYPE to its services." + (home-environment + (inherit he) + (services (cons (service home-provenance-service-type config-file) + (home-environment-user-services he))))) diff --git a/gnu/local.mk b/gnu/local.mk index 8c44c143af..bbaee51140 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -72,6 +72,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/bootloader/u-boot.scm \ %D%/bootloader/depthcharge.scm \ %D%/ci.scm \ + %D%/home.scm \ %D%/home-services.scm \ %D%/home-services/symlink-manager.scm \ %D%/home-services/fontutils.scm \ =2D-=20 2.33.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEojzcPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6weEgP/3ULj2So54R12l43fRefig3Uf+wZ6PgaSvFu AFLxcjOZpVguSCq1jh+pz93uDAFmTTFQ7xSbDjDBr3EEICjIEs4o/LcXPi3q672n hrcqjQXlYo+lYuXAN4MvM+sxYSBHksUj0aAWnX/kfD5xZWWb6C1BjqwKIBuNifvi j+qU5gvKDxUdVq395h6vgEA2nlPuFqkhWuogFFVPAK1cElB+LYD7k5C5rzqruZw7 6sODAuIJh3gooDMFZPxQXa+ZvKbu8VEyDjJo50/BIxv4Lk1uVY28HfVHTv7OdURv V/+k86YtbJwRMD+Bjt+D4awFBWIeiBCr0sUv95yGDxwSNr58G6pQuQ9PTTKHjcLH izR1mr8/wHYcGyFW/8ckdYPI+3oQllGB7ZOAqLtBLOKS3WDcAOj6ibOPhH2xbRTb +TPpALx+WxsWgRkSJjxlxRj5tnkxb5E5GYskinozVY1lZdSOAhMP3jKqZqv9qxeG 8YXBOLPN9v86moFtIbXOA8bIBMXwt7yj6qaA6pLVNGw8MIewoWCvEhgXd/LxhIRI cY9Vklby2Ymemtw13lm1cwoiDPTSd+/BYnB+upuvdJJfYyZTVy/EAWbvR+NwJzLd yuNZsgtDAZ3gGzyf3mI5TQvq685lYWX4VHwEL1ZOArxmq0xsqtRZta2VCwBr5N00 H+cRUeOa =AWns -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 04:55:43 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 08:55:43 +0000 Received: from localhost ([127.0.0.1]:51224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJXeJ-0007ou-0u for submit@debbugs.gnu.org; Fri, 27 Aug 2021 04:55:43 -0400 Received: from mail1.fsfe.org ([217.69.89.151]:54582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJXeG-0007oj-Cx for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 04:55:41 -0400 From: Jelle Licht To: Andrew Tropin , 50208@debbugs.gnu.org Subject: Re: [bug#50208] [PATCH] home-services: Add symlink-manager In-Reply-To: <87bl5kbsk8.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> Date: Fri, 27 Aug 2021 10:55:36 +0200 Message-ID: <86zgt38dx3.fsf@fsfe.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 50208 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hey Andrew, some nits, as requested! Andrew Tropin writes: > --- > This patch is targeted against wip-guix-home branch. > > It's not a part of any patch series to make sure it will get enough atten= tion, > because it's most unpure part of the Guix Home and operates on user's fil= es. > > gnu/home-services/symlink-manager.scm | 248 ++++++++++++++++++++++++++ > 1 file changed, 248 insertions(+) > create mode 100644 gnu/home-services/symlink-manager.scm > > diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/sy= mlink-manager.scm > new file mode 100644 > index 0000000000..f13c9f4dbe > --- /dev/null > +++ b/gnu/home-services/symlink-manager.scm > @@ -0,0 +1,248 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2021 Andrew Tropin > +;;; Copyright =C2=A9 2021 Xinglu Chen > +;;; > +;;; 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 symlink-manager) > + #:use-module (gnu home-services) > + #:use-module (guix gexp) > + > + #:export (home-symlink-manager-service-type)) > + > +;;; Comment: > +;;; > +;;; symlink-manager cares about configuration files: it backups files s/backups/backs up > +;;; created by user, removes symlinks and directories created by missing the/a > +;;; previous generation, and creates new directories and symlinks to > +;;; configs according to content of files/ directory of current home I don't really get the last part of this sentence. > +;;; environment generation (created by home-files-service). > +;;; > +;;; Code: > + > +(define (update-symlinks-script) > + (program-file > + "update-symlinks" > + #~(begin > + (use-modules (ice-9 ftw) > + (ice-9 curried-definitions) > + (ice-9 match) > + (srfi srfi-1)) The formatting seems off. In addition, I notice there are tab characters in the patch for some reason, you should be able to have emacs Do The Right Thing if you hack within a Guix git checkout. > + (define ((simplify-file-tree parent) file) > + "Convert the result produced by `file-system-tree' to less > +verbose and more suitable for further processing format. > + > +Extract dir/file info from stat and compose a relative path to the > +root of the file tree. > + > +Sample output: > + > +((dir . \".\") > + ((dir . \"config\") > + ((dir . \"config/fontconfig\") > + (file . \"config/fontconfig/fonts.conf\")) > + ((dir . \"config/isync\") > + (file . \"config/isync/mbsyncrc\")))) > +" > + (match file > + ((name stat) `(file . ,(string-append parent name))) > + ((name stat children ...) > + (cons `(dir . ,(string-append parent name)) > + (map (simplify-file-tree > + (if (equal? name ".") > + "" > + (string-append parent name "/"))) > + children))))) > + > + (define ((file-tree-traverse preordering) node) > + "Traverses the file tree in different orders, depending on PREORDERING. > + > +if PREORDERING is @code{#t} resulting list will contain folders before > +files located in those folders, otherwise folders will appear only > +after all nested items already listed." s/folders/(sub-)directories > + (let ((prepend (lambda (a b) (append b a)))) > + (match node > + (('file . path) (list node)) > + ((('dir . path) . rest) > + ((if preordering append prepend) > + (list (cons 'dir path)) > + (append-map (file-tree-traverse preordering) rest)))))) > + > + (use-modules (guix build utils)) > + > + (let* ((he-path (string-append (getenv "HOME") "/.guix-home")) > + (new-he-tmp-path (string-append he-path ".new")) > + (new-home (getenv "GUIX_NEW_HOME"))) > + (symlink new-home new-he-tmp-path) > + (rename-file new-he-tmp-path he-path)) > + > + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") > + (string-append (getenv "HOME") "/.config"))) > + > + (he-path (string-append (getenv "HOME") "/.guix-home")) > + (new-he-tmp-path (string-append he-path ".new")) This is a path to a transient location for the new home environment, correc= t? tmp-path, to me at least, evokes a place where temporary files are stored, contrasted to a temporary home for important files. > + > + (files-path (string-append he-path "/files")) > + ;; Leading dot is required, because files itself is symlink and > + ;; to make file-system-tree works it should be a directory. > + (files-dir-path (string-append files-path "/.")) > + (new-files-path (string-append new-he-tmp-path "/files")) > + (new-files-dir-path (string-append files-path "/.")) > + > + (home-path (getenv "HOME")) > + (backup-dir (string-append home-path "/" > + (number->string (current-time)) > + "-guix-home-legacy-configs-backup")) > + > + (old-tree (if (file-exists? files-dir-path) > + ((simplify-file-tree "") > + (file-system-tree files-dir-path)) > + #f)) > + (new-tree ((simplify-file-tree "") > + (file-system-tree new-files-dir-path))) > + > + (get-source-path > + (lambda (path) > + (readlink (string-append files-path "/" path)))) > + > + (get-target-path > + (lambda (path) > + (string-append home-path "/." path))) > + > + (get-backup-path > + (lambda (path) > + (string-append backup-dir "/." path))) > + > + (directory? > + (lambda (path) > + (equal? (stat:type (stat path)) 'directory))) > + > + (empty-directory? > + (lambda (dir) > + (equal? (scandir dir) '("." "..")))) > + > + (symlink-to-store? > + (lambda (path) > + (and > + (equal? (stat:type (lstat path)) 'symlink) > + (store-file-name? (readlink path))))) > + > + (backup-file > + (lambda (path) > + (mkdir-p backup-dir) > + (format #t "Backing up ~a..." (get-target-path path)) > + (mkdir-p (dirname (get-backup-path path))) > + (rename-file (get-target-path path) (get-backup-path path)) > + (display " done\n"))) A couple of the previous lambdas could have been `define'd (as a nested define) instead of put in this binding form. > + > + (cleanup-symlinks > + (lambda () > + (let ((to-delete ((file-tree-traverse #f) old-tree))) > + (display > + "Cleaning up symlinks from previous home-environment.\n\n") > + (map > + (match-lambda > + (('dir . ".") > + (display "Cleanup finished.\n\n")) > + > + (('dir . path) > + (if (and > + (file-exists? (get-target-path path)) > + (directory? (get-target-path path)) > + (empty-directory? (get-target-path path))) > + (begin > + (format #t "Removing ~a..." > + (get-target-path path)) > + (rmdir (get-target-path path)) > + (display " done\n")) I think a let-binding for (get-target-path path) would work well here. > + (format > + #t "Skipping ~a (not an empty directory)... done\n" > + (get-target-path path)))) > + > + (('file . path) > + (when (file-exists? (get-target-path path)) > + ;; DO NOT remove the file if it was modified > + ;; by user (not a symlink to the /gnu/store > + ;; anymore) it will be backed up later during > + ;; create-symlinks phase. `by user' does not add anything; Referring to modified is slightly confusing, as I can change the symlink to point to a different file in the store and it will happily be deleted at this point in time. what about: DO NOT remote the file if it is no longer a symblink to the store. It will be backed up later during the create-symlinks phase. > + (if (symlink-to-store? (get-target-path path)) > + (begin > + (format #t "Removing ~a..." (get-target-path path)) > + (delete-file (get-target-path path)) > + (display " done\n")) > + (format > + #t > + "Skipping ~a (not a symlink to store)... done\n" > + (get-target-path path)))))) > + to-delete)))) > + > + (create-symlinks > + (lambda () > + (let ((to-create ((file-tree-traverse #t) new-tree))) > + (map > + (match-lambda > + (('dir . ".") > + (display > + "New symlinks to home-environment will be created soon.\n") > + (format > + #t "All conflicting files will go to ~a.\n\n" backup-dir)) > + > + (('dir . path) > + (let ((target-path (get-target-path path))) > + (when (and (file-exists? target-path) > + (not (directory? target-path))) > + (backup-file path)) > + > + (if (file-exists? target-path) > + (format > + #t "Skipping ~a (directory already exists)... done\n" > + target-path) > + (begin > + (format #t "Creating ~a..." target-path) > + (mkdir target-path) > + (display " done\n"))))) > + > + (('file . path) > + (when (file-exists? (get-target-path path)) > + (backup-file path)) > + (format #t "Symlinking ~a -> ~a..." > + (get-target-path path) (get-source-path path)) > + (symlink (get-source-path path) (get-target-path path)) > + (display " done\n"))) > + to-create))))) > + > + (when old-tree > + (cleanup-symlinks)) > + > + (create-symlinks) > + > + (display " done\nFinished updating symlinks.\n\n"))))) > + > + > +(define (update-symlinks-gexp _) > + #~(primitive-load #$(update-symlinks-script))) > + > +(define home-symlink-manager-service-type > + (service-type (name 'home-symlink-manager) > + (extensions > + (list > + (service-extension > + home-activation-service-type > + update-symlinks-gexp))) > + (default-value #f) > + (description "Provide an @code{update-symlinks} > +script, which create and remove symlinks on every activation. If the creates,removes. > +target is occupied by a file created by user, back it up."))) What is target? Why should I care as a user of this service :)? Perhaps rather than describing how the service does what it does, something= in the spirit of; If an existing file would be overwritten by a symlink, back up the exiting file first. > --=20 > 2.33.0 A nitpick I'm much less certain about is your use of display (and format) without using the G_ macro; Perhaps you can try to reach out to the folks who are most involved with the translation effort to see if there is something that needs to be addressed now, of whether that can still easily happen at a later point? Thanks again for working on this! - Jelle From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 11:24:28 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 15:24:28 +0000 Received: from localhost ([127.0.0.1]:52751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdiV-00014i-H3 for submit@debbugs.gnu.org; Fri, 27 Aug 2021 11:24:28 -0400 Received: from mail-lj1-f176.google.com ([209.85.208.176]:46888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdiS-00014U-N6 for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 11:24:26 -0400 Received: by mail-lj1-f176.google.com with SMTP id w4so12010958ljh.13 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 08:24:24 -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=C7tyVaGBYP8dy6P6vBi99zWmw5feQJIGSwTBlwTE7Gs=; b=wFGanPfDhc6CrW2E7TJApsuDBVuw3YMURCRzKyxjyr5ZbNKTouwVDYHqUjAQ6aHcwc 7VPGl2Jrwp5gsA5AGUtGMgH3MKFV0YF7yEywWyRYWkyBYx+c9QvDOeIeJcEMlJZAd8Wm WJMWdloNJUqp/O/6bZUSe++OqCmbkxkOOoiMr5T31/FIn5JbFf1Dbl4Phj05+myRrT9S gKNEdpPJRmDgv9Ifkh0m4S6K58CizAKuX1+/R0qxWc9MJtEsmxSKXTZbsWenBnHg6BRR nB7fQoY/CFjaGcYbwnosvzGwVF1OOi1Pd1aTKs6sHK2dWDXSGqtK0dD6sAua515RoUA4 yQrg== 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=C7tyVaGBYP8dy6P6vBi99zWmw5feQJIGSwTBlwTE7Gs=; b=HzAGJgCg+tdFhVJ4uCJMANLO8p/fEwjEk59LJEy/fJLJp22Up1uPBngEtnKZOq1+K0 uzVzh0DJNCVebdIt4GUJ2rCP3LLqoeUBZ1B+iaEj4YfteoRxGIwIItkm6wweWVxT+c7c kYWvrfbkSOXS5pCFhDSzaw7AXS9N9YSF6SuntCHcwF+JStTypLCBDhIDca5f9yxjay6Z nyJeE14I47/KYBDdJGrGoRCeqSGjWct9UnukXofRm0uwu+e5Af5g/GbcWWprUEIBQWrC bPLN+xwAwNNBY/Y4n2IvvtTuxBVhJlmue0p9oOm7zbru57rl0zwF492BrGWPFtfhueml EzZw== X-Gm-Message-State: AOAM530dNVxb9FLkt/1y6iNTl4iL5vNUtOVKPYYUyOKwm6ndFuaYfot7 fTMct1xioSodo4sPSLOmCLyx8g== X-Google-Smtp-Source: ABdhPJwV1z47HLTaCKrlOdyqm3lRBfA1tzsqSe1tzfpPoUtgaxY8cdTzYvohWtQTnAyRJRwZGQ4FVw== X-Received: by 2002:a2e:b4b9:: with SMTP id q25mr8031377ljm.180.1630077858295; Fri, 27 Aug 2021 08:24:18 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id x33sm620097lfu.8.2021.08.27.08.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 08:24:17 -0700 (PDT) From: Andrew Tropin To: Jelle Licht , 50208@debbugs.gnu.org Subject: Re: [bug#50208] [PATCH] home-services: Add symlink-manager In-Reply-To: <86zgt38dx3.fsf@fsfe.org> References: <87bl5kbsk8.fsf@trop.in> <86zgt38dx3.fsf@fsfe.org> Date: Fri, 27 Aug 2021 18:24:13 +0300 Message-ID: <877dg6di76.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: On 2021-08-27 10:55, Jelle Licht wrote: > Hey Andrew, > > some nits, as requested! > > Andrew Tropin writes: > >> --- >> This patch is targeted against wip-guix-home branch. >> >> It's not a part of any patch series to make [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.176 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.176 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-27 10:55, Jelle Licht wrote: > Hey Andrew, > > some nits, as requested! > > Andrew Tropin writes: > >> --- >> This patch is targeted against wip-guix-home branch. >> >> It's not a part of any patch series to make sure it will get enough atte= ntion, >> because it's most unpure part of the Guix Home and operates on user's fi= les. >> >> gnu/home-services/symlink-manager.scm | 248 ++++++++++++++++++++++++++ >> 1 file changed, 248 insertions(+) >> create mode 100644 gnu/home-services/symlink-manager.scm >> >> diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/s= ymlink-manager.scm >> new file mode 100644 >> index 0000000000..f13c9f4dbe >> --- /dev/null >> +++ b/gnu/home-services/symlink-manager.scm >> @@ -0,0 +1,248 @@ >> +;;; GNU Guix --- Functional package management for GNU >> +;;; Copyright =C2=A9 2021 Andrew Tropin >> +;;; Copyright =C2=A9 2021 Xinglu Chen >> +;;; >> +;;; 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 symlink-manager) >> + #:use-module (gnu home-services) >> + #:use-module (guix gexp) >> + >> + #:export (home-symlink-manager-service-type)) >> + >> +;;; Comment: >> +;;; >> +;;; symlink-manager cares about configuration files: it backups files > > s/backups/backs up > >> +;;; created by user, removes symlinks and directories created by > missing the/a >> +;;; previous generation, and creates new directories and symlinks to >> +;;; configs according to content of files/ directory of current home > > I don't really get the last part of this sentence. > Slightly rewrote it, hope now it's easier to understand: ;;; symlink-manager cares about configuration files: it backs up files ;;; created by user, removes symlinks and directories created by a ;;; previous generation, and creates new directories and symlinks to ;;; configuration files according to the content of files/ directory ;;; (created by home-files-service) of the current home environment ;;; generation. > >> +;;; environment generation (created by home-files-service). >> +;;; >> +;;; Code: >> + >> +(define (update-symlinks-script) >> + (program-file >> + "update-symlinks" >> + #~(begin >> + (use-modules (ice-9 ftw) >> + (ice-9 curried-definitions) >> + (ice-9 match) >> + (srfi srfi-1)) > The formatting seems off. In addition, I notice there are tab characters > in the patch for some reason, you should be able to have emacs Do The > Right Thing if you hack within a Guix git checkout. Already fixed. > >> + (define ((simplify-file-tree parent) file) >> + "Convert the result produced by `file-system-tree' to less >> +verbose and more suitable for further processing format. >> + >> +Extract dir/file info from stat and compose a relative path to the >> +root of the file tree. >> + >> +Sample output: >> + >> +((dir . \".\") >> + ((dir . \"config\") >> + ((dir . \"config/fontconfig\") >> + (file . \"config/fontconfig/fonts.conf\")) >> + ((dir . \"config/isync\") >> + (file . \"config/isync/mbsyncrc\")))) >> +" >> + (match file >> + ((name stat) `(file . ,(string-append parent name))) >> + ((name stat children ...) >> + (cons `(dir . ,(string-append parent name)) >> + (map (simplify-file-tree >> + (if (equal? name ".") >> + "" >> + (string-append parent name "/"))) >> + children))))) >> + >> + (define ((file-tree-traverse preordering) node) >> + "Traverses the file tree in different orders, depending on PREORDERIN= G. >> + >> +if PREORDERING is @code{#t} resulting list will contain folders before >> +files located in those folders, otherwise folders will appear only >> +after all nested items already listed." > s/folders/(sub-)directories Done. >> + (let ((prepend (lambda (a b) (append b a)))) >> + (match node >> + (('file . path) (list node)) >> + ((('dir . path) . rest) >> + ((if preordering append prepend) >> + (list (cons 'dir path)) >> + (append-map (file-tree-traverse preordering) rest)))))) >> + >> + (use-modules (guix build utils)) >> + >> + (let* ((he-path (string-append (getenv "HOME") "/.guix-home")) >> + (new-he-tmp-path (string-append he-path ".new")) >> + (new-home (getenv "GUIX_NEW_HOME"))) >> + (symlink new-home new-he-tmp-path) >> + (rename-file new-he-tmp-path he-path)) >> + >> + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") >> + (string-append (getenv "HOME") "/.config"))) >> + >> + (he-path (string-append (getenv "HOME") "/.guix-home")) >> + (new-he-tmp-path (string-append he-path ".new")) > > This is a path to a transient location for the new home environment, > correct? Yup. >=20 > tmp-path, to me at least, evokes a place where temporary files are > stored, contrasted to a temporary home for important files. > Removed tmp suffix. > >> + >> + (files-path (string-append he-path "/files")) >> + ;; Leading dot is required, because files itself is symlink and >> + ;; to make file-system-tree works it should be a directory. >> + (files-dir-path (string-append files-path "/.")) >> + (new-files-path (string-append new-he-tmp-path "/files")) >> + (new-files-dir-path (string-append files-path "/.")) >> + >> + (home-path (getenv "HOME")) >> + (backup-dir (string-append home-path "/" >> + (number->string (current-time)) >> + "-guix-home-legacy-configs-backup")) >> + >> + (old-tree (if (file-exists? files-dir-path) >> + ((simplify-file-tree "") >> + (file-system-tree files-dir-path)) >> + #f)) >> + (new-tree ((simplify-file-tree "") >> + (file-system-tree new-files-dir-path))) >> + > >> + (get-source-path >> + (lambda (path) >> + (readlink (string-append files-path "/" path)))) >> + >> + (get-target-path >> + (lambda (path) >> + (string-append home-path "/." path))) >> + >> + (get-backup-path >> + (lambda (path) >> + (string-append backup-dir "/." path))) >> + >> + (directory? >> + (lambda (path) >> + (equal? (stat:type (stat path)) 'directory))) >> + >> + (empty-directory? >> + (lambda (dir) >> + (equal? (scandir dir) '("." "..")))) >> + >> + (symlink-to-store? >> + (lambda (path) >> + (and >> + (equal? (stat:type (lstat path)) 'symlink) >> + (store-file-name? (readlink path))))) >> + >> + (backup-file >> + (lambda (path) >> + (mkdir-p backup-dir) >> + (format #t "Backing up ~a..." (get-target-path path)) >> + (mkdir-p (dirname (get-backup-path path))) >> + (rename-file (get-target-path path) (get-backup-path path)) >> + (display " done\n"))) > > A couple of the previous lambdas could have been `define'd (as a nested > define) instead of put in this binding form. > Yes, but some of them are closures and have to be in the let or deeper in the tree, so I decided to put them all in the let. > >> + >> + (cleanup-symlinks >> + (lambda () >> + (let ((to-delete ((file-tree-traverse #f) old-tree))) >> + (display >> + "Cleaning up symlinks from previous home-environment.\n\n") >> + (map >> + (match-lambda >> + (('dir . ".") >> + (display "Cleanup finished.\n\n")) >> + >> + (('dir . path) >> + (if (and >> + (file-exists? (get-target-path path)) >> + (directory? (get-target-path path)) >> + (empty-directory? (get-target-path path))) >> + (begin >> + (format #t "Removing ~a..." >> + (get-target-path path)) >> + (rmdir (get-target-path path)) >> + (display " done\n")) > > I think a let-binding for (get-target-path path) would work well here. > >> + (format >> + #t "Skipping ~a (not an empty directory)... done\n" >> + (get-target-path path)))) >> + >> + (('file . path) >> + (when (file-exists? (get-target-path path)) >> + ;; DO NOT remove the file if it was modified >> + ;; by user (not a symlink to the /gnu/store >> + ;; anymore) it will be backed up later during >> + ;; create-symlinks phase. > > `by user' does not add anything; Referring to modified is slightly > confusing, as I can change the symlink to point to a different file in > the store and it will happily be deleted at this point in time. > > what about: > DO NOT remote the file if it is no longer a symblink to the store. It > will be backed up later during the create-symlinks phase. > Sounds good, picked this one. > >> + (if (symlink-to-store? (get-target-path path)) >> + (begin >> + (format #t "Removing ~a..." (get-target-path path)) >> + (delete-file (get-target-path path)) >> + (display " done\n")) >> + (format >> + #t >> + "Skipping ~a (not a symlink to store)... done\n" >> + (get-target-path path)))))) >> + to-delete)))) >> + >> + (create-symlinks >> + (lambda () >> + (let ((to-create ((file-tree-traverse #t) new-tree))) >> + (map >> + (match-lambda >> + (('dir . ".") >> + (display >> + "New symlinks to home-environment will be created soon.\n") >> + (format >> + #t "All conflicting files will go to ~a.\n\n" backup-dir)) >> + >> + (('dir . path) >> + (let ((target-path (get-target-path path))) >> + (when (and (file-exists? target-path) >> + (not (directory? target-path))) >> + (backup-file path)) >> + >> + (if (file-exists? target-path) >> + (format >> + #t "Skipping ~a (directory already exists)... done\n" >> + target-path) >> + (begin >> + (format #t "Creating ~a..." target-path) >> + (mkdir target-path) >> + (display " done\n"))))) >> + >> + (('file . path) >> + (when (file-exists? (get-target-path path)) >> + (backup-file path)) >> + (format #t "Symlinking ~a -> ~a..." >> + (get-target-path path) (get-source-path path)) >> + (symlink (get-source-path path) (get-target-path path)) >> + (display " done\n"))) >> + to-create))))) >> + >> + (when old-tree >> + (cleanup-symlinks)) >> + >> + (create-symlinks) >> + >> + (display " done\nFinished updating symlinks.\n\n"))))) >> + >> + >> +(define (update-symlinks-gexp _) >> + #~(primitive-load #$(update-symlinks-script))) >> + >> +(define home-symlink-manager-service-type >> + (service-type (name 'home-symlink-manager) >> + (extensions >> + (list >> + (service-extension >> + home-activation-service-type >> + update-symlinks-gexp))) >> + (default-value #f) >> + (description "Provide an @code{update-symlinks} >> +script, which create and remove symlinks on every activation. If the > creates,removes. >> +target is occupied by a file created by user, back it up."))) > What is target? Why should I care as a user of this service :)? > Perhaps rather than describing how the service does what it does, somethi= ng in > the spirit of; > > If an existing file would be overwritten by a symlink, back up > the exiting file first. Updated. > >> --=20 >> 2.33.0 > > A nitpick I'm much less certain about is your use of display (and > format) without using the G_ macro; Perhaps you can try to reach out to > the folks who are most involved with the translation effort to see if > there is something that needs to be addressed now, of whether that can > still easily happen at a later point? > Yep, it's very likely that there is a better mechanism for providing output than display function, but I think it can be easily updated later. >=20 > Thanks again for working on this! - Jelle Cleaned up and updated the script. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=v2-0001-home-services-Add-symlink-manager.patch Content-Transfer-Encoding: quoted-printable From=202a755c1061098e73975dfd539eb25cb3fff98533 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Thu, 26 Aug 2021 09:39:38 +0300 Subject: [PATCH v2] home-services: Add symlink-manager. * gnu/home-services/symlink-manager.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/symlink-manager.scm. =2D-- gnu/home-services/symlink-manager.scm | 247 ++++++++++++++++++++++++++ gnu/local.mk | 1 + 2 files changed, 248 insertions(+) create mode 100644 gnu/home-services/symlink-manager.scm diff --git a/gnu/home-services/symlink-manager.scm b/gnu/home-services/syml= ink-manager.scm new file mode 100644 index 0000000000..dc409d2ae2 =2D-- /dev/null +++ b/gnu/home-services/symlink-manager.scm @@ -0,0 +1,247 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Andrew Tropin +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; 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 symlink-manager) + #:use-module (gnu home-services) + #:use-module (guix gexp) + + #:export (home-symlink-manager-service-type)) + +;;; Comment: +;;; +;;; symlink-manager cares about configuration files: it backs up files +;;; created by user, removes symlinks and directories created by a +;;; previous generation, and creates new directories and symlinks to +;;; configuration files according to the content of files/ directory +;;; (created by home-files-service) of the current home environment +;;; generation. +;;; +;;; Code: + +(define (update-symlinks-script) + (program-file + "update-symlinks" + #~(begin + (use-modules (ice-9 ftw) + (ice-9 curried-definitions) + (ice-9 match) + (srfi srfi-1)) + (define ((simplify-file-tree parent) file) + "Convert the result produced by `file-system-tree' to less +verbose and more suitable for further processing format. + +Extract dir/file info from stat and compose a relative path to the +root of the file tree. + +Sample output: + +((dir . \".\") + ((dir . \"config\") + ((dir . \"config/fontconfig\") + (file . \"config/fontconfig/fonts.conf\")) + ((dir . \"config/isync\") + (file . \"config/isync/mbsyncrc\")))) +" + (match file + ((name stat) `(file . ,(string-append parent name))) + ((name stat children ...) + (cons `(dir . ,(string-append parent name)) + (map (simplify-file-tree + (if (equal? name ".") + "" + (string-append parent name "/"))) + children))))) + + (define ((file-tree-traverse preordering) node) + "Traverses the file tree in different orders, depending on PREORD= ERING. + +if PREORDERING is @code{#t} resulting list will contain directories +before files located in those directories, otherwise directory will +appear only after all nested items already listed." + (let ((prepend (lambda (a b) (append b a)))) + (match node + (('file . path) (list node)) + ((('dir . path) . rest) + ((if preordering append prepend) + (list (cons 'dir path)) + (append-map (file-tree-traverse preordering) rest)))))) + + (use-modules (guix build utils)) + + (let* ((config-home (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.config= "))) + + (he-path (string-append (getenv "HOME") "/.guix-home")) + (new-he-path (string-append he-path ".new")) + (new-home (getenv "GUIX_NEW_HOME")) + (old-home (getenv "GUIX_OLD_HOME")) + + (new-files-path (string-append new-home "/files")) + ;; Trailing dot is required, because files itself is symlink= and + ;; to make file-system-tree works it should be a directory. + (new-files-dir-path (string-append new-files-path "/.")) + + (home-path (getenv "HOME")) + (backup-dir (string-append home-path "/" + (number->string (current-time)) + "-guix-home-legacy-configs-backup= ")) + + (old-tree (if (file-exists? old-home) + ((simplify-file-tree "") + (file-system-tree + (string-append old-home "/files/."))) + #f)) + (new-tree ((simplify-file-tree "") + (file-system-tree new-files-dir-path))) + + (get-source-path + (lambda (path) + (readlink (string-append new-files-path "/" path)))) + + (get-target-path + (lambda (path) + (string-append home-path "/." path))) + + (get-backup-path + (lambda (path) + (string-append backup-dir "/." path))) + + (directory? + (lambda (path) + (equal? (stat:type (stat path)) 'directory))) + + (empty-directory? + (lambda (dir) + (equal? (scandir dir) '("." "..")))) + + (symlink-to-store? + (lambda (path) + (and + (equal? (stat:type (lstat path)) 'symlink) + (store-file-name? (readlink path))))) + + (backup-file + (lambda (path) + (mkdir-p backup-dir) + (format #t "Backing up ~a..." (get-target-path path)) + (mkdir-p (dirname (get-backup-path path))) + (rename-file (get-target-path path) (get-backup-path path= )) + (display " done\n"))) + + (cleanup-symlinks + (lambda () + (let ((to-delete ((file-tree-traverse #f) old-tree))) + (display + "Cleaning up symlinks from previous home-environment.\= n\n") + (map + (match-lambda + (('dir . ".") + (display "Cleanup finished.\n\n")) + + (('dir . path) + (if (and + (file-exists? (get-target-path path)) + (directory? (get-target-path path)) + (empty-directory? (get-target-path path))) + (begin + (format #t "Removing ~a..." + (get-target-path path)) + (rmdir (get-target-path path)) + (display " done\n")) + (format + #t "Skipping ~a (not an empty directory)... do= ne\n" + (get-target-path path)))) + + (('file . path) + (when (file-exists? (get-target-path path)) + ;; DO NOT remove the file if it is no longer + ;; a symlink to the store, it will be backed + ;; up later during create-symlinks phase. + (if (symlink-to-store? (get-target-path path)) + (begin + (format #t "Removing ~a..." (get-target-pat= h path)) + (delete-file (get-target-path path)) + (display " done\n")) + (format + #t + "Skipping ~a (not a symlink to store)... don= e\n" + (get-target-path path)))))) + to-delete)))) + + (create-symlinks + (lambda () + (let ((to-create ((file-tree-traverse #t) new-tree))) + (map + (match-lambda + (('dir . ".") + (display + "New symlinks to home-environment will be created = soon.\n") + (format + #t "All conflicting files will go to ~a.\n\n" back= up-dir)) + + (('dir . path) + (let ((target-path (get-target-path path))) + (when (and (file-exists? target-path) + (not (directory? target-path))) + (backup-file path)) + + (if (file-exists? target-path) + (format + #t "Skipping ~a (directory already exists)= ... done\n" + target-path) + (begin + (format #t "Creating ~a..." target-path) + (mkdir target-path) + (display " done\n"))))) + + (('file . path) + (when (file-exists? (get-target-path path)) + (backup-file path)) + (format #t "Symlinking ~a -> ~a..." + (get-target-path path) (get-source-path pat= h)) + (symlink (get-source-path path) (get-target-path pa= th)) + (display " done\n"))) + to-create))))) + + (when old-tree + (cleanup-symlinks)) + + (create-symlinks) + + (symlink new-home new-he-path) + (rename-file new-he-path he-path) + + (display " done\nFinished updating symlinks.\n\n"))))) + + +(define (update-symlinks-gexp _) + #~(primitive-load #$(update-symlinks-script))) + +(define home-symlink-manager-service-type + (service-type (name 'home-symlink-manager) + (extensions + (list + (service-extension + home-activation-service-type + update-symlinks-gexp))) + (default-value #f) + (description "Provide an @code{update-symlinks} +script, which creates symlinks to configuration files and directories +on every activation. If an existing file would be overwritten by a +symlink, backs up that file first."))) diff --git a/gnu/local.mk b/gnu/local.mk index bd3aed77e8..91c3b0da3d 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -73,6 +73,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/bootloader/depthcharge.scm \ %D%/ci.scm \ %D%/home-services.scm \ + %D%/home-services/symlink-manager.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ =2D-=20 2.33.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEpA50ACgkQIgjSCVjB 3rBg0Q//aVX25FamMjeS5tdarecXbavq973ZQA4rsZF7I1LuXfcCWbvGlxWIk641 9SPcMCkU0zG9h4nzrW5xlCrcC2NqCZHM2iGY5wbrc5ExHMZXbiq4VCC7S3/KsrMV NHbHgHMD/dczdiUr5AtCVoQYWFpPm3xHl4yKcIYaUZBYyiEizce2+/JII7u8pEXo oQnCdI4B36rwjz/Yky973oDG0UnBush4Cua7fu6SfrutrPkHb292uPoczS0pIuo2 K29UPqFqDrhBZ+J+P4IerL4wC1nfCwMNjD23Y8UxwRiXsda/2wTHiaMAR9mYImMm FRbfMWMi4Ar+goZpRaTdLaHjYN606p5w/j7bzN1uWBH0N3keLbtbNk6C+mWfd/Wi HfBsQhbPH1hcf9BXxXumoO2JAs+jXt2+Rsp2bFbMhKDWnTG1Wc1bMfaqTL4Z74xV kW6+dpJEWR12gOwmUSTAlM/Now1nNmDbU/KL1mDwjnnM9DuZVDmNdKfkvQX16CBp ThSGmOPp3jjUvIfgkgMC5wMbyQ6HiwDrYSYQdCq/l1QC7a2l31NDk2a6QKEdlTs/ LOoDpXgfRNbBc4Kq6wi3+WnFForEYw6NnOZn5YmfAny5Lg6/rtCULswIsPoMcp1U 5Gab/aZGNoghHn8SXGtcNc9ApvGPl1I7dJq5XrguMZ3x7VVKc8Y= =Y18q -----END PGP SIGNATURE----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 11:25:53 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 15:25:53 +0000 Received: from localhost ([127.0.0.1]:52755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdjo-00016r-MN for submit@debbugs.gnu.org; Fri, 27 Aug 2021 11:25:53 -0400 Received: from mail-lf1-f43.google.com ([209.85.167.43]:35677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdjm-00016b-GA for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 11:25:48 -0400 Received: by mail-lf1-f43.google.com with SMTP id l2so7029446lfp.2 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 08:25:46 -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=f6Ra0gXahhwKnl4w16TBQd2ksB3xd3u4fe6q/b1SOd8=; b=onaoqz9bfIUo53vi9LCXDDTVgSwT10/b7ZF/NI9jHwqbYa8AFbqS8VNTTXIskGh2Ef GAYS+r7TJq9wx6qIhR4hnMkJr0Vy8kyYHRsuZXR6jzVOcCYfBwKiVNSeLvDtOUDKJsGM EhUYdhPbm3EYhC0AmYkYaHOoW9G0OupadEsmOV44SnZXX56PrXaCpECCikwF9I3JgKZo Sp/kirLNTTIwGpyap/b2oj5D+3c5sR1tRFhivNYYJMzCEMotQ2a6FdSK1aGwL/qoCYoJ 6fymsDGwjBxht7tklMZmvf1EfhvemU6sx3FSGdboFPEvWqTGyzNSJYMBl2v5B662dX8e aLlw== 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=f6Ra0gXahhwKnl4w16TBQd2ksB3xd3u4fe6q/b1SOd8=; b=bapYKP8l0/AG0vZIERMzRzhx7tUl79nKpoiQedPnp/Wel563mf7k+GpDE9P21q9Mc/ UmktGgzzcqVvcCoor8l/fxbo0fSGsU4CBADlO/8vJmSUBVNjJuDbAy1xAkwBiOas87m2 TugA936EHkSWjBSATz1MulQuBsHhGc+tUGs8YLhffU//Q9LLplHtqrF/I1x5B/COeSH7 pZ4JKtyJHf7qX0tSQLj2wNM2KDBYzSx71cLN2StT+s/O7Cdsv401z4cuQd3ZIzUBoukt OOZgbu1Gn3CmFr1bDk/Oz3iyrZ/YDwMWwheOe6bNJVe/7MIUuMaRJlZoLqHp6hwFnboB wY1w== X-Gm-Message-State: AOAM531rilMHfSSywzMjQBJMs1L5EF9MmALiSMVh4KR5sSNk7Z8uC7Bd RtPeq6Cu4VhRIZzZcoa3iXBPcw== X-Google-Smtp-Source: ABdhPJwfBb2ViVvkyEdPyvPoGRTkJ0A/jOATGjNr94rWcySpYjS8PVY3YfK3kF3/g6c5zJ0m8xxOkA== X-Received: by 2002:a05:6512:6cd:: with SMTP id u13mr7117253lff.184.1630077940081; Fri, 27 Aug 2021 08:25:40 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id x13sm205975lfq.262.2021.08.27.08.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 08:25:39 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: Re: [PATCH 3/5] home-services: Add shells. In-Reply-To: <87r1efe5eh.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> <87r1efe5eh.fsf@trop.in> Date: Fri, 27 Aug 2021 18:25:36 +0300 Message-ID: <874kbadi4v.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: On 2021-08-27 10:03, Andrew Tropin wrote: > * gnu/home-services/shells.scm > (home-shell-profile-service-type, home-shell-profile-configuration) > (home-bash-service-type, home-bash-configuration, home-bash-extension) > (home-zsh-service-type [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.43 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.43 listed in list.dnswl.org] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-27 10:03, Andrew Tropin wrote: > * gnu/home-services/shells.scm > (home-shell-profile-service-type, home-shell-profile-configuration) > (home-bash-service-type, home-bash-configuration, home-bash-extension) > (home-zsh-service-type, home-zsh-configuration, home-zsh-extension) > (home-fish-service-type, home-fish-configuration, home-fish-extension): N= ew > variables. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add home-services/shells.scm. > --- > gnu/home-services/shells.scm | 637 +++++++++++++++++++++++++++++++++++ > gnu/local.mk | 1 + > 2 files changed, 638 insertions(+) > create mode 100644 gnu/home-services/shells.scm > > diff --git a/gnu/home-services/shells.scm b/gnu/home-services/shells.scm > new file mode 100644 > index 0000000000..0643019361 > --- /dev/null > +++ b/gnu/home-services/shells.scm > @@ -0,0 +1,637 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2021 Andrew Tropin > +;;; Copyright =C2=A9 2021 Xinglu Chen > +;;; > +;;; 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 shells) > + #:use-module (gnu services configuration) > + #:use-module (gnu home-services configuration) > + #:use-module (gnu home-services) > + #:use-module (gnu packages shells) > + #:use-module (gnu packages bash) > + #:use-module (guix gexp) > + #:use-module (guix packages) > + #:use-module (srfi srfi-1) > + #:use-module (srfi srfi-26) > + #:use-module (ice-9 match) > + > + #:export (home-shell-profile-service-type > + home-shell-profile-configuration > + > + home-bash-service-type > + home-bash-configuration > + home-bash-extension > + > + home-zsh-service-type > + home-zsh-configuration > + home-zsh-extension > + > + home-fish-service-type > + home-fish-configuration > + home-fish-extension)) > + > +;;; Commentary: > +;;; > +;;; This module contains shell related services like Zsh. > +;;; > +;;; Code: > + > + > +;;; > +;;; Shell profile. > +;;; > + > +(define path? string?) > +(define (serialize-path field-name val) val) > + > +(define-configuration home-shell-profile-configuration > + (profile > + (text-config '()) > + "\ > +@code{home-shell-profile} is instantiated automatically by > +@code{home-environment}, DO NOT create this service manually, it can > +only be extended. > + > +@code{profile} is a list of strings or gexps, which will go to > +@file{~/.profile}. By default @file{~/.profile} contains the > +initialization code, which have to be evaluated by login shell to make > +home-environment's profile avaliable to the user, but other commands > +can be added to the file if it is really necessary. > + > +In most cases shell's configuration files are preferred places for > +user's customizations. Extend home-shell-profile service only if you > +really know what you do.")) > + > +(define (add-shell-profile-file config) > + `(("profile" > + ,(mixed-text-file > + "shell-profile" > + "\ > +HOME_ENVIRONMENT=3D$HOME/.guix-home > +. $HOME_ENVIRONMENT/setup-environment > +$HOME_ENVIRONMENT/on-first-login\n" > + (serialize-configuration > + config > + (filter-configuration-fields > + home-shell-profile-configuration-fields '(profile))))))) > + > +(define (add-profile-extensions config extensions) > + (home-shell-profile-configuration > + (inherit config) > + (profile > + (append (home-shell-profile-configuration-profile config) > + extensions)))) > + > +(define home-shell-profile-service-type > + (service-type (name 'home-shell-profile) > + (extensions > + (list (service-extension > + home-files-service-type > + add-shell-profile-file))) > + (compose concatenate) > + (extend add-profile-extensions) > + (default-value (home-shell-profile-configuration)) > + (description "Create @file{~/.profile}, which is used > +for environment initialization of POSIX compliant login shells. This > +service type can be extended with a list of strings or gexps."))) > + > +(define (serialize-boolean field-name val) "") > +(define (serialize-posix-env-vars field-name val) > + #~(string-append > + #$@(map > + (match-lambda > + ((key . #f) > + "") > + ((key . #t) > + #~(string-append "export " #$key "\n")) > + ((key . value) > + #~(string-append "export " #$key "=3D" #$value "\n"))) > + val))) > + > + > +;;; > +;;; Zsh. > +;;; > + > +(define-configuration home-zsh-configuration > + (package > + (package zsh) > + "The Zsh package to use.") > + (xdg-flavor? > + (boolean #t) > + "Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes > +@file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}. > +Shell startup process will continue with > +@file{$XDG_CONFIG_HOME/zsh/.zshenv}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set for the Zsh session= ." > + serialize-posix-env-vars) > + (zshenv > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zshenv}. > +Used for setting user's shell environment variables. Must not contain > +commands assuming the presence of tty or producing output. Will be > +read always. Will be read before any other file in @env{ZDOTDIR}.") > + (zprofile > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zprofile}. > +Used for executing user's commands at start of login shell (In most > +cases the shell started on tty just after login). Will be read before > +@file{.zlogin}.") > + (zshrc > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zshrc}. > +Used for executing user's commands at start of interactive shell (The > +shell for interactive usage started by typing @code{zsh} or by > +terminal app or any other program).") > + (zlogin > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zlogin}. > +Used for executing user's commands at the end of starting process of > +login shell.") > + (zlogout > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.zlogout}. > +Used for executing user's commands at the exit of login shell. It > +won't be read in some cases (if the shell terminates by exec'ing > +another process for example).")) > + > +(define (add-zsh-configuration config) > + (let* ((xdg-flavor? (home-zsh-configuration-xdg-flavor? config))) > + > + (define prefix-file > + (cut string-append > + (if xdg-flavor? > + "config/zsh/." > + "") <>)) > + > + (define (filter-fields field) > + (filter-configuration-fields home-zsh-configuration-fields > + (list field))) > + > + (define (serialize-field field) > + (serialize-configuration > + config > + (filter-fields field))) > + > + (define (file-if-not-empty field) > + (let ((file-name (symbol->string field)) > + (field-obj (car (filter-fields field)))) > + (if (not (null? ((configuration-field-getter field-obj) config))) > + `(,(prefix-file file-name) > + ,(mixed-text-file > + file-name > + (serialize-field field))) > + '()))) > + > + (filter > + (compose not null?) > + `(,(if xdg-flavor? > + `("zshenv" > + ,(mixed-text-file > + "auxiliary-zshenv" > + (if xdg-flavor? > + "source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zshen= v\n" > + ""))) > + '()) > + (,(prefix-file "zshenv") > + ,(mixed-text-file > + "zshenv" > + (if xdg-flavor? > + "export ZDOTDIR=3D${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n" > + "") > + (serialize-field 'zshenv) > + (serialize-field 'environment-variables))) > + (,(prefix-file "zprofile") > + ,(mixed-text-file > + "zprofile" > + "\ > +# Setups system and user profiles and related variables > +source /etc/profile > +# Setups home environment profile > +source ~/.profile > + > +# It's only necessary if zsh is a login shell, otherwise profiles will > +# be already sourced by bash > +" > + (serialize-field 'zprofile))) > + > + ,@(list (file-if-not-empty 'zshrc) > + (file-if-not-empty 'zlogin) > + (file-if-not-empty 'zlogout)))))) > + > +(define (add-zsh-packages config) > + (list (home-zsh-configuration-package config))) > + > +(define-configuration/no-serialization home-zsh-extension > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (zshrc > + (text-config '()) > + "List of strings or gexps.") > + (zshenv > + (text-config '()) > + "List of strings or gexps.") > + (zprofile > + (text-config '()) > + "List of strings or gexps.") > + (zlogin > + (text-config '()) > + "List of strings or gexps.") > + (zlogout > + (text-config '()) > + "List of strings or gexps.")) > + > +(define (home-zsh-extensions original-config extension-configs) > + (home-zsh-configuration > + (inherit original-config) > + (environment-variables > + (append (home-zsh-configuration-environment-variables original-confi= g) > + (append-map > + home-zsh-extension-environment-variables extension-configs)= )) > + (zshrc > + (append (home-zsh-configuration-zshrc original-config) > + (append-map > + home-zsh-extension-zshrc extension-configs))) > + (zshenv > + (append (home-zsh-configuration-zshenv original-config) > + (append-map > + home-zsh-extension-zshenv extension-configs))) > + (zprofile > + (append (home-zsh-configuration-zprofile original-config) > + (append-map > + home-zsh-extension-zprofile extension-configs))) > + (zlogin > + (append (home-zsh-configuration-zlogin original-config) > + (append-map > + home-zsh-extension-zlogin extension-configs))) > + (zlogout > + (append (home-zsh-configuration-zlogout original-config) > + (append-map > + home-zsh-extension-zlogout extension-configs))))) > + > +(define home-zsh-service-type > + (service-type (name 'home-zsh) > + (extensions > + (list (service-extension > + home-files-service-type > + add-zsh-configuration) > + (service-extension > + home-profile-service-type > + add-zsh-packages))) > + (compose identity) > + (extend home-zsh-extensions) > + (default-value (home-zsh-configuration)) > + (description "Install and configure Zsh."))) > + > + > +;;; > +;;; Bash. > +;;; > + > +(define-configuration home-bash-configuration > + (package > + (package bash) > + "The Bash package to use.") > + (guix-defaults? > + (boolean #t) > + "Add sane defaults like reading @file{/etc/bashrc}, coloring output > +for @code{ls} provided by guix to @file{.bashrc}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set for the Bash sessio= n." > + serialize-posix-env-vars) > + (bash-profile > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bash_profile= }. > +Used for executing user's commands at start of login shell (In most > +cases the shell started on tty just after login). @file{.bash_login} > +won't be ever read, because @file{.bash_profile} always present.") > + (bashrc > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bashrc}. > +Used for executing user's commands at start of interactive shell (The > +shell for interactive usage started by typing @code{bash} or by > +terminal app or any other program).") > + (bash-logout > + (text-config '()) > + "List of strings or gexps, which will be added to @file{.bash_logout}. > +Used for executing user's commands at the exit of login shell. It > +won't be read in some cases (if the shell terminates by exec'ing > +another process for example).")) > + > +;; TODO: Use value from (gnu system shadow) > +(define guix-bashrc > + "\ > +# Bash initialization for interactive non-login shells and > +# for remote shells (info \"(bash) Bash Startup Files\"). > + > +# Export 'SHELL' to child processes. Programs such as 'screen' > +# honor it and otherwise use /bin/sh. > +export SHELL > + > +if [[ $- !=3D *i* ]] > +then > + # We are being invoked from a non-interactive shell. If this > + # is an SSH session (as in \"ssh host command\"), source > + # /etc/profile so we get PATH and other essential variables. > + [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile > + > + # Don't do anything else. > + return > +fi > + > +# Source the system-wide file. > +source /etc/bashrc > + > +# Adjust the prompt depending on whether we're in 'guix environment'. > +if [ -n \"$GUIX_ENVIRONMENT\" ] > +then > + PS1=3D'\\u@\\h \\w [env]\\$ ' > +else > + PS1=3D'\\u@\\h \\w\\$ ' > +fi > +alias ls=3D'ls -p --color=3Dauto' > +alias ll=3D'ls -l' > +alias grep=3D'grep --color=3Dauto'\n") > + > +(define (add-bash-configuration config) > + (define (filter-fields field) > + (filter-configuration-fields home-bash-configuration-fields > + (list field))) > + > + (define (serialize-field field) > + (serialize-configuration > + config > + (filter-fields field))) > + > + (define* (file-if-not-empty field #:optional (extra-content #f)) > + (let ((file-name (symbol->string field)) > + (field-obj (car (filter-fields field)))) > + (if (or extra-content > + (not (null? ((configuration-field-getter field-obj) config= )))) > + `(,(object->snake-case-string file-name) Didn't add object->snake-case-string function to this patch series, will add it in v2. > + ,(mixed-text-file > + (object->snake-case-string file-name) > + (if extra-content extra-content "") > + (serialize-field field))) > + '()))) > + > + (filter > + (compose not null?) > + `(("bash_profile" > + ,(mixed-text-file > + "bash_profile" > + "\ > +# Setups system and user profiles and related variables > +# /etc/profile will be sourced by bash automatically > +# Setups home environment profile > +if [ -f ~/.profile ]; then source ~/.profile; fi > + > +# Honor per-interactive-shell startup file > +if [ -f ~/.bashrc ]; then source ~/.bashrc; fi > +" > + (serialize-field 'bash-profile) > + (serialize-field 'environment-variables))) > + > + ,@(list (file-if-not-empty > + 'bashrc > + (if (home-bash-configuration-guix-defaults? config) > + guix-bashrc > + #f)) > + (file-if-not-empty 'bash-logout))))) > + > +(define (add-bash-packages config) > + (list (home-bash-configuration-package config))) > + > +(define-configuration/no-serialization home-bash-extension > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (bash-profile > + (text-config '()) > + "List of strings or gexps.") > + (bashrc > + (text-config '()) > + "List of strings or gexps.") > + (bash-logout > + (text-config '()) > + "List of strings or gexps.")) > + > +(define (home-bash-extensions original-config extension-configs) > + (home-bash-configuration > + (inherit original-config) > + (environment-variables > + (append (home-bash-configuration-environment-variables original-conf= ig) > + (append-map > + home-bash-extension-environment-variables extension-configs= ))) > + (bash-profile > + (append (home-bash-configuration-bash-profile original-config) > + (append-map > + home-bash-extension-bash-profile extension-configs))) > + (bashrc > + (append (home-bash-configuration-bashrc original-config) > + (append-map > + home-bash-extension-bashrc extension-configs))) > + (bash-logout > + (append (home-bash-configuration-bash-logout original-config) > + (append-map > + home-bash-extension-bash-logout extension-configs))))) > + > +(define home-bash-service-type > + (service-type (name 'home-bash) > + (extensions > + (list (service-extension > + home-files-service-type > + add-bash-configuration) > + (service-extension > + home-profile-service-type > + add-bash-packages))) > + (compose identity) > + (extend home-bash-extensions) > + (default-value (home-bash-configuration)) > + (description "Install and configure GNU Bash."))) > + > + > +;;; > +;;; Fish. > +;;; > + > +(define (serialize-fish-aliases field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . value) > + #~(string-append "alias " #$key " \"" #$value "\"\n")) > + (_ "")) > + val))) > + > +(define (serialize-fish-abbreviations field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . value) > + #~(string-append "abbr --add " #$key " " #$value "\n")) > + (_ "")) > + val))) > + > +(define (serialize-fish-env-vars field-name val) > + #~(string-append > + #$@(map (match-lambda > + ((key . #f) > + "") > + ((key . #t) > + #~(string-append "set " #$key "\n")) > + ((key . value) > + #~(string-append "set " #$key " " #$value "\n"))) > + val))) > + > +(define-configuration home-fish-configuration > + (package > + (package fish) > + "The Fish package to use.") > + (config > + (text-config '()) > + "List of strings or gexps, which will be added to > +@file{$XDG_CONFIG_HOME/fish/config.fish}.") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set in Fish." > + serialize-fish-env-vars) > + (aliases > + (alist '()) > + "Association list of aliases for Fish, both the key and the value > +should be a string. An alias is just a simple function that wraps a > +command, If you want something more akin to @dfn{aliases} in POSIX > +shells, see the @code{abbreviations} field." > + serialize-fish-aliases) > + (abbreviations > + (alist '()) > + "Association list of abbreviations for Fish. These are words that, > +when typed in the shell, will automatically expand to the full text." > + serialize-fish-abbreviations)) > + > +(define (fish-files-service config) > + `(("config/fish/config.fish" > + ,(mixed-text-file > + "fish-config.fish" > + #~(string-append "\ > +# if we haven't sourced the login config, do it > +status --is-login; and not set -q __fish_login_config_sourced > +and begin > + > + set --prepend fish_function_path " > + #$fish-foreign-env > + "/share/fish/functions > + fenv source $HOME/.profile > + set -e fish_function_path[1] > + > + set -g __fish_login_config_sourced 1 > + > +end\n\n") > + (serialize-configuration > + config > + home-fish-configuration-fields))))) > + > +(define (fish-profile-service config) > + (list (home-fish-configuration-package config))) > + > +(define-configuration/no-serialization home-fish-extension > + (config > + (text-config '()) > + "List of strings or gexps for extending the Fish initialization file.= ") > + (environment-variables > + (alist '()) > + "Association list of environment variables to set.") > + (aliases > + (alist '()) > + "Association list of Fish aliases.") > + (abbreviations > + (alist '()) > + "Association list of Fish abbreviations.")) > + > +(define (home-fish-extensions original-config extension-configs) > + (home-fish-configuration > + (inherit original-config) > + (config > + (append (home-fish-configuration-config original-config) > + (append-map > + home-fish-extension-config extension-configs))) > + (environment-variables > + (append (home-fish-configuration-environment-variables original-conf= ig) > + (append-map > + home-fish-extension-environment-variables extension-configs= ))) > + (aliases > + (append (home-fish-configuration-aliases original-config) > + (append-map > + home-fish-extension-aliases extension-configs))) > + (abbreviations > + (append (home-fish-configuration-abbreviations original-config) > + (append-map > + home-fish-extension-abbreviations extension-configs))))) > + > +;; TODO: Support for generating completion files > +;; TODO: Support for installing plugins > +(define home-fish-service-type > + (service-type (name 'home-fish) > + (extensions > + (list (service-extension > + home-files-service-type > + fish-files-service) > + (service-extension > + home-profile-service-type > + fish-profile-service))) > + (compose identity) > + (extend home-fish-extensions) > + (default-value (home-fish-configuration)) > + (description "\ > +Install and configure Fish, the friendly interactive shell."))) > + > + > +(define (generate-home-shell-profile-documentation) > + (generate-documentation > + `((home-shell-profile-configuration > + ,home-shell-profile-configuration-fields)) > + 'home-shell-profile-configuration)) > + > +(define (generate-home-bash-documentation) > + (generate-documentation > + `((home-bash-configuration > + ,home-bash-configuration-fields)) > + 'home-bash-configuration)) > + > +(define (generate-home-zsh-documentation) > + (generate-documentation > + `((home-zsh-configuration > + ,home-zsh-configuration-fields)) > + 'home-zsh-configuration)) > + > +(define (generate-home-fish-documentation) > + (string-append > + (generate-documentation > + `((home-fish-configuration > + ,home-fish-configuration-fields)) > + 'home-fish-configuration) > + "\n\n" > + (generate-documentation > + `((home-fish-extension > + ,home-fish-extension-fields)) > + 'home-fish-extension))) > + > +;; (display (generate-home-shell-profile-documentation)) > +;; (display (generate-home-bash-documentation)) > +;; (display (generate-home-zsh-documentation)) > diff --git a/gnu/local.mk b/gnu/local.mk > index e24da4716f..dc0e732114 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -76,6 +76,7 @@ GNU_SYSTEM_MODULES =3D \ > %D%/home-services/symlink-manager.scm \ > %D%/home-services/fontutils.scm \ > %D%/home-services/configuration.scm \ > + %D%/home-services/shells.scm \ > %D%/image.scm \ > %D%/packages.scm \ > %D%/packages/abduco.scm \ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEpA/AACgkQIgjSCVjB 3rCWLg//TNp7Axgv68YStSS6kPMqM1lk8rvyw8Fwge4xQayHMvCbWt9gO2FV6uH9 5uZa6kV0FIKFfE5FpiJujkwkBELR33mWfPEWMhLSS9tZnXsCoSJ/jT1yULqTt75Z QRvn1r8xZESqimUu3MU7lLrwcqFfd+VfKIWWiFjTl2dORXtsEl/pnuqJsN0wOOpp wSpYFbr18qY319gSXJG8vUeNgx1bdQFGlLDTr6z+bQCzU63HGoXP5GJGw5K1Mg21 hMVQKdqoUuGUqKuBri45JpMjGPFBYuZkOyObS6LNEDPPsYHfN2X4gPGouuKDdPWJ NlvCNeAK9Z7bpUYzBCkGua7N/VZfQVn51gD21PMzthmNNKKxPz+TkQjuXpCDjPJw XKMmvOgn9yfr1jotIiH1M0z8Lvynj+XPXuV8NC+6hyZ4pqn0a4AzbnvYG2klpkN+ lV6+95UhvWRgrXXYbZRR/McEHC2sNAjrflVGNaIW1wL/daCaqZFw31Qenxf5k8sw 2FuR86fRqdprjaUpZUNxebTgf5cNwTR7+SCogk2GPz+a9NeO0jIASE/x07VA4YS8 msIR+J5vYPvA+W9UR8pvz0eqtNF3mvYmRhjmB22iDwbhY5AVsXVSXJ2xWtzrtdgC GufLG2ZapTi48ppVPn/l5hLU35uLlSFd0WjIexG8nv0F9nVo3P0= =fRhY -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 11:28:26 2021 Received: (at 50208) by debbugs.gnu.org; 27 Aug 2021 15:28:26 +0000 Received: from localhost ([127.0.0.1]:52759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdmM-0001As-1F for submit@debbugs.gnu.org; Fri, 27 Aug 2021 11:28:26 -0400 Received: from mail-lj1-f180.google.com ([209.85.208.180]:42836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdmK-0001Ac-DM for 50208@debbugs.gnu.org; Fri, 27 Aug 2021 11:28:24 -0400 Received: by mail-lj1-f180.google.com with SMTP id h1so12062170ljl.9 for <50208@debbugs.gnu.org>; Fri, 27 Aug 2021 08:28:24 -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=5P5LBdhOlCgzZBT2+1hCJjecwpsZWrqkI218lt+A7uU=; b=ugndr1NAafLOlIeO/ZKKLbpJEKqfdk4tIiq34pvOyUVXQK5dnq0uaIf3e/+TyBtNGE RGczonwKr/h0qj1couISyr7MSU2yJyPVvhH7xWIW6U7u//eocJ3qndxJhwWbIRD6PVoC 2Cr64HdzWLYvSy1aDl83n2nS1tB569lfV2ibKcN2CN/GZMvmrLqrM3XBOHaGtUXiH0xT lP9bzMEXcLWLIfh2jjHF52qBjIxlH2T3XWYQeKQq37PEdfa0zLdXwPBUxPFVe22CiYc/ +MYxLsWW0uk1OZWclAOxEe31IcPN7Mwi0kn7jf7OLQjR7++/Tv9dcFtCyQmRzUdZM+zT nmow== 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=5P5LBdhOlCgzZBT2+1hCJjecwpsZWrqkI218lt+A7uU=; b=GFqRSkKltdlfVUWvKtOAtqYgRIH1mMQYg9NG9GPQ0+cPdJhWRAD4EWSB+0YW38g+J6 QMg9A5/WQ26z3Ft20TrjUhOQcQ6STOHCGOd/0tSmsCt0mbGwSCnQYPE8E2QmMMa6YZ68 XFgI9nXrTq3+pJD+UruU5PljB+gokqnVazipvbmCRlRD6Nf14NJCmuHgdtnnWY0gmoFS LgwGRU7qpeeGQIf0DaEHsxMe9r0xkpIa7CXfxwQY94GnlwLYvKsvTN5ET159LNbwmNR2 Wk02l6wVnBn9dN5/VfxZydLb4jK32bj9QVyVLquVr/ZNF5g9X4YafE6Qsr0cUn+wAYIu eQAQ== X-Gm-Message-State: AOAM5323Hr0tbQsv5IOjLNAMP5nA/Rj5aaV8/m9cls8vKrb93GrMwutr XsOToziWh8BHgLyUmmi8X786RnASxDWZ1A== X-Google-Smtp-Source: ABdhPJx6DYxdjL8/NBa1MSOLR3LMx+1msOI4PsnwPNkN/KkF0pK88TNFmUT9EQ0lPXvQ939kFdhSRg== X-Received: by 2002:a2e:a4d1:: with SMTP id p17mr8220116ljm.82.1630078098675; Fri, 27 Aug 2021 08:28:18 -0700 (PDT) Received: from localhost ([109.252.93.92]) by smtp.gmail.com with ESMTPSA id j1sm716842lji.124.2021.08.27.08.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 08:28:18 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: Re: [PATCH 0/5] Add home-environment and related services In-Reply-To: <871r6ffklu.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> Date: Fri, 27 Aug 2021 18:28:14 +0300 Message-ID: <871r6edi0h.fsf@trop.in> 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: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain On 2021-08-27 09:49, Andrew Tropin wrote: > On 2021-08-26 13:58, Oleg Pykhalov wrote: > >> I applied your patch, replaces tabs with spaces, modified commit message >> according to GNU standards, added the file to gnu/local.mk for >> compilation (I forgot to do it for previous patch series, apologies). >> >> >> I would like to squash the patch for home-services.scm with a previous >> series (hope force push will work), but I should ask you could I do it? >> Otherwise I could just push two patches to wip-guix-home. >> >> Updated patches are attached below. > > On top of the patches above I made a new patch series, which introduces > home-environment and a set of default services, which are expected to be > present in most Guix Home configurations. > > Andrew Tropin (5): > home-services: Add fontutils. > home-services: Add helper functions for service configurations. > home-services: Add shells. > home-services: Add xdg. > home: Add home-environment. > > gnu/home-services/configuration.scm | 63 +++ > gnu/home-services/fontutils.scm | 65 +++ > gnu/home-services/shells.scm | 637 ++++++++++++++++++++++++++++ > gnu/home-services/xdg.scm | 475 +++++++++++++++++++++ > gnu/home.scm | 97 +++++ > gnu/local.mk | 5 + > 6 files changed, 1342 insertions(+) > create mode 100644 gnu/home-services/configuration.scm > create mode 100644 gnu/home-services/fontutils.scm > create mode 100644 gnu/home-services/shells.scm > create mode 100644 gnu/home-services/xdg.scm > create mode 100644 gnu/home.scm Is it ok to keep discussion and review of the patch series in this thread or better create a new ticket for that? I posted it here, because it relies on symlink-manager, but not sure if it's handy for reviewers. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEpBI8ACgkQIgjSCVjB 3rBJKw/5ATNrX8qzWxeEY3KoU9gw41VECGTgJ5mx6iZ7HZU0H65mlgXc8jjxBWq6 pdxL1s8zwM917FaPV7iQrRPqOwwJVyzhIOIgZdL+F6ChHw5FXQcu/2jjffZ3CgvV 59wF1uEcOQhAiNr38AK1Ow0YME4NwP6rH0dcKq/MwwJ2RoATVzXuGBOSiDZ9gkxm fDMAi+v4z3LQas5F9nqbje6ZBj/4RGw3arGKfIH1K3FZN+tEg2hcmWhfe/NGC/DV e9SbWoXEtnlYVvyGPSQ31MAAlmuVD1AfY5H6o8Ln+6u61lGdel0JXAWVBEn/DsHw Oz98HQo6PrCYP3n7/O6Hv+PUrYwUV04TlcH9QA0+6lBWZtSl4r3rTKQlH6C7JUry ZuHhd1QW5Fow64KL+mUvfgTIobvRIwDS33m96DO5l2c78Wxam+8M/hrgzyyCB+rp t/8727wylEFtrWZT7aQdQZl+k3sILFR0j0Dai17LXUjU9CSY/ckTl4b8ixw6a+LH q1R2ylPhAEsvEgP6P5QAUvAPo/E7ZQIyWUY5Wq9hcYM5pGR0T9HwBFJnpqlP9H1d zMfp+Ozdz6GtpL+/SGw9stFIlpEZG2GFJo+7R/SYncCuJPukQMKs+v4+cf6+zDSo ar5849E9OWTHyMMM9ftu8v+7VPB1r66cRazpxbkE2FHzRvBlzrY= =KF4c -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 27 15:15:40 2021 Received: (at 50208-done) by debbugs.gnu.org; 27 Aug 2021 19:15:40 +0000 Received: from localhost ([127.0.0.1]:53034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJhKB-0007FG-Hv for submit@debbugs.gnu.org; Fri, 27 Aug 2021 15:15:40 -0400 Received: from mail-lj1-f174.google.com ([209.85.208.174]:37721) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJhK5-0007Ez-Sc for 50208-done@debbugs.gnu.org; Fri, 27 Aug 2021 15:15:34 -0400 Received: by mail-lj1-f174.google.com with SMTP id d16so13200665ljq.4 for <50208-done@debbugs.gnu.org>; Fri, 27 Aug 2021 12:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=La176WNjfere28PCtv7+yf2X/pxzoQvYMAEHYFL3l2I=; b=tCQ72eJkIc8i/UsLuWIULBk5bUM0VXSV60QXpipT92hNeBQn4QvZz3tbkAQ6ViXPIx vRod9RQjLiKbDc15gMyBABkwZsH7M6YgzRBACtewcRALL8GQKfMQqERjyhmnbOadKQdn a8vCLjLdhdEcF223+EeX8sVDEbPgrVY7r1XFhDBpMvqUpLwahQTTRTJimLOQ59IZlhpg 7dQZUKMj9INLraNvwui9+FyJyAXlFf/afbu7gripVUU9VMquQ5ej4KzqUiSY0acy2dsp FSu1EqYJ7d4O5QgZKoB14NRBAxG4D9yfPpkgI828bne6sNY6M6R3rUbFEpGlZxhooJFy xIQw== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=La176WNjfere28PCtv7+yf2X/pxzoQvYMAEHYFL3l2I=; b=nxE9Dbw5skh2H8TCahzPbWa1WDdfSNkUygtaaYk51nW8taeTmCBcFvB84Sx+CVgah2 nL4WNTqVeGtbqwNBDSokv8j++ZXoaqrFMCPRUOD/Y7YMNJlKlf39vWmdOUFkHvXnjRvI scSX9Gpnd8MESK9BPb3fiLN2vKk1dfwO2Nz8XEcCnf5tMNA2MHZs9RmV/f94PgMgU0P7 yII0H5ZQ4fqmcxp1EAyXMV0yAwHKWhnp/7Zju3YzeEvrC3Xwlm/PA5RkGPHPT5QGVwXb HTPvl7gGcZ7I0j6zZWUvcY2PhDtBsOJ4YwVXE35BBd+4eg7O2hJgxW1R0R5h5ut6pcQf Y/PA== X-Gm-Message-State: AOAM530B22f1Qv2Ja5NSeKYzsDKzwGekE2f6Rkryx5u9EBNesDLWr/Oa pH5QjwEwhbtsTgXGYUPTl4ti0YkBnOI= X-Google-Smtp-Source: ABdhPJwL13orQMUwXfyWn7YVC9eX11YhR7ZpjxPK0rqJEb52sdlW0p901judXltAcueSUw6P09CnjQ== X-Received: by 2002:a2e:8e62:: with SMTP id t2mr9085264ljk.477.1630091723432; Fri, 27 Aug 2021 12:15:23 -0700 (PDT) Received: from guixsd ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id bn3sm842224ljb.18.2021.08.27.12.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 12:15:22 -0700 (PDT) From: Oleg Pykhalov To: Andrew Tropin Subject: Re: [PATCH 0/5] Add home-environment and related services References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> <871r6edi0h.fsf@trop.in> Date: Fri, 27 Aug 2021 22:15:18 +0300 In-Reply-To: <871r6edi0h.fsf@trop.in> (Andrew Tropin's message of "Fri, 27 Aug 2021 18:28:14 +0300") Message-ID: <87v93q3dix.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) 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: 50208-done Cc: 50208-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Andrew Tropin writes: [=E2=80=A6] >> On top of the patches above I made a new patch series, which introduces >> home-environment and a set of default services, which are expected to be >> present in most Guix Home configurations. I added a copyright in gnu/home-services/configuration.scm and a copyright line in gnu/local.mk files. From=20gnu/home-services/shells.scm removed 3 comment lines at the bottom, because I don't see this practice in other Guix documentation generation functions: =2D-8<---------------cut here---------------start------------->8--- ;; (display (generate-home-shell-profile-documentation)) ;; (display (generate-home-bash-documentation)) ;; (display (generate-home-zsh-documentation)) =2D-8<---------------cut here---------------end--------------->8--- In gnu/home.scm and gnu/home-services/xdg.scm alligned define-record-type* with Emacs's =E2=80=98M-x aggressive-indent-mode=E2=80= =99 and =E2=80=98M-x align-regexp=E2=80=99 . Unfortunately force push is disallowed, removed origin/wip-guix-home and pushed again with squashed local.mk and slightly modified commit messages (missing dots at the commit messages). [=E2=80=A6] > Is it ok to keep discussion and review of the patch series in this > thread or better create a new ticket for that? > > I posted it here, because it relies on symlink-manager, but not sure if > it's handy for reviewers. I think it's OK to keep discussion here, because every patch is a part of guix-home. Not a strong opinion on that. I'll close the issue for now, it should reopen in case you send an email to 50208@debbugs.gnu.org Oleg. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEpOcYUHGdvLndpZ3Vz dEBnbWFpbC5jb20ACgkQFn+OpQAa+pzGRRAAskrX3YGeDq8HY1OFKuDVhJpHMcIe jRo/7s51OvkZXPLyrsC579N+Z27wiFD4clOnq6f03hEuftqnS1hv+y/SXclQxRjJ t+X7Ym2f5yzplJg6BNp3ZS/HdfTweDMVxaHvRpyNX3OadUWdCkr1NwkT/P4QC7Uv MiiDBerNsfxHQlmlcdiP3OWhYGVwJGgYUDq6E9P6ALOrLG+hX1t4S8+1PdEL80ye EF7380GtnhaBNrJsAWWHqR+YfFDcxCIB3jGodd7mHS2Ff59XL+TTkjm2B29JgaAO p/012FhODHcZmHUpl5+IEp2XmN2lujB2izc5oJISolWvC8FxgcWuSxCq/RsTTxqg VI5JRyrO2sOlmzggwBL0x+GaExRhTNwPjKCZYlftxD+XQN1jVDovA3H2H73PPE0C T1FgaPPe7bNo39HvBB5H7Tyt5boNhu8ghXRrFjXcZAUVikPFVc/rDptK1i/B7yCK Alj2BntsfwxALdU9XGzfq0rLUb3cxqBM/z4bpIABv0xcfGW81cwfo2f6FA6cHRts /9qJWauZO9WTocqpQuhGWPL09VLckxtUYWnJ06os1MyNY6e9JIMQFuIag57UIR4j c4oJiFS621pItki9lr6TkTaoruuAOseWfcopANgHRhs6XzDBpP4MWoaCd91/Knu4 WQPYa0c0UV95dck= =XxgN -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 28 06:44:51 2021 Received: (at 50208) by debbugs.gnu.org; 28 Aug 2021 10:44:51 +0000 Received: from localhost ([127.0.0.1]:53456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJvpT-00034N-D7 for submit@debbugs.gnu.org; Sat, 28 Aug 2021 06:44:51 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:44848 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJvpR-000348-2w for 50208@debbugs.gnu.org; Sat, 28 Aug 2021 06:44:49 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1630147476; bh=arrWOYvTTChcJyEpx7Hfe23R84CoMkLYEZVrN51tZLs=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=fsHjC0lSJZxXjJArSl54IwmRfI8qknflutG3+FSFnGqqHcZomyxS/k8quudd0jjUG mOzAAr9wx4bEIKuQV6LgQj36uURqxfHJrOOx4pWwBs0A93wxpcKPbSPq/Jngt6W6pw Kc8Cksxt4lmv0hgoZrd7YOttOIMeFba9Gk1cpH0I= To: Andrew Tropin , Oleg Pykhalov Subject: Re: [bug#50208] [PATCH 5/5] home: Add home-environment. In-Reply-To: <87lf4ne56w.fsf@trop.in> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> <87lf4ne56w.fsf@trop.in> Date: Sat, 28 Aug 2021 12:44:35 +0200 Message-ID: <87mtp1vofg.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Score: 2.9 (++) 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: On Fri, Aug 27 2021, Andrew Tropin wrote: > * gnu/home.scm > (home-environment, home-environment?, this-home-environment) > (home-environment-derivation, home-environment-user-services) > (home-environment-essential-services, home-environment [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.9 (++) 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: On Fri, Aug 27 2021, Andrew Tropin wrote: > * gnu/home.scm > (home-environment, home-environment?, this-home-environment) > (home-environment-derivation, home-environment-user-services) > (home-environment-essential-services, home-environment [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 1.0 BULK_RE_SUSP_NTLD Precedence bulk and RE: from a suspicious TLD -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 27 2021, Andrew Tropin wrote: > * gnu/home.scm > (home-environment, home-environment?, this-home-environment) > (home-environment-derivation, home-environment-user-services) > (home-environment-essential-services, home-environment-services) > (home-environment-location, home-environment-with-provenance): New variab= les. > * gnu/local.mk (GNU_SYSTEM_MODULES): Add home.scm. > --- > gnu/home.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > gnu/local.mk | 1 + > 2 files changed, 98 insertions(+) > create mode 100644 gnu/home.scm > > diff --git a/gnu/home.scm b/gnu/home.scm > new file mode 100644 > index 0000000000..220cc49846 > --- /dev/null > +++ b/gnu/home.scm > @@ -0,0 +1,97 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; 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) > + #:use-module (gnu home-services) > + #:use-module (gnu home-services symlink-manager) > + #:use-module (gnu home-services shells) > + #:use-module (gnu home-services xdg) > + #:use-module (gnu home-services fontutils) > + #:use-module (gnu services) > + #:use-module (guix records) > + #:use-module (guix diagnostics) > + > + #:export (home-environment > + home-environment? > + this-home-environment > + > + home-environment-derivation > + home-environment-user-services > + home-environment-essential-services > + home-environment-services > + home-environment-location > + > + home-environment-with-provenance)) > + It should probably have a =E2=80=98Commentary=E2=80=99 section. Maybe some= thing like This module provides a record for managing per-user packages and 'dotfiles'. ? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmEqE5MVHHB1YmxpY0B5 b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x53NUP/Rnxqd2dNrpbH9oKQBtLm7IyXVSW HugeTcYq0u4k5xW9Qm3mUg8hg4TnBuXsRMji18Q+Gx/lS0SMmqgKIyg0AyBXIzaS WWVK6sGaDWv1SnmmbOYsKdNVTBJCssFk4F5w8Esy2vxRR7CT6XaVaoQKZAka4vHB 4VXwP9iXPmZgL4+Tcee26DGBnxOAH+M23Sax98Tw7ieKd6VWuVRUGx21MwdHYaA1 hcPlUzmJqhZVuoXHpilZwXM01bNNVlnm83g/kulz/UGIC26k+v7sIWcCkj6CEL9B HOcfBVJr9MpljYglrQabz31AYwuyXOTr/B/MfYkST7JhT9BxBcDYwd75RfcS+POI aW/YaXL4RmTRJ6fb5mabNDuxKxhbAF1VYL9gxtT1o5oa/5vrX/Gvt8KXObkn+q9C amI3SRl6ABrGCEgM7LnAxpsG1y8fvLPJzMpxrQ2LV/Ww5ipy1nymopY2yiooOPaz AK+GyUpKUzULcwQ7bRPYxpWtg3++f3snBAQUryKwMVilVVpbcR3RS0sCvqopO2t8 caoijQvJRSalamydhOShCvq4Dzc2/KIfZgoH4934gY05th/pSQFH0ke3ERh68kly VyL5h8zIquVEJ9/hHJkMjyQMEn7Ezd/Fv6LXJ0T9st4k0Mz0Li+S3dl6qGSZPPgq lZjZMeXQP3D/SqWu =A+CL -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 05:10:45 2021 Received: (at 50208) by debbugs.gnu.org; 30 Aug 2021 09:10:46 +0000 Received: from localhost ([127.0.0.1]:58129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKdJV-0002cv-LU for submit@debbugs.gnu.org; Mon, 30 Aug 2021 05:10:45 -0400 Received: from mail-lj1-f169.google.com ([209.85.208.169]:34664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKdJT-0002ch-6c for 50208@debbugs.gnu.org; Mon, 30 Aug 2021 05:10:43 -0400 Received: by mail-lj1-f169.google.com with SMTP id f2so24723086ljn.1 for <50208@debbugs.gnu.org>; Mon, 30 Aug 2021 02:10:43 -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=SjLSMIPMFcmkovFeNJfPVPG3aCqKrQBnCs7YAIyhKrY=; b=eyRbg5O/MYBgRr/L1ZmugxBQDfdzEzSX5ajArTyhXgsV86UQnt5GPk0hFD9uO3M7n9 pEV2o+RmJMpHFBy/FTVqYHs1l9lvquoeqlRvcwxtpsrP+dlo6HNHmABs1YkzTCA/lcwq tAglvoH+hQlRyTcMagNrn6IfJnKOtdljHCRTyVOCkcZuR/Y+pAMg31ty5sZvhmSfofDt YeSdvOv3WlavuTxtVOblIYMWQOrn5G8+nO4Pm1uTVhuC4RUCdSTT7OLKIbh7AHkBNdCs 2/edz1ztozeeNlteQFpHx8NeBJulHUl2Zbmzhqn6oQDTV7zPTDSw73Dh1lqQPTbCVMqH 4q1Q== 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=SjLSMIPMFcmkovFeNJfPVPG3aCqKrQBnCs7YAIyhKrY=; b=NocqHieVjYsoJRB6Md3i0YJJg2Ncwh12nMsCWqD/W411uBVs9+GiwVZ5cihTmQAeCm 5g+H5TeChCosIgbZoC7txgg9jUNEzup8MJOng+mNX4+I9eMu96gMHj1HVNrYGqeeKn1h Jd6Ark1BjFfIX83fkLMeJdL/UIKI/a8A/PqSAIkWxN8imskQM3bX550cRA8FZZuoEjwh +UZENt836JnafkfLzzasdcl2TWFEjNuKl9y+RJyjAVYoHiWzH3DVB1TMDXtNTwg3q+uF ixXqUJvjJHu0L4sw+Om8BxXzJ0esEEgh1oWg+cfxZD3qO3mPorNJ8qzam4DUgw0vSP/l rTbQ== X-Gm-Message-State: AOAM532d6U8fNmVus+ZGMv9KaBdFGFLIRdEoRFEntETmVZcmFcJleWMM 46HJl9bptOoIRTeo7Le/SnrOag== X-Google-Smtp-Source: ABdhPJwmNS+TYx4NsWSW3tO7mCaEVhP2vg01Vuetj48Qs6vDUtCqfJk8g0S+Dn9r4nqnau+5WkVE3w== X-Received: by 2002:a2e:555:: with SMTP id 82mr20355892ljf.245.1630314637162; Mon, 30 Aug 2021 02:10:37 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id c10sm1340917lfm.271.2021.08.30.02.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 02:10:36 -0700 (PDT) From: Andrew Tropin To: Xinglu Chen , Oleg Pykhalov Subject: Re: [bug#50208] [PATCH 5/5] home: Add home-environment. In-Reply-To: <87mtp1vofg.fsf@yoctocell.xyz> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <871r6ffklu.fsf@trop.in> <87lf4ne56w.fsf@trop.in> <87mtp1vofg.fsf@yoctocell.xyz> Date: Mon, 30 Aug 2021 12:10:33 +0300 Message-ID: <87ilzn8fhy.fsf@trop.in> 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: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-28 12:44, Xinglu Chen wrote: > On Fri, Aug 27 2021, Andrew Tropin wrote: > >> * gnu/home.scm >> (home-environment, home-environment?, this-home-environment) >> (home-environment-derivation, home-environment-user-services) >> (home-environment-essential-services, home-environment-services) >> (home-environment-location, home-environment-with-provenance): New varia= bles. >> * gnu/local.mk (GNU_SYSTEM_MODULES): Add home.scm. >> --- >> gnu/home.scm | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ >> gnu/local.mk | 1 + >> 2 files changed, 98 insertions(+) >> create mode 100644 gnu/home.scm >> >> diff --git a/gnu/home.scm b/gnu/home.scm >> new file mode 100644 >> index 0000000000..220cc49846 >> --- /dev/null >> +++ b/gnu/home.scm >> @@ -0,0 +1,97 @@ >> +;;; GNU Guix --- Functional package management for GNU >> +;;; 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) >> + #:use-module (gnu home-services) >> + #:use-module (gnu home-services symlink-manager) >> + #:use-module (gnu home-services shells) >> + #:use-module (gnu home-services xdg) >> + #:use-module (gnu home-services fontutils) >> + #:use-module (gnu services) >> + #:use-module (guix records) >> + #:use-module (guix diagnostics) >> + >> + #:export (home-environment >> + home-environment? >> + this-home-environment >> + >> + home-environment-derivation >> + home-environment-user-services >> + home-environment-essential-services >> + home-environment-services >> + home-environment-location >> + >> + home-environment-with-provenance)) >> + > > It should probably have a =E2=80=98Commentary=E2=80=99 section. Maybe so= mething like > > This module provides a record for managing per-user > packages and 'dotfiles'. > > ? Thank you for the idea, added a doc comment. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEsoIkACgkQIgjSCVjB 3rBoqA//Y0gUiBWtPlkfS/ph39Ul3oNM4vBZ1OTRn5tXhpA6zNHIfWMPV1LYNZpN U4SGYg0cnM2WcxQHNocWs676HjP99IQLglqDEcOQbsbSPSg1reT9AJlN0wYo1wZq eYAmLjluvcoDMTa7OX0kPDp8+DMG/gFyy5L6LlY+vYxPyA2ricRmSuyNsIq+On9w iQktMKompWz1S5EsgQ3Ig1an46jxbxBSxhThl0w9DDaYyKbecgYS595YrEjYhcbp dlxwFxEyqPdOnWVJvVUc0nahlsKxaUnjwUvXUTGynNTBZqn1nyZxo+dJjSOrFY0g 7IWCMhK2gUGEpmLGJz9zZDWTDwKFlpICAaxQAg1NU0dJ+zx0XTIPxylnNt5iFcUs pYgTV+RYtOs+M80m7KOYhlIjPK75Z0ou41O+xlLBFPJcLnefLbRsl70T67owS6ne GMagPtDr5rsAp8YiQYNLmUFBpmaQkUnFfuoj74L4h8ZwI4StLsXVbn79LmysXUBl CdyXZZ449zJTjT13C/QEFgTogCuh3lmaza9y9Pz/MD15TVc+qMVA3qp7uZ5mh0EK LLXMb2eZRzmJmSHoJAfit/+Kz6yJPFYknlu//aGWFKcuOFL/i68JkeN3AJroTCBA lAI18sXHamXhlxaPtU410V7+NzBNazehHc5Wso73rf9W4ZUQoPY= =SG8Z -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 05:40:18 2021 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 To: Oleg Pykhalov Subject: [PATCH 0/4] Fixes and improvements for home-services 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-Spam-Score: 2.0 (++) 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: There are a few follow up patches for the current wip-guix-home branch: - Add utils ns with helpers for converting cases, which was missing. - Fix issue with creating first home-environment generation [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.43 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.43 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --==-=-= 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----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 06:28:44 2021 Received: (at 50208) by debbugs.gnu.org; 30 Aug 2021 10:28:44 +0000 Received: from localhost ([127.0.0.1]:58266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKeWx-0004hs-7z for submit@debbugs.gnu.org; Mon, 30 Aug 2021 06:28:44 -0400 Received: from mail-lf1-f52.google.com ([209.85.167.52]:33354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKeWq-0004hH-Jw for 50208@debbugs.gnu.org; Mon, 30 Aug 2021 06:28:41 -0400 Received: by mail-lf1-f52.google.com with SMTP id p38so30351110lfa.0 for <50208@debbugs.gnu.org>; Mon, 30 Aug 2021 03:28:36 -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=RZ5cQHgZDlUjDx9Xdqh3xhQA/a20Ka0+4mK618FpnOQ=; b=IGzqGc7k0CkkJ0kW8Y6Cijxj+Gz3cr4ZtAwG8oc56iVvOig7S399qCH1yojn4Q7eJH fWsfYLIHcnNpgFPg7fJS0dqCXjFWRXNBDwbw9Iw/H6NdLA6yNB+ae68Y/mc7v38Cmb+Y a87jsriXJ3m5vPBHuBtnd+QlVp4lwRhZVOWQgXpAdjVUT3Y157LALyda/M/+oFeno9vm 7ZvBGn5hcb/SriTNsKaN0vIz88I1GFziDYNGH1MbTf5EyCqMO0RYS24oA4+KuJYKnfJ3 /5DKpsWaNWMzno5qQLBnqPnw37hRkPB6uePji/4+PQ1FeLb4P6TOF2lTg0mbKLEXkOZa hgow== 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=RZ5cQHgZDlUjDx9Xdqh3xhQA/a20Ka0+4mK618FpnOQ=; b=t23MJacOdAKfaXVPT1zEQz6btbnxOYgmsHbXcGYhgb8bRmcxu0ckKAnWnHzpuWJT35 n0qQ7hK6vnQ9C1J8p07nattwbcZSOLxEvYqL+qNPF3qa95Sb+AgEbaJxzFtTrNgx5X8h K31ZH0XaTkd9WjMzp4XK7vv8UQkwDVDNg3SAKwq95jWaWGy1eitcxh2pTqoUubohjEjb Botvm5W+nSY3FBr+UTxnp07NHV4/5MQKRxfnXyvlHqzpvC6sWcZBPZguk9hPdIqfKRJB 0cYuRPtWFPqR6PiraLPF65EdL+2bqQLJvsifEHp9DoOPogBCdxdKfE9KKlt9kfZCjY9O x1tQ== X-Gm-Message-State: AOAM533nLuvyvsIoo5eoNWkj+uFc3SZg0f5Jei5NwFP/jm4FZKNxpKoD gKyM/4078e44zgmL/JfcMHqCMA== X-Google-Smtp-Source: ABdhPJz78xA3MIJuymgp/uwrButnYQe9E+97QRXRqTy29nxbzFm/4B7RL6UW4TzqkoEIKEidr8kH2A== X-Received: by 2002:a05:6512:3d8e:: with SMTP id k14mr15155698lfv.430.1630319310469; Mon, 30 Aug 2021 03:28:30 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id h4sm1789827ljk.4.2021.08.30.03.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 03:28:29 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: [PATCH v2 0/5] Fixes and improvements for home-services In-Reply-To: <87r1eg8obm.fsf@gmail.com> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> Date: Mon, 30 Aug 2021 13:28:26 +0300 Message-ID: <87czpv8bw5.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 2.0 (++) 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: Changes since v1: Added missing import to xdg via a separate commit. Added trailing dots to commit messages. Andrew Tropin (5): 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 d [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.52 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.52 listed in wl.mailspike.net] X-Debbugs-Envelope-To: 50208 Cc: 50208@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Changes since v1: Added missing import to xdg via a separate commit. Added trailing dots to commit messages. Andrew Tropin (5): 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. home-services: xdg: Add missing import. 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-services/xdg.scm | 1 + gnu/home.scm | 8 +++ 6 files changed, 90 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=v2-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 v2 1/5] 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=v2-0002-home-services-symlink-manager-Properly-handle-1st.patch Content-Transfer-Encoding: quoted-printable From=20710a4983790ecdae7aa53acb5361669b6061e551 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:23:48 +0300 Subject: [PATCH v2 2/5] 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=v2-0003-home-services-activation-Add-support-for-multilin.patch Content-Transfer-Encoding: quoted-printable From=2078b9527c368549af63d8fb987d7f9ce3e472d6ae Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:26:19 +0300 Subject: [PATCH v2 3/5] home-services: activation: Add support for multiline env 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=v2-0004-gnu-home-Add-doc-comment-about-the-module.patch Content-Transfer-Encoding: quoted-printable From=20e2257d5b134a52b67a2e4b3b1e95b73eef975401 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 12:07:48 +0300 Subject: [PATCH v2 4/5] 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: text/x-patch Content-Disposition: inline; filename=v2-0005-home-services-xdg-Add-missing-import.patch Content-Transfer-Encoding: quoted-printable From=202c7a295468aecd4f40e98ac0651800f561d89a71 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Mon, 30 Aug 2021 13:22:16 +0300 Subject: [PATCH v2 5/5] home-services: xdg: Add missing import. =2D-- gnu/home-services/xdg.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/gnu/home-services/xdg.scm b/gnu/home-services/xdg.scm index 6e4a2542a3..535c8667a1 100644 =2D-- a/gnu/home-services/xdg.scm +++ b/gnu/home-services/xdg.scm @@ -26,6 +26,7 @@ #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix i18n) + #:use-module (guix diagnostics) =20 #:use-module (ice-9 match) #:use-module (srfi srfi-1) =2D-=20 2.33.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEsssoACgkQIgjSCVjB 3rBbrRAAg+ZQDx6cKdcXMbIfp1zw5TL8UsyPdCYLoVe1rB9zo9Mt5MreMQRUZBi0 1jjLZoCGcoKnmxs4HvaNyti2oCZm6suS+W4K7f2mzMJ+CJRkTZrh1XkojuubopjX lf/9TB56a29QAPpl7v52Ew6D3OY5xcnEZl08uOJBwmCp7+X6AE1YprJxOQfd2PZx t6RIdfKOy7K+lI1Lu53h9Mn4iprK1jgLY0wWJnFyIrSRpWgwR70yaglh9m6Cpjub AC5EUO+SgSxhL+ZVXS5/Z9ph5E4YHIeQVulz1ADZYuGiJ+XRLiFwzEk3PPy8jX8m Gl07n3cMcy5Y3Xfqp0qlGdTXRA7BIfVoDgW5308WXSPYRe6sm+ovRwKSpaxlsi3p 4kzkme2QEBf6OJNWl1IqwWSXwWlr8U+jttbF4j8+LqSnzQPsnJLzSeAmeGpiKA1W MphgMCjbq/KDgOW+DYGIcc6okQDKUJ0sryuRHcytgQAYnGtrKI98pWbZWY/XgA9X eyIOWj0YzNEW7LTdfFAZh1x5ireLlYHKCQiPx+BLFFWriCEXRNov7xotEBkGaHy1 LGLorwEjh1ejt/Mat/ZyBLdeRRioKxTYW4xFxT2TCFTS0MIhMXaclXB8jgGgZJB3 QTMvHT/WZDDMjZH8gAn6Sw41uKMLfkoYQEyn6LJIyFIfDaQighw= =KKS4 -----END PGP SIGNATURE----- --==-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 30 19:19:43 2021 Received: (at 50208-done) by debbugs.gnu.org; 30 Aug 2021 23:19:44 +0000 Received: from localhost ([127.0.0.1]:60590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKqZ5-0005BW-Mu for submit@debbugs.gnu.org; Mon, 30 Aug 2021 19:19:43 -0400 Received: from mail-lf1-f44.google.com ([209.85.167.44]:40895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKqZ3-0005BI-Do for 50208-done@debbugs.gnu.org; Mon, 30 Aug 2021 19:19:42 -0400 Received: by mail-lf1-f44.google.com with SMTP id bq28so34562299lfb.7 for <50208-done@debbugs.gnu.org>; Mon, 30 Aug 2021 16:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=qi+JsKK8yaFpWMlOrX1MzWkPBUhq15eMKJK845XpXy8=; b=tEoUKBOw9NH1DxOHO0xRpQ3uM1sq2Ga+h3/N2lFsSI7Zhqg8D88+05oddoZdidxxMw ltqNaq489n2rFhJkBFIWGe+ECx0q0al2ygGQ4Tp+lhhOILleG50tWRRvtt3pymMFl2pO y0/hSUb8+tiQdSIZFvIlSJtY9ElR5caG8ubimhl9rbLeOt7HfLHOfR0sju+MhxhdtibO T+fDsE1raUQPtVfH1PPHR0tRb0mn/DhJU97wxHBWpz9bkfMcLKfgEqhTiKg9jhCO6yXL gDcyC2UCPb3K8k4EQlIsm/6IajnxuGrlztq12HJPWk+8KT9wF891JicejzfZJfFLiOAe wpFg== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=qi+JsKK8yaFpWMlOrX1MzWkPBUhq15eMKJK845XpXy8=; b=W1E8byvrXTrisgYw1rqx1QWGaeJBYQIZTD1CbolfQcl8d5PhcwabPzO3nwpsPPobwb j4HlFCU3C1WPjVvJSitst9wjhQbzbrReoaoC7n+ZIxohxJf7znwikjZOj9L5euoB3IdR NmNVI4qVpGhsFuLpC7Whw8aumcB/bwq/qrEHP4IP1+fJyfhZ6tLE3TEjFa44UVXT3bwm R1F1hRm9lNrmFlM1V9jEgJ2Ro/BTQOTDUxAXZxxApEF+/+olIPDi3c741BBGFbap3+em CGv4UbfI/xsUjHjlQ9H+TN5f4sVf8ys9AsCSDqg9GF+TpqtNoFyUdAGjdSVIVY7vGl+i 5tFA== X-Gm-Message-State: AOAM531UGLQR+psRQqyJkVTmQQTnT4x1HPE/2It7Xrr3rFpG6VMtBrdo xObsqaQ97fgVd/LGzCnp6w30OuLEmHQ= X-Google-Smtp-Source: ABdhPJyOlkHCu/RA4CChcW8dTK8YGnq8LEv1thGGQBYqbPFSC4yiP8mumGHAZLqiQYhXnamCDkyj/w== X-Received: by 2002:a05:6512:b91:: with SMTP id b17mr6982327lfv.453.1630365575042; Mon, 30 Aug 2021 16:19:35 -0700 (PDT) Received: from guixsd ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id f16sm2139901ljq.81.2021.08.30.16.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 16:19:34 -0700 (PDT) From: Oleg Pykhalov To: Andrew Tropin Subject: Re: bug#50208: [PATCH] home-services: Add symlink-manager References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <87czpv8bw5.fsf@trop.in> Date: Tue, 31 Aug 2021 02:19:31 +0300 In-Reply-To: <87czpv8bw5.fsf@trop.in> (Andrew Tropin's message of "Mon, 30 Aug 2021 13:28:26 +0300") Message-ID: <87pmtu8qrg.fsf_-_@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) 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: 50208-done Cc: 50208-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Andrew Tropin writes: > Changes since v1: > Added missing import to xdg via a separate commit. > Added trailing dots to commit messages. > > Andrew Tropin (5): > 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. > home-services: xdg: Add missing import. > > 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-services/xdg.scm | 1 + > gnu/home.scm | 8 +++ > 6 files changed, 90 insertions(+), 3 deletions(-) > create mode 100644 gnu/home-services/utils.scm > > --=20 > 2.33.0 [=E2=80=A6] Tabified local.mk, pushed to wip-guix-home. Oleg. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEcjhxI46s62NFSFhXFn+OpQAa+pwFAmEtZ4MUHGdvLndpZ3Vz dEBnbWFpbC5jb20ACgkQFn+OpQAa+pyJZRAAu2tBEHCMrNX07/8aWDLihrgcHCeb xeuxt4vKCozTuERruDNj51/IvAXK+IOqyPz83r6Bv4k5EKUM7Cw2m+3WHFJeypsn L3qZ1STAVqt+j1QWskdzPh8TLHDKOqZUP7oj7YYE9Owo509eLp8X8UwXZX7I+Dv7 BCAOIvvGqPvafwqzoaPNzqI8yC4Uug1DJQsdnvl/ALjHKV3L4ZI103DuhQ+i/XaT qOg7VpEd9YWGhM8dzu02Bxng6HS232IDCQG13eLtZySreyvkGJ0NIFUQOD92wxoO IGF0hTi6IwXZpap2Tl0hPR/9IqFWSVjg5KBJp4Bw+77KsFfZ9LQSpE4AFqdryMaH XR9ET/CqVgyh4D3Z0cSg5Ssjzs/Q4AIl9UlJITfylG/0NO5ql2aPlUw6ib/sTElw RHByZUP+j+rW39k51qiTIZJXWtlBvu2FHUPLoDh4qZ7E+7A6o3KTwI6eWTmsZpq2 ns0DN8NHAMEYCHTtAaM1g+AsltnQB2ljENHJOJHv/Q9UprnGm2aBy3Y4Ax5CSONh MNLPcwG8UPdj1elD/S3zEhDEULtTKw7wiIl94e0yQAbZt8E7U/lSOWJ8+gxOg4c7 YNKrWbI8hFBm0dtD9VJ8UcO0zNBChSt2oB88tK5Jx//oR3BKVF6ea2uOizT5Zjto VIBvUrUFTFJ/8dM= =YQ/G -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 31 03:03:20 2021 Received: (at 50208-done) by debbugs.gnu.org; 31 Aug 2021 07:03:20 +0000 Received: from localhost ([127.0.0.1]:60978 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxnk-0004c2-1n for submit@debbugs.gnu.org; Tue, 31 Aug 2021 03:03:20 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:40507) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKxnj-0004bk-51 for 50208-done@debbugs.gnu.org; Tue, 31 Aug 2021 03:03:19 -0400 Received: by mail-lf1-f46.google.com with SMTP id bq28so36397419lfb.7 for <50208-done@debbugs.gnu.org>; Tue, 31 Aug 2021 00:03:19 -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=Ig+WaWurFLHtFrp3lsHZ5W3ZlQs88tnrHTD64ZbbGzI=; b=byvOy7VJcFuucvTmF+YP7Xmdqc4QHmSkSjZjAGcNWe6Q4oRHVx8lsgJouD+URafuzR Hm30pj+iE0iEC8lgQsRDeuSwp3b3t/y5JU9B6kB9yHPKQaBvwRFR6RyC2Sjb1nam9Q8q lZQgK9zNqaFeLjqgh6u9ShvBb4mdX5E2lhWyOb4h3QzQdud36y+T7gjTC9ZgiIludWRl 1UpJrH6qpExQE7snDkG2lLqA3vXgW+nB0ClUSgddZD68LHmlNVvw8kiv88J6lKj2K6Xd Ldv/OLhfcHpQlmCZqejKauFVjZKXM5dFAabsN0WJ8cxiRXDg6M30I/BD5otSSN0nQ+WQ CDfA== 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=Ig+WaWurFLHtFrp3lsHZ5W3ZlQs88tnrHTD64ZbbGzI=; b=eQI8n+9K+MHqy1Tw+/TSQET3cJC2dDLbDPTQbAzvH5xBkGersR9av3nEoi4MDlVwaV T1ZhOv3pxNKr188/pMor//9pyqZM5nius4txU72JDO5u8dTrJ8VWfAgQo8Zlgf64rJrU y2vu7GF6JTUQBvw2M9fL82sBy8E1NFDCBkqS6Oj2Aokvv4FZQGHqpPl6qt0Ulx7PSqKS uHhXRZRgfyR5FGIGxctNeKixqcPNAhCdMjPkfiXAqCZOBLtGl1NtLGlQPky/8sLlRBbZ IiEUBHVrI/rLKqv4kBNV/ASu5anbo+poXg0a4d+LKsUBsJ25VLT8eHpL0RZfmGeIxNuI Pwpg== X-Gm-Message-State: AOAM532kZUGPHZM6w0UlWqwA0RDum3tf+zDF/DhERufFiNcQypc2JUwc qlV0N7DAGea76uYAICKULLOHeQ== X-Google-Smtp-Source: ABdhPJxEq1Cmt11vEgcfSgW1K+AAdjhHpV381LUlslPuI2G5rG7Ial5dvm1xv2GvrQbCPQHnHOS5Ew== X-Received: by 2002:a05:6512:ad3:: with SMTP id n19mr441928lfu.297.1630393393126; Tue, 31 Aug 2021 00:03:13 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id bi37sm1637037lfb.35.2021.08.31.00.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 00:03:12 -0700 (PDT) From: Andrew Tropin To: Oleg Pykhalov Subject: Re: bug#50208: [PATCH] home-services: Add symlink-manager In-Reply-To: <87pmtu8qrg.fsf_-_@gmail.com> References: <87bl5kbsk8.fsf@trop.in> <87r1eg8obm.fsf@gmail.com> <87czpv8bw5.fsf@trop.in> <87pmtu8qrg.fsf_-_@gmail.com> Date: Tue, 31 Aug 2021 10:03:08 +0300 Message-ID: <877dg2jdub.fsf@trop.in> 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: 50208-done Cc: 50208-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2021-08-31 02:19, Oleg Pykhalov wrote: > Andrew Tropin writes: > >> Changes since v1: >> Added missing import to xdg via a separate commit. >> Added trailing dots to commit messages. >> >> Andrew Tropin (5): >> 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. >> home-services: xdg: Add missing import. >> >> 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-services/xdg.scm | 1 + >> gnu/home.scm | 8 +++ >> 6 files changed, 90 insertions(+), 3 deletions(-) >> create mode 100644 gnu/home-services/utils.scm >> >> --=20 >> 2.33.0 > > [=E2=80=A6] > > Tabified local.mk, pushed to wip-guix-home. > > Oleg. It seems we are finished with basic home-services, refactoring and preparing CLI now, will send it in a separate thread. Thank you very much!) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmEt1CwACgkQIgjSCVjB 3rDT2A//XGL7dh+QFzhqM0jFT3mkD1qC++tAVzj4DQLg1BeCxTUgKW7+SeZSoLje yPERDKxvsOBD+WSI9IyJTBumaumhDa49xmtu3Su1yT3TRFms9dbl8QqVueHfAecc W8Z0wkDymeaj0oZUvrzdy/JPJTShr6tBO5U5uB3YSGkSJlIwruAEgq94+MuV8cr3 YI4kKN2DAAHFzD1MxuUJ1bonw0qWOsJ9m8JBg3sE1fD1vyIbzpsvpoLnoBRLYNhH augjUtg2gxIkS3RiRZsdYpsExwwRF/L6OUae+Cg1QDS729sk4tyrBo+WLXKa0jKD +nh/gt/tiMEEV/s/UBK9y47Ly1j+QoF/mp0UocoK5s2yJuCUY7nzASq3rf8nJzSX lw0bNdh9oriK1s5MuovhGnoFEK6dU4Ifs3NNDmZTCcIoNJxqXjph/U0AUWjXV2lU 3C0AEF7dYeIX+UUHvViRLm2Ql8fFTGPnPRpW2ZvwQRjIUSDaNcnCUDeVoKmvUr4/ v8NE2h/VLAcCh1ILDTrl5k37tUo6KESpcgNY2LB/SqNRDFyXwVrklexemgbz/YRj MOi0Lg0oQFMV11b4RU+4QJqmAbMnSU0UJHn5MulnzW9IKzGlWvX5WlqVFsevXdMm Mmrh6Az/8txi7u+FK3q/wsl3Si/1KtUYLX74ppK1LpBW5L3Eqng= =rxjX -----END PGP SIGNATURE----- --=-=-=-- From unknown Thu Jun 19 13:56:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 28 Sep 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator