From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +IMzN5+GBmLcvQAAgWs5BA (envelope-from ) for ; Fri, 11 Feb 2022 16:54:07 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id UJaFNJ+GBmLpeAAA9RJhRA (envelope-from ) for ; Fri, 11 Feb 2022 16:54:07 +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 2045F278CA for ; Fri, 11 Feb 2022 16:54:07 +0100 (CET) Received: from localhost ([::1]:40046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIYFK-00045C-CP for larch@yhetil.org; Fri, 11 Feb 2022 10:54:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIYEI-0003b5-PY for bug-guix@gnu.org; Fri, 11 Feb 2022 10:53:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIYEI-0003BI-GB for bug-guix@gnu.org; Fri, 11 Feb 2022 10:53:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nIYEI-0001I4-Fw for bug-guix@gnu.org; Fri, 11 Feb 2022 10:53: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 Feb 2022 15:53: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.16445947714943 (code B ref 52808); Fri, 11 Feb 2022 15:53:02 +0000 Received: (at 52808) by debbugs.gnu.org; 11 Feb 2022 15:52:51 +0000 Received: from localhost ([127.0.0.1]:60827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIYE6-0001He-2v for submit@debbugs.gnu.org; Fri, 11 Feb 2022 10:52:51 -0500 Received: from mail-lf1-f45.google.com ([209.85.167.45]:43580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIYE3-0001HQ-96 for 52808@debbugs.gnu.org; Fri, 11 Feb 2022 10:52:48 -0500 Received: by mail-lf1-f45.google.com with SMTP id x15so194446lfu.10 for <52808@debbugs.gnu.org>; Fri, 11 Feb 2022 07:52:47 -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=NFtpCjKRs1/w6qRZTOz61D5ZQV3/OWX1Z1Ru9l4h5dU=; b=MRwCKirJoGmqgBOPq45ondT86GNrR5pKMZHcrT7Xach/fNQy9SWrFQxX2oDFkAgpUb Ii6fwQyCPRKV1USbxDkeW1RbxPzvYxqTRalwU4SornZtdHUCeQiJRTVg4Oa2czP2XuCL XUAdHi+x2uOtJfiSFfP33WNHN5nGy2NBPf7gdA4lxK+LFJWkYoCxEWEz44UVvGcop6gQ uWmeFSGEDz+dKGxGkh3ZtzamZq9Irt7fXU+Y7mz42vsZA3kzrlE9TBmcbis8AtkjhgSP 91NaTNu588g5myot+R35nRPu02F/5uBT8qdiDgw8iK435Tqgn4x9JQ2euhR6/UbSQUxu Fw+w== 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=NFtpCjKRs1/w6qRZTOz61D5ZQV3/OWX1Z1Ru9l4h5dU=; b=d1LXVisHptH1shy6n7qEm20jFjEUcxcQEwkiHJ5jge0lNRKc6ZkpY8JKmPIzHCxznh 3owbBaNv2/aZ6MOy43vCMAWAaZ3ZjfIAwsDH2aqUob2M2nANbbAG7Ou36SWOpatZsmD3 o564SxeGQumvgS4zL/bH1E9m+W0B2jJ+19rKprJsklEjv7QYZf12ioYPazTnK770Za4q BXREojfySfYDYq8VblvDoDpo2IHZYi0+vgWAJvmoRr1DNKMtOnojh/kdsrB2wnHdlJch qchSxqpUm4aoeBPmFTM7eGxP0XR+JIORKf40AvO51Kdt4QQu4gw0ho69lvRmAg1Ux/5T niXw== X-Gm-Message-State: AOAM5329qoDQQ76sZISRbCwKR0Pu66UTs+YfbFwB0KUBE6NxkxibbyT2 GejXnUXrItwlzLOny7NxsAbUJw== X-Google-Smtp-Source: ABdhPJzHLGip5OVN+BboloNZqd3EBseLMH5H2kt2jp/sAnoAwPNNYYLZSaAHyVut4GLs4pt2Bxi0VQ== X-Received: by 2002:ac2:530c:: with SMTP id c12mr1585919lfh.122.1644594760846; Fri, 11 Feb 2022 07:52:40 -0800 (PST) Received: from localhost ([213.193.20.100]) by smtp.gmail.com with ESMTPSA id h23sm3178140lfv.46.2022.02.11.07.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 07:52:39 -0800 (PST) From: Andrew Tropin In-Reply-To: <87zgn1bsha.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> Date: Fri, 11 Feb 2022 18:52:36 +0300 Message-ID: <87r189s8mz.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=1644594847; 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=NFtpCjKRs1/w6qRZTOz61D5ZQV3/OWX1Z1Ru9l4h5dU=; b=p7E1lz6pqbzoKpa77hzXy71StJkXM5l1c9KPIdpU8Wm/6oaj/sZ8ugVQcSrfpW1AOWiryb 5lL/01HmidhqC5IeUNRQixskU7otA9cUfa+KyTyWicM6bw3+6PGmAA3zDEP4sOWnEguoRG /03Rs40HcVq4hyChkq0WFFWdRcV6LzbDnHQMe7MmF/NE6NhzYA2bfmjtPvV0uc7Ca0Z78s YaAe4LE4ntJgQAMJyfQnOQsVXI37ju3+oVIg16NQyyO0IhmaJebVTBuLTEz7wOc+B6UPtf oan+ciRuCCN3ip2OO/tXojngZ0TpehopsQai3fW7R9J0CEKoulK6HLS7l2wxfA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644594847; a=rsa-sha256; cv=none; b=hnFCWMD7vf3Ua6bqabZE3tPUgpvpcg9NVo3LvQed3LNWkmE3Xpm7diKv8ObeVObGLCDc8K ox6+EHtDpVn2OsYMPba43mtTgPmru0eAaeWE+oOsvA9w1EPg0C9sIWelH9LmH1J9GCT0Fj 020UkKdJs9rTjHkmW1A6M+QJipiDL4jhaGoVKCYpkwpcJAJB0yL08Fty9CStIPKUr1sJ66 igHoj0Iy8xZ8K3aGpRRYgikLIAVX5K9rmUat9ElZX2PRnJNNoFCyx8UK/n+TM/Qyz4wd7/ 16ds1M36L9ccBBS3nWeIOkFCxaNqGWTkadxE4+HtcZk1MW4lpKnTTmys7ZcfgQ== 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=MRwCKirJ; 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: -5.23 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop-in.20210112.gappssmtp.com header.s=20210112 header.b=MRwCKirJ; 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: 2045F278CA X-Spam-Score: -5.23 X-Migadu-Scanner: scn0.migadu.com X-TUID: gIuS1+r7neis --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-02-08 10:46, Ludovic Court=C3=A8s wrote: > Hi, > > Andrew Tropin skribis: > >>>> You can elaborate more on what you try to achieve and I can try to give >>>> you a recommendation how to implement it. >>> >>> I=E2=80=99d expect =E2=80=98home-files-service-type=E2=80=99 to do just= that: add files to the >>> home directory, without trying to be smart. >>> >>> Would it make sense to distinguish between =E2=80=98home-files=E2=80=99= and (say) >>> =E2=80=98home-xdg-configuration-files=E2=80=99? >> >> Yep, I can do that, actually, it will be even better for the purpose I >> originally had. I'll make home-files to store files as it is and >> symlink manager not to add leading dots and a separate folder for >> xdg configs. > > Neat. > >> Ludo, Nick, what do you think about following names? >> ~/.guix-home/home-dir-files/ >> ~/.guix-home/xdg-config-dir-files/ > > I=E2=80=99d make it =E2=80=98=E2=80=A6/home-files=E2=80=99 and =E2=80=98= =E2=80=A6/xdg-configuration-files=E2=80=99, but that=E2=80=99s a > detail. > >>> I=E2=80=99d also suggest removing special handling of HOME/files in >>> symlink-manager.scm. Relations between the various components of Guix >>> Home should preferably be made explicit via service extensions, and not >>> implicit through conventions like this =E2=80=98files=E2=80=99 sub-dire= ctory. >>> >>> Thoughts? >> >> Unfortunatelly, I don't know how to implement polymorphic behavior the >> other way with current extension mechanism, so I would prefer to keep >> this relation implicit, > > I=E2=80=99m not sure I follow but maybe I should try by myself to get a b= etter > understanding. > > Thanks for your feedback! > > Ludo=E2=80=99. I decided to go one step at a time, and prepared a patch series, which: 1. Adds an explicit connection between home-files-service-type and symlink-manager by introducing a global constant used by both services. 2. Adds a home-xdg-configuration-files-service-type, which accepts a list of files for XDG_CONFIG_DIR, `(("mpv/mpv.conf" ,file-like-here)) 3. Migrates all (gnu home services) to xdg-configuration-files. 4. Make symlink-manager respect XDG_CONIFG_HOME and xdg-configuration-files-subdir. 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-home-Explicitly-connect-home-file-and-symlink-manage.patch Content-Transfer-Encoding: quoted-printable From=200cd37bbc724f9c793898c2655bdd1c335045c5f0 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-manager 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 | 23 ++++++++++++++--------- gnu/home/services/symlink-manager.scm | 17 +++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index 1cd19ce7f9..e4e3717b80 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,9 @@ (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 (format #f "Files that will be put in +@file{~~/.guix-home/~a}, and further processed during activation." + home-files-directory)))) =20 (define %initialize-gettext #~(begin diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index 314da3ba3e..747bb343d3 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -25,12 +25,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 @@ -94,7 +93,8 @@ (define ((file-tree-traverse preordering) node) (new-home (getenv "GUIX_NEW_HOME")) (old-home (getenv "GUIX_OLD_HOME")) =20 =2D (new-files-path (string-append new-home "/files")) + (new-files-path (string-append + new-home "/" #$home-files-directory)) ;; 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 "/.")) @@ -107,7 +107,8 @@ (define ((file-tree-traverse preordering) node) (old-tree (if old-home ((simplify-file-tree "") (file-system-tree =2D (string-append old-home "/files/."))) + (string-append + old-home "/" #$home-files-directory "/."))) #f)) (new-tree ((simplify-file-tree "") (file-system-tree new-files-dir-path))) =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-home-Add-home-xdg-configuration-files-service.patch Content-Transfer-Encoding: quoted-printable From=2023f7095d60b18b52de0d1aa314c4012cdf55a046 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. =2D-- gnu/home/services.scm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gnu/home/services.scm b/gnu/home/services.scm index e4e3717b80..bf044a0421 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-subdir =20 fold-home-service-types home-provenance @@ -284,6 +286,27 @@ (define home-files-service-type @file{~~/.guix-home/~a}, and further processed during activation." home-files-directory)))) =20 +(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)) + +(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 (format #f "Files that will be put in +@file{~~/.guix-home/~a/~a}, and further processed during activation." + home-files-directory + xdg-configuration-files)))) + (define %initialize-gettext #~(begin (bindtextdomain %gettext-domain =2D-=20 2.34.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-home-shells-Migrate-zsh-to-xdg-configuration-files.patch Content-Transfer-Encoding: quoted-printable From=2011f23a48d480a91d6bfba0ff55c1a9831585a4ee 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-files. * gnu/home/services.scm (home-zsh-service-type): Additionally extend home-xdg-configuration-files-service-type. =2D-- gnu/home/services/shells.scm | 112 +++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 51 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))) +(define (zsh-filter-fields field) + (filter-configuration-fields home-zsh-configuration-fields (list field))) =20 =2D (define prefix-file =2D (cut string-append =2D (if xdg-flavor? =2D "config/zsh/." =2D "") <>)) +(define (zsh-serialize-field config field) + (serialize-configuration config (zsh-filter-fields field))) =20 =2D (define (filter-fields field) =2D (filter-configuration-fields home-zsh-configuration-fields =2D (list 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))))) =20 =2D (define (serialize-field field) =2D (serialize-configuration =2D config =2D (filter-fields field))) +(define (zsh-file-zshenv config) + (mixed-text-file + "zshenv" + (zsh-serialize-field config 'zshenv) + (zsh-serialize-field config 'environment-variables))) =20 =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-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))) + (zsh-serialize-field config 'zprofile))) =20 =2D ,@(list (file-if-not-empty 'zshrc) =2D (file-if-not-empty 'zlogin) =2D (file-if-not-empty 'zlogout)))))) +(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=0004-home-Migrate-fountutils-and-xdg-modules-to-xdg-confi.patch Content-Transfer-Encoding: quoted-printable From=20ef4c3bbcc0c8c1a251f4ad6c494f8ed30adf45f2 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): 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 d230dd7665..9c43aa93b9 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=0005-home-symlink-manager-Respect-XDG_CONFIG_HOME-during-.patch Content-Transfer-Encoding: quoted-printable From=20089683bbd301f6e085f00fbd53713f335abac40e 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 during activation. * gnu/home/services/symlink-manager.scm (update-symlinks-script): Respect XDG_CONFIG_HOME during activation. =2D-- gnu/home/services/symlink-manager.scm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index 747bb343d3..418bfbd98a 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -85,8 +85,8 @@ (define ((file-tree-traverse preordering) node) =20 (use-modules (guix build utils)) =20 =2D (let* ((config-home (or (getenv "XDG_CONFIG_HOME") =2D (string-append (getenv "HOME") "/.conf= ig"))) + (let* ((xdg-config-home (or (getenv "XDG_CONFIG_HOME") + (string-append (getenv "HOME") "/.confi= g"))) =20 (he-path (string-append (getenv "HOME") "/.guix-home")) (new-he-path (string-append he-path ".new")) @@ -117,13 +117,24 @@ (define ((file-tree-traverse preordering) node) (lambda (path) (readlink (string-append new-files-path "/" path)))) =20 + (preprocess-path + (lambda (path) + "If file is in xdg-configuration-files-subdir use +subdirectory from XDG_CONFIG_HOME to generate a target path." + (if (string-prefix? #$xdg-configuration-files-subdir path) + (string-append + (substring xdg-config-home (1+ (string-length home-p= ath))) + (substring + path (string-length #$xdg-configuration-files-subdi= r))) + (string-append "." path)))) + (get-target-path (lambda (path) =2D (string-append home-path "/." path))) + (string-append home-path "/" (preprocess-path path)))) =20 (get-backup-path (lambda (path) =2D (string-append backup-dir "/." path))) + (string-append backup-dir "/" (preprocess-path path)))) =20 (directory? (lambda (path) @@ -224,6 +235,12 @@ (define ((file-tree-traverse preordering) node) (display (G_ " done\n")))) to-create))))) =20 + (format #t "home-path: ~a\nxdg-config-home: ~a\n" + home-path xdg-config-home) + + (format #t "prepr: ~a\n" + (preprocess-path "config/sway/config")) + (when old-tree (cleanup-symlinks)) =20 =2D-=20 2.34.0 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Best regards, Andrew Tropin --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmIGhkQPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wFucP/iPnHFKo/gkCj+azi72XXAPUWec60GCh4pfQ gSzE/9NA8e/E+16xnGtVQcAcsB6ujXm7gOpyHCxjrC1OfZewbhCeh9+t5S1vZYGd oOWmJOd4Y6+YnpOkTZmKGOhDSyxO4UfFIowmd1QoFStgSc0uEKTIWmnB+8do9M81 6Hyjb8ygCIh0mDV4osYMob6kg0K3h1I09Ynp3Fa6lKZ62b8MHrGj+3YDI+uaLa6b ygbis7P1k3e0WQ3uZDMuPX32QiQ7cJT1dmFT18siTlmJiIx2LNcYlwRyh34QJhWK j9bKJwRKrJDm2duxtiM3je9KNIwnqkKwLUMqbhjCByu79hWgXJnoOAKmtwhzsTdj sYso2+hJYXhz56jCKNOrTWKD7dWq35sJk4exOfq4tK8PheiTR3/srsA8cIw/mFoD IoKA8hk3uCtroC3S0MZRQvAeUImtfABKWpHeGUETvTXuLvMeSSszuodayLJd9P0T t1GZBCyZux5AvUOeFuwLP2N/omwhjjDYl/3M/fBm/Vv5MpFKDH3FGqcbqv+IxDB3 qR91k6j6F83Q7TYX6FC2mMO2UFv2XjlmsLSMF5SCeFPvf0socbdUUpDRfKceLVwz rkpWnB358sPPH3kshRpFVOJLeOn/l7MP55+/gUqVVtRB+Ux5bYBiB+9CtboI42/E Ik01RWy+ =ns8e -----END PGP SIGNATURE----- --==-=-=--