From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CAYqCW79KmIbRwEAgWs5BA (envelope-from ) for ; Fri, 11 Mar 2022 08:42:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MDrpAW79KmKJXAEAG6o9tA (envelope-from ) for ; Fri, 11 Mar 2022 08:42:38 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2508736195 for ; Fri, 11 Mar 2022 08:42:37 +0100 (CET) Received: from localhost ([::1]:49582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSZv2-0001xm-3p for larch@yhetil.org; Fri, 11 Mar 2022 02:42:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSZuV-0001sy-Eb for bug-guix@gnu.org; Fri, 11 Mar 2022 02:42:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42484) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSZuU-0006Y4-DC for bug-guix@gnu.org; Fri, 11 Mar 2022 02:42:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSZuU-00013c-Bj for bug-guix@gnu.org; Fri, 11 Mar 2022 02:42:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52808: Guix home should not assume that all targets are dot files Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 11 Mar 2022 07:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52808 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 52808-submit@debbugs.gnu.org id=B52808.16469845014030 (code B ref 52808); Fri, 11 Mar 2022 07:42:02 +0000 Received: (at 52808) by debbugs.gnu.org; 11 Mar 2022 07:41:41 +0000 Received: from localhost ([127.0.0.1]:36381 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSZu8-00012v-K6 for submit@debbugs.gnu.org; Fri, 11 Mar 2022 02:41:41 -0500 Received: from mail-lj1-f181.google.com ([209.85.208.181]:38647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSZu5-00012e-8x for 52808@debbugs.gnu.org; Fri, 11 Mar 2022 02:41:38 -0500 Received: by mail-lj1-f181.google.com with SMTP id s25so10993251lji.5 for <52808@debbugs.gnu.org>; Thu, 10 Mar 2022 23:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=yvyD4Or/dc3kSMQyPu20xK4rd2cZosJvOpo1gSwY7/s=; b=w6EMxyt0PjPvaZ2Hqr1sTjkoO3PquxGmUvogyHEcKpY/utTwUlpX8kK6snRydRgyJB yECUV7YyjnPuRl2dGhNFTBs5soICtkOVK3BQBSIgdCvEIOzjzz0Jj0J6CLO+M+/qisWZ 5s99WYZdII0IHihlb5KyaDFSmrNZCutRzMvSCxj1JqatIgkG6VABo1Mhh9f+D/jIFuWG G4WnJqemisEIrc81zCXXlIteTtC+J9MWLVd8h70W0SdvWa2PgN/HUCMHCv/qpuda1dS0 rqoaW3CuGXzMLpGcvBhq4UFm8w7tOBe4Kaz1YbpKbyItZ4T+RAMTqMPa6cudyDIePB/q 2EPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=yvyD4Or/dc3kSMQyPu20xK4rd2cZosJvOpo1gSwY7/s=; b=3FBw5PFces/19sRzFl/pJMUN7Q5+5Oqb1uWBIJ27eEEeg1GaEjSb5TlMjh8uVzeHLO BfvtJxcPkz9+eHEtZ3yf3z9y/Yo76uUfomXXqF4ocNbCvGE62OY//4WluQiqV89UG7jt 4eDODfyHtAZUagHeOBTvyX7jd2P4nxaQaRYT7HiWttSc5/XhaVwgsNV2jV2WbAkzThkz eoHLa5xXxtCI4aahpMZ8eqCbJSa/9eap7qOBrgkAGhef2qTW3hzeR8MjOJLpkrAnYJaj 5xyQ3+g7TseiRuIdK/gFtv5pMWV+jGf5ugvPD4MDcrV4bdT0FFFGvF/Czr1/kbQKfda3 li+A== X-Gm-Message-State: AOAM531YF68R9AFZtBIHgKzcMumUuvvX4bso/rh36SuXaVyOEiZ7Tn+u GEkD9rCTS5S8PsOv+ggh7Oxkwg== X-Google-Smtp-Source: ABdhPJxh3v4jpAkj8nudUdOj7aAZ/eQ/dx2SLJJiQ/Wxs02xDFOjuw76tufPirGuLDj/hqKuFEZ7lA== X-Received: by 2002:a2e:7c13:0:b0:247:feee:d202 with SMTP id x19-20020a2e7c13000000b00247feeed202mr5122292ljc.35.1646984490915; Thu, 10 Mar 2022 23:41:30 -0800 (PST) Received: from localhost (109-252-135-33.dynamic.spd-mgts.ru. [109.252.135.33]) by smtp.gmail.com with ESMTPSA id a19-20020a2e88d3000000b00246585ccd51sm1582122ljk.14.2022.03.10.23.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 23:41:30 -0800 (PST) From: Andrew Tropin In-Reply-To: <871qzgm33o.fsf@gnu.org> References: <6050c325-9ae9-406a-97fe-91bdf9bcd12a@www.fastmail.com> <87bkzw2kvm.fsf@trop.in> <87o83t9mf8.fsf@gnu.org> <878rutzo1d.fsf@trop.in> <87zgn1bsha.fsf@gnu.org> <87r189s8mz.fsf@trop.in> <871qzgm33o.fsf@gnu.org> Date: Fri, 11 Mar 2022 10:41:26 +0300 Message-ID: <87o82dkkbd.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 52808@debbugs.gnu.org, Nick Zalutskiy Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646984557; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=yvyD4Or/dc3kSMQyPu20xK4rd2cZosJvOpo1gSwY7/s=; b=V0KsV5ekHQ5IliywX6VD+pk8BbkW9chqyF5apkxcY6mPsT7KpinSTr+wBPd900RtYAwlqN +6MpqU9Ia8RfZSeCq78kyw+1oyP1w5DWIMAaaSYuRtoOWjZcSGFPn1NhulXM34Z5Hb/Iwa jiiMpUTkvR5+VIHHrA2XkUxd4B6G+1w5tfwVxbDq1CW82MF+MBj5WM62CsrYwOJ3GJbiT/ 8m5vRbOM4zcbcHlzQP1NHyIEFfbKTlOtrMUEUUASWwPsiMUdtXtZfPpE/KxOD8tvB9sw49 D0RLxkBb0edBoLcxXPbBAD7l780V8BOfqMZkvlV7rHDPyMDi4eSwmHjXHOAX/w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646984557; a=rsa-sha256; cv=none; b=f3jHizogKGPIQ/cWrPfsfZhe7wTi7V66H5luh/1bihKglDcDZKowpuSYcRTWZ15UhZsHJ2 1RkbqCUt84E9vrdXpRF8X6bIDzIaRKR/IdgRH8xYnUD1LTVQU9F+dItfZM6oaz4b4540nW bO/w+o9MkZucWYlqlvGRzfI/Ub6uRjj/PNZTy0avjRATZeIXiMQjoUh+GcU+1TFt/vam+F i5ACHysRWUBIc3NxuFTaqEPJZwoJ+UqK4TamcyHU+6AFU9OqEHxt+onWIH1iUISxw0F9Hb fuW6WRHVvzNrteArBk4/Q954RE5m5NtWNYJ1zNCp4HiCq5uFxfcpSoj1a+HCug== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=w6EMxyt0; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.39 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=w6EMxyt0; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2508736195 X-Spam-Score: -2.39 X-Migadu-Scanner: scn0.migadu.com X-TUID: iYnyFQ/eNBjV --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-03-05 23:44, Ludovic Court=C3=A8s wrote: > Hi Andrew, > > The patches reached my mailbox around the time I went on vacation and > then fell through the cracks. Sorry about that! > > Andrew Tropin skribis: > >> After that patch series is merged we can give a time for users to >> migrate their self-made home services to xdg-configuration-files and >> after for example 2 weeks, remove special handling of dots for >> home-files. > > Sounds like a plan! > >> From 0cd37bbc724f9c793898c2655bdd1c335045c5f0 Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Fri, 11 Feb 2022 10:55:01 +0300 >> Subject: [PATCH 1/5] home: Explicitly connect home-file and symlink-mana= ger >> services. >> >> * gnu/home/services.scm (home-files-directory): New variable. >> * gnu/home/symlink-manager.scm (update-symlinks-script): Use >> home-files-directory variable from (gnu home services). > > [...] > >> - (description "Configuration files for programs that >> -will be put in @file{~/.guix-home/files}."))) >> + (description (format #f "Files that will be put in >> +@file{~~/.guix-home/~a}, and further processed during activation." >> + home-files-directory)))) > > This hunk would prevent i18n so I suggest dropping it (you can mention > =E2=80=98home-files-directory=E2=80=99 in a margin comment for good measu= re). > > Otherwise LGTM. > Done. > >> From 23f7095d60b18b52de0d1aa314c4012cdf55a046 Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Fri, 11 Feb 2022 11:03:02 +0300 >> Subject: [PATCH 2/5] home: Add home-xdg-configuration-files service. >> >> * gnu/home/services.scm (home-xdg-configuration-files): New variable. > > [...] > >> +(define xdg-configuration-files-subdir "config") >> >> +(define (xdg-configuration-files files) >> + (map (lambda (lst) >> + (cons (string-append xdg-configuration-files-subdir >> + "/" (car lst)) (cdr lst))) >> + files)) > > I=E2=80=99d just call it =E2=80=9C.config=E2=80=9D (instead of =E2=80=9Cc= onfig=E2=80=9D). That way, there > wouldn=E2=80=99t be any special treatment. WDYT? Will be done in next patch series. > > Also: s/subdir/directory/, and please use =E2=80=98match=E2=80=99 instead= of car/cdr > (info "(guix) Coding Style"). Done, done. > > >> + (description (format #f "Files that will be put in >> +@file{~~/.guix-home/~a/~a}, and further processed during activation." >> + home-files-directory >> + xdg-configuration-files)))) > > Same as above: drop =E2=80=98format=E2=80=99 and write ~/.guix-home/files= /.config. > Done. > >> From 11f23a48d480a91d6bfba0ff55c1a9831585a4ee Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Fri, 11 Feb 2022 15:03:44 +0300 >> Subject: [PATCH 3/5] home: shells: Migrate zsh to xdg-configuration-file= s. >> >> * gnu/home/services.scm (home-zsh-service-type): Additionally extend >> home-xdg-configuration-files-service-type. > > [...] > >> From ef4c3bbcc0c8c1a251f4ad6c494f8ed30adf45f2 Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Fri, 11 Feb 2022 15:34:46 +0300 >> Subject: [PATCH 4/5] home: Migrate fountutils and xdg modules to >> xdg-configuration-files. >> >> * gnu/home/services/fontutils.scm (home-fontconfig-service-type): Migrat= e to >> xdg-configuration-files. >> * gnu/home/services/xdg.scm (home-xdg-user-directories-service-type, >> home-xdg-mime-applications-service-type): Migrate to xdg-configuration-f= iles. > > Neat! > >> From 089683bbd301f6e085f00fbd53713f335abac40e Mon Sep 17 00:00:00 2001 >> From: Andrew Tropin >> Date: Fri, 11 Feb 2022 16:14:23 +0300 >> Subject: [PATCH 5/5] home: symlink-manager: Respect XDG_CONFIG_HOME duri= ng >> activation. >> >> * gnu/home/services/symlink-manager.scm (update-symlinks-script): Respect >> XDG_CONFIG_HOME during activation. > > I propose to postpone this one after > , and I even offer to rebase it > myself if you want. :-) > > Could you send updated patches? > > Thanks in advance, and apologies again for the delay! > > Ludo=E2=80=99. Added two minor patches for symlink-manager. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-home-symlink-manager-Use-existing-home-directory-sym.patch Content-Transfer-Encoding: quoted-printable From=203a6dc64d3366aa37507c83c598cbddb0f0815b6d Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Mar 2022 08:43:04 +0300 Subject: [PATCH 1/2] home: symlink-manager: Use existing home-directory symbol. * gnu/home/services/symlink-manager.scm (update-symlinks-script): Use existing home-directory symbol instead of additional getenv call. =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 767b1bdc01..bce5c85b56 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -185,7 +185,7 @@ (define (source-file file) =20 #$%initialize-gettext =20 =2D (let* ((home (string-append (getenv "HOME") "/.guix-home")) + (let* ((home (string-append home-directory "/.guix-home")) (pivot (string-append home ".new")) (new-home (getenv "GUIX_NEW_HOME")) (old-home (getenv "GUIX_OLD_HOME"))) =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-home-symlink-manager-Add-missing-done-word-in-messag.patch Content-Transfer-Encoding: quoted-printable From=20aaef728aaf621884cce49539d47abb09a9f1e32d Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Mar 2022 09:21:41 +0300 Subject: [PATCH 2/2] home: symlink-manager: Add missing 'done' word in message. * gnu/home/services/symlink-manager.scm (update-symlinks-script): Add missi= ng 'done' word in message, keep code width below 80 column. =2D-- gnu/home/services/symlink-manager.scm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index bce5c85b56..eb13d60496 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -107,9 +107,10 @@ (define (strip file) (format #t (G_ "Removing ~a...") file) (delete-file file) (display (G_ " done\n"))) =2D (format #t =2D (G_ "Skipping ~a (not a symlink to store).= .. done\n") =2D file))))) + (format + #t + (G_ "Skipping ~a (not a symlink to store)... done\n= ") + file))))) =20 (const #t) ;down (lambda (directory stat _) ;up @@ -121,14 +122,15 @@ (define (strip file) (format #t (G_ "Removed ~a.\n") directory)) (lambda args (let ((errno (system-error-errno args))) =2D (cond ((=3D ENOTEMPTY errno) =2D (format =2D #t =2D (G_ "Skipping ~a (not an empty directory= )...\n") =2D directory)) =2D ((=3D ENOTDIR errno) #t) =2D (else =2D (apply throw args))))))))) + (cond + ((=3D ENOTEMPTY errno) + (format + #t + (G_ "Skipping ~a (not an empty directory)... do= ne\n") + directory)) + ((=3D ENOTDIR errno) #t) + (else + (apply throw args))))))))) (const #t) ;skip (const #t) ;error #t ;init =2D-=20 2.34.0 --=-=-= Content-Type: text/plain Thank you for cleaning up symlink-manager, now it's much nicer, simplier and I believe easier to maintain. Rebased previous patch series and addressed all the comments. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0001-home-Explicitly-connect-home-file-and-symlink-man.patch Content-Transfer-Encoding: quoted-printable From=201509c974029d161009b35bfd76132a86425bdecc Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Feb 2022 10:55:01 +0300 Subject: [PATCH v2 1/5] home: Explicitly connect home-file and symlink-mana= ger services. * gnu/home/services.scm (home-files-directory): New variable. * gnu/home/symlink-manager.scm (update-symlinks-script): Use home-files-directory variable from (gnu home services). =2D-- gnu/home/services.scm | 22 +++++++++++++--------- gnu/home/services/symlink-manager.scm | 15 +++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 1cd19ce7f9..32b10e99aa 100644 =2D-- a/gnu/home/services.scm +++ b/gnu/home/services.scm @@ -43,6 +43,8 @@ (define-module (gnu home services) home-run-on-change-service-type home-provenance-service-type =20 + home-files-directory + fold-home-service-types home-provenance =20 @@ -74,12 +76,11 @@ (define-module (gnu home services) ;;; file (details described in the manual). ;;; ;;; home-files-service-type is similar to etc-service-type, but doesn't ex= tend =2D;;; home-activation, because deploy mechanism for config files is plugga= ble and =2D;;; can be different for different home environments: The default one is= called =2D;;; symlink-manager (will be introudced in a separate patch series), whi= ch creates =2D;;; links for various dotfiles (like $XDG_CONFIG_HOME/$APP/...) to store= , but is =2D;;; possible to implement alternative approaches like read-only home fro= m Julien's =2D;;; guix-home-manager. +;;; home-activation, because deploy mechanism for config files is pluggable +;;; and can be different for different home environments: The default one = is +;;; called symlink-manager, which creates links for various dotfiles and x= dg +;;; configuration files to store, but is possible to implement alternative +;;; approaches like read-only home from Julien's guix-home-manager. ;;; ;;; home-run-on-first-login-service-type provides an @file{on-first-login}= guile ;;; script, which runs provided gexps once, when user makes first login. = It can @@ -262,11 +263,14 @@ (define (assert-no-duplicates files) =20 (file-union "files" files)) =20 +;; Used by symlink-manager +(define home-files-directory "files") + (define (files-entry files) "Return an entry for the @file{~/.guix-home/files} directory containing FILES." (with-monad %store-monad =2D (return `(("files" ,(files->files-directory files)))))) + (return `((,home-files-directory ,(files->files-directory files)))))) =20 (define home-files-service-type (service-type (name 'home-files) @@ -276,8 +280,8 @@ (define home-files-service-type (compose concatenate) (extend append) (default-value '()) =2D (description "Configuration files for programs that =2Dwill be put in @file{~/.guix-home/files}."))) + (description "Files that will be put in +@file{~~/.guix-home/files}, and further processed during activation."))) =20 (define %initialize-gettext #~(begin diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index eb13d60496..16031ea5d3 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -26,12 +26,11 @@ (define-module (gnu home services symlink-manager) =20 ;;; Comment: ;;; =2D;;; symlink-manager cares about configuration files: it backs up files =2D;;; created by user, removes symlinks and directories created by a =2D;;; previous generation, and creates new directories and symlinks to =2D;;; configuration files according to the content of files/ directory =2D;;; (created by home-files-service) of the current home environment =2D;;; generation. +;;; symlink-manager cares about xdg configurations and other files: it bac= ks +;;; up files created by user, removes symlinks and directories created by a +;;; previous generation, and creates new directories and symlinks to files +;;; according to the content of directories (created by home-files-service= ) of +;;; the current home environment generation. ;;; ;;; Code: =20 @@ -84,7 +83,7 @@ (define (cleanup-symlinks home-generation) ;; store item containing a home generation. (define config-file-directory ;; Note: Trailing slash is needed because "files" is a symlin= k. =2D (string-append home-generation "/files/")) + (string-append home-generation "/" #$home-files-directory "/"= )) =20 (define (strip file) (string-drop file @@ -143,7 +142,7 @@ (define (create-symlinks home-generation) ;; Create in $HOME symlinks for the files in HOME-GENERATION. (define config-file-directory ;; Note: Trailing slash is needed because "files" is a symlin= k. =2D (string-append home-generation "/files/")) + (string-append home-generation "/" #$home-files-directory "/"= )) =20 (define (strip file) (string-drop file =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0002-home-Add-home-xdg-configuration-files-service.patch Content-Transfer-Encoding: quoted-printable From=20e98e5ee520fada9c6d100f40fcafa6358b626365 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Feb 2022 11:03:02 +0300 Subject: [PATCH v2 2/5] home: Add home-xdg-configuration-files service. * gnu/home/services.scm (home-xdg-configuration-files): New variable. =2D-- gnu/home/services.scm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 32b10e99aa..2f441eb968 100644 =2D-- a/gnu/home/services.scm +++ b/gnu/home/services.scm @@ -38,12 +38,14 @@ (define-module (gnu home services) home-profile-service-type home-environment-variables-service-type home-files-service-type + home-xdg-configuration-files-service-type home-run-on-first-login-service-type home-activation-service-type home-run-on-change-service-type home-provenance-service-type =20 home-files-directory + xdg-configuration-files-directory =20 fold-home-service-types home-provenance @@ -283,6 +285,27 @@ (define home-files-service-type (description "Files that will be put in @file{~~/.guix-home/files}, and further processed during activation."))) =20 +(define xdg-configuration-files-directory "config") + +(define (xdg-configuration-files files) + "Add config/ prefix to each file-path in FILES." + (map (match-lambda + ((file-path . rest) + (cons (string-append xdg-configuration-files-directory "/" file-= path) + rest))) + files)) + +(define home-xdg-configuration-files-service-type + (service-type (name 'home-files) + (extensions + (list (service-extension home-files-service-type + xdg-configuration-files))) + (compose concatenate) + (extend append) + (default-value '()) + (description "Files that will be put in +@file{~~/.guix-home/files/config}, and further processed during activation= ."))) + (define %initialize-gettext #~(begin (bindtextdomain %gettext-domain =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0003-home-shells-Migrate-zsh-to-xdg-configuration-file.patch Content-Transfer-Encoding: quoted-printable From=202dcb5da4991607b01b479c12617c00bf0785d247 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Feb 2022 15:03:44 +0300 Subject: [PATCH v2 3/5] home: shells: Migrate zsh to xdg-configuration-file= s. * gnu/home/services.scm (home-zsh-service-type): Additionally extend home-xdg-configuration-files-service-type. =2D-- gnu/home/services/shells.scm | 122 +++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index ca7f4ac0ad..4b3618a868 100644 =2D-- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -171,56 +171,27 @@ (define-configuration home-zsh-configuration won't be read in some cases (if the shell terminates by exec'ing another process for example).")) =20 =2D(define (add-zsh-configuration config) =2D (let* ((xdg-flavor? (home-zsh-configuration-xdg-flavor? config))) =2D =2D (define prefix-file =2D (cut string-append =2D (if xdg-flavor? =2D "config/zsh/." =2D "") <>)) =2D =2D (define (filter-fields field) =2D (filter-configuration-fields home-zsh-configuration-fields =2D (list field))) =2D =2D (define (serialize-field field) =2D (serialize-configuration =2D config =2D (filter-fields field))) =2D =2D (define (file-if-not-empty field) =2D (let ((file-name (symbol->string field)) =2D (field-obj (car (filter-fields field)))) =2D (if (not (null? ((configuration-field-getter field-obj) config))) =2D `(,(prefix-file file-name) =2D ,(mixed-text-file =2D file-name =2D (serialize-field field))) =2D '()))) =2D =2D (filter =2D (compose not null?) =2D `(,(if xdg-flavor? =2D `("zshenv" =2D ,(mixed-text-file =2D "auxiliary-zshenv" =2D (if xdg-flavor? =2D "source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zshen= v\n" =2D ""))) =2D '()) =2D (,(prefix-file "zshenv") =2D ,(mixed-text-file =2D "zshenv" =2D (if xdg-flavor? =2D "export ZDOTDIR=3D${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n" =2D "") =2D (serialize-field 'zshenv) =2D (serialize-field 'environment-variables))) =2D (,(prefix-file "zprofile") =2D ,(mixed-text-file =2D "zprofile" =2D "\ +(define (zsh-filter-fields field) + (filter-configuration-fields home-zsh-configuration-fields (list field))) + +(define (zsh-serialize-field config field) + (serialize-configuration config (zsh-filter-fields field))) + +(define* (zsh-field-not-empty? config field) + (let ((file-name (symbol->string field)) + (field-obj (car (zsh-filter-fields field)))) + (not (null? ((configuration-field-getter field-obj) config))))) + +(define (zsh-file-zshenv config) + (mixed-text-file + "zshenv" + (zsh-serialize-field config 'zshenv) + (zsh-serialize-field config 'environment-variables))) + +(define (zsh-file-zprofile config) + (mixed-text-file + "zprofile" + "\ # Setups system and user profiles and related variables source /etc/profile # Setups home environment profile @@ -229,11 +200,47 @@ (define (file-if-not-empty field) # It's only necessary if zsh is a login shell, otherwise profiles will # be already sourced by bash " =2D (serialize-field 'zprofile))) =2D =2D ,@(list (file-if-not-empty 'zshrc) =2D (file-if-not-empty 'zlogin) =2D (file-if-not-empty 'zlogout)))))) + (zsh-serialize-field config 'zprofile))) + +(define (zsh-file-by-field config field) + (match field + ('zshenv (zsh-file-zshenv config)) + ('zprofile (zsh-file-zprofile config)) + (e (mixed-text-file + (symbol->string field) + (zsh-serialize-field config field))))) + +(define (zsh-get-configuration-files config) + `(("zprofile" ,(zsh-file-by-field config 'zprofile)) ;; Always non-empty + ,@(if (and (zsh-field-not-empty? config 'zshenv) + (zsh-field-not-empty? config 'environment-variables)) + `(("zshenv" ,(zsh-file-by-field config 'zshenv))) '()) + ,@(if (zsh-field-not-empty? config 'zshrc) + `(("zshrc" ,(zsh-file-by-field config 'zshrc))) '()) + ,@(if (zsh-field-not-empty? config 'zlogin) + `(("zlogin" ,(zsh-file-by-field config 'zlogin))) '()) + ,@(if (zsh-field-not-empty? config 'zlogout) + `(("zlogout" ,(zsh-file-by-field config 'zlogout))) '()))) + +(define (zsh-home-files config) + (define zshenv-auxiliary-file + (mixed-text-file + "zshenv-auxiliary" + "export ZDOTDIR=3D${XDG_CONFIG_HOME:-$HOME/.config}/zsh\n" + "[[ -f $ZDOTDIR/.zshenv ]] && source $ZDOTDIR/.zshenv\n")) + + (if (home-zsh-configuration-xdg-flavor? config) + `(("zshenv" ,zshenv-auxiliary-file)) + (zsh-get-configuration-files config))) + +(define (zsh-xdg-configuration-files config) + (if (home-zsh-configuration-xdg-flavor? config) + (map + (lambda (lst) + (cons (string-append "zsh/." (car lst)) + (cdr lst))) + (zsh-get-configuration-files config)) + '())) =20 (define (add-zsh-packages config) (list (home-zsh-configuration-package config))) @@ -291,7 +298,10 @@ (define home-zsh-service-type (extensions (list (service-extension home-files-service-type =2D add-zsh-configuration) + zsh-home-files) + (service-extension + home-xdg-configuration-files-service-type + zsh-xdg-configuration-files) (service-extension home-profile-service-type add-zsh-packages))) =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0004-home-Migrate-fountutils-and-xdg-modules-to-xdg-co.patch Content-Transfer-Encoding: quoted-printable From=2099ef9ce7d0796642a54497e3a080e94a78fbb03c Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Feb 2022 15:34:46 +0300 Subject: [PATCH v2 4/5] home: Migrate fountutils and xdg modules to xdg-configuration-files. * gnu/home/services/fontutils.scm (home-fontconfig-service-type): Migrate to xdg-configuration-files. * gnu/home/services/xdg.scm (home-xdg-user-directories-service-type, home-xdg-mime-applications-service-type): Migrate to xdg-configuration-file= s. =2D-- gnu/home/services/fontutils.scm | 4 ++-- gnu/home/services/xdg.scm | 31 +++++++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.= scm index 772904367d..6062eaed6a 100644 =2D-- a/gnu/home/services/fontutils.scm +++ b/gnu/home/services/fontutils.scm @@ -34,7 +34,7 @@ (define-module (gnu home services fontutils) ;;; Code: =20 (define (add-fontconfig-config-file he-symlink-path) =2D `(("config/fontconfig/fonts.conf" + `(("fontconfig/fonts.conf" ,(mixed-text-file "fonts.conf" " @@ -51,7 +51,7 @@ (define home-fontconfig-service-type (service-type (name 'home-fontconfig) (extensions (list (service-extension =2D home-files-service-type + home-xdg-configuration-files-service-type add-fontconfig-config-file) (service-extension home-run-on-change-service-type diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm index 2833198cdf..361a2a6148 100644 =2D-- a/gnu/home/services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -190,11 +190,11 @@ (define-configuration home-xdg-user-directories-confi= guration "Default directory for videos.")) =20 (define (home-xdg-user-directories-files-service config) =2D `(("config/user-dirs.conf" + `(("user-dirs.conf" ,(mixed-text-file "user-dirs.conf" "enabled=3DFalse\n")) =2D ("config/user-dirs.dirs" + ("user-dirs.dirs" ,(mixed-text-file "user-dirs.dirs" (serialize-configuration @@ -218,7 +218,7 @@ (define home-xdg-user-directories-service-type (service-type (name 'home-xdg-user-directories) (extensions (list (service-extension =2D home-files-service-type + home-xdg-configuration-files-service-type home-xdg-user-directories-files-service) (service-extension home-activation-service-type @@ -417,7 +417,7 @@ (define-configuration home-xdg-mime-applications-config= uration "A list of XDG desktop entries to create. See @code{xdg-desktop-entry}.")) =20 =2D(define (home-xdg-mime-applications-files-service config) +(define (home-xdg-mime-applications-files config) (define (add-xdg-desktop-entry-file entry) (let ((file (first entry)) (config (second entry))) @@ -425,16 +425,16 @@ (define (add-xdg-desktop-entry-file entry) (apply mixed-text-file (format #f "xdg-desktop-~a-entry" file) config)))) + (map (compose add-xdg-desktop-entry-file serialize-xdg-desktop-entry) + (home-xdg-mime-applications-configuration-desktop-entries config))) =20 =2D (append =2D `(("config/mimeapps.list" =2D ,(mixed-text-file =2D "xdg-mime-appplications" =2D (serialize-configuration =2D config =2D home-xdg-mime-applications-configuration-fields)))) =2D (map (compose add-xdg-desktop-entry-file serialize-xdg-desktop-entry) =2D (home-xdg-mime-applications-configuration-desktop-entries config= )))) +(define (home-xdg-mime-applications-xdg-files config) + `(("mimeapps.list" + ,(mixed-text-file + "xdg-mime-appplications" + (serialize-configuration + config + home-xdg-mime-applications-configuration-fields))))) =20 (define (home-xdg-mime-applications-extension old-config extension-configs) (define (extract-fields config) @@ -469,7 +469,10 @@ (define home-xdg-mime-applications-service-type (extensions (list (service-extension home-files-service-type =2D home-xdg-mime-applications-files-service))) + home-xdg-mime-applications-files) + (service-extension + home-xdg-configuration-files-service-type + home-xdg-mime-applications-xdg-files))) (compose identity) (extend home-xdg-mime-applications-extension) (default-value (home-xdg-mime-applications-configuration)) =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0005-home-symlink-manager-Respect-XDG_CONFIG_HOME-duri.patch Content-Transfer-Encoding: quoted-printable From=20f34175838dac46093a26971798b08c0679691b34 Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 11 Mar 2022 10:12:30 +0300 Subject: [PATCH v2 5/5] home: symlink-manager: Respect XDG_CONFIG_HOME duri= ng activation. * gnu/home/services/symlink-manager.scm (update-symlinks-script): Respect XDG_CONFIG_HOME during activation. =2D-- gnu/home/services/symlink-manager.scm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index 16031ea5d3..3b851229f3 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -50,14 +50,29 @@ (define (update-symlinks-script) (define home-directory (getenv "HOME")) =20 + (define xdg-config-home + (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.config"))) + (define backup-directory (string-append home-directory "/" (number->string (current-time= )) "-guix-home-legacy-configs-backup")) =20 + (define (preprocess-file file) + "If file is in XDG-CONFIGURATION-FILES-DIRECTORY use +subdirectory from XDG_CONFIG_HOME to generate a target path." + (if (string-prefix? #$xdg-configuration-files-directory file) + (string-append + (substring xdg-config-home + (1+ (string-length home-directory))) + (substring file + (string-length #$xdg-configuration-files-direct= ory))) + (string-append "." file))) + (define (target-file file) ;; Return the target of FILE, a config file name sans leading d= ot ;; such as "config/fontconfig/fonts.conf" or "bashrc". =2D (string-append home-directory "/." file)) + (string-append home-directory "/" (preprocess-file file))) =20 (define (symlink-to-store? file) (catch 'system-error @@ -70,7 +85,7 @@ (define (symlink-to-store? file) =20 (define (backup-file file) (define backup =2D (string-append backup-directory "/." file)) + (string-append backup-directory "/" (preprocess-file file))) =20 (mkdir-p backup-directory) (format #t (G_ "Backing up ~a...") (target-file file)) =2D-=20 2.34.0 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I plan to prepare documentation, second patch series and announcement next week. =2D-=20 Best regards, Andrew Tropin --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmIq/ScPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wulAQAIV0kkYIifh66/uDx/80aZ8xJZlJEYv+/64O z4ZOzZVWuPvzOPcL/JwumIz1GC78tioWlVCaoKivs0x+3NH1N4wQVBc3SUKbxfqU WIIMxoq02Wt/slGwNdt60Bzi7SBitoLiiH4MS1TUJTqr09x79G7vLs8q7zPCvcvo c1usaibWFThdtA5Y07cFqa6rZgqrQDWQrOdxka+SRbiIJ8485ILovafdjDBfA+PG HVa3PxEitdCdU4QaN/seBIDn6ap4ziFzXtMzefyasoV0mLYaShWW4mu2Rq8P83nx DG0E8hzU1LgSjfkb4LZIx+epp3KcFa0Y3abwTOAfgYqKoodlSKJQnjOHmcHe78oh F52K7696PwVXqOn+mETTeVNOnhFlQzNS5s3MLQEnNCOpCqHyc4ByzP9v/NdpJC0i 3SfHt7b3azoKi11HO1T3yUnd6Zp7yRTu7aS1crYZg449vSOeY7ueDEZz1SaZdI2N YyV31vEVaZvwEM8SEwifGM9ljWy3kfx+q3sWWOrD/mYWzeflx/NIzak8ri7mfXEv z5GnJ9nYzW5gVvm06s9zo/kpRYb+g7I6KN07o8Qe1yW1VWkCBx4taeoNjrNrcrq1 dnnda9e/q78F9k97LlveYUQRCr5LH5RMzS2yccnTxxLVhJQKdwQbyGsWtju9gPxR /BKOc+9T =HkF5 -----END PGP SIGNATURE----- --==-=-=--