From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 17:16:17 2024 Received: (at submit) by debbugs.gnu.org; 31 Jan 2024 22:16:17 +0000 Received: from localhost ([127.0.0.1]:39178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVIsT-00062U-4n for submit@debbugs.gnu.org; Wed, 31 Jan 2024 17:16:17 -0500 Received: from lists.gnu.org ([2001:470:142::17]:60984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVIsS-000621-3r for submit@debbugs.gnu.org; Wed, 31 Jan 2024 17:16:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVIsA-0005Az-RM for guix-patches@gnu.org; Wed, 31 Jan 2024 17:16:00 -0500 Received: from confino.investici.org ([2a11:7980:1::2:0]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rVIs7-0005Vw-5S; Wed, 31 Jan 2024 17:15:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1706739348; bh=zFfglOkMLREtr0sCM+HqZDGfyA3/QF3t538LNtqqNeU=; h=Date:To:Cc:From:Subject:From; b=KGO9Ny4avpaFgl5cI2MOE5q+QEhtKhNGr681rDdU2fSV7yK2LsQUwOA8zmt7TGUMN 9xAYCR/O6iZ8+G0VBV38gCSabM+d3nODajr163cU45trk3SuDT6F8onaqq6szS73KB B0olKdQwdbrot3TSv7kV7omLosI1SKol5QnOWSIo= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TQGZX4Klqz11JF; Wed, 31 Jan 2024 22:15:48 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TQGZX2yyBz11J7; Wed, 31 Jan 2024 22:15:48 +0000 (UTC) Message-ID: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> Date: Wed, 31 Jan 2024 23:15:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: guix-patches@gnu.org From: paul Subject: gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a11:7980:1::2:0; envelope-from=goodoldpaul@autistici.org; helo=confino.investici.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?Q?Ludovic_Court=c3=a8s?= , Sergey Trofimov , 68848@debbugs.gnu.org, janneke@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: -0.1 (/) Hello, I'm sending a patch supposed to fix https://issues.guix.gnu.org/68848  . Please let me know if this is ok for you and fixes your issues. Thank you, giacomo From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 31 17:18:08 2024 Received: (at 68857) by debbugs.gnu.org; 31 Jan 2024 22:18:08 +0000 Received: from localhost ([127.0.0.1]:39184 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVIuF-000662-LP for submit@debbugs.gnu.org; Wed, 31 Jan 2024 17:18:07 -0500 Received: from confino.investici.org ([2a11:7980:1::2:0]:46797) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rVIuD-00065r-4Y for 68857@debbugs.gnu.org; Wed, 31 Jan 2024 17:18:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1706739474; bh=JlNHK2Cz5KbFRmoeeQOQEAfmo1lD6jTu8GQlpz6MB/8=; h=From:To:Cc:Subject:Date:From; b=RztKwwDaFwszuzW6QUAlmzSZ9+6cGceeBgBQmv+8jla+jiTCm2YNg+Tb8tS0TYMf3 hhr6UpKeRh/Es2gL2J9BDQPuZegr77rLJqwO9tg1ASlgkS8gEHT1HRWGgwnwq0+R/7 0V3ab8lnlCiyUya+fhZ+qz4FBRM5PM1JhnT1GgdM= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TQGcy5bKhz11Ft; Wed, 31 Jan 2024 22:17:54 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TQGcy4qj6z11Fn; Wed, 31 Jan 2024 22:17:54 +0000 (UTC) From: Giacomo Leidi To: 68857@debbugs.gnu.org Subject: [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. Date: Wed, 31 Jan 2024 23:17:48 +0100 Message-ID: <20240131221748.1190-1-goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 68857 Cc: Giacomo Leidi 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 (-) This patch applies the fix from https://issues.guix.gnu.org/60521#43 , it is supposed to fix https://issues.guix.gnu.org/68848 . * gnu/home/services/dotfiles.scm (import-dotfiles)[strip]: Drop extra directory. Change-Id: I98b747396e1fc8a8925204cde2bb705019ce2c1d --- gnu/home/services/dotfiles.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/home/services/dotfiles.scm b/gnu/home/services/dotfiles.scm index 6a740c42ce..fc842f1fb3 100644 --- a/gnu/home/services/dotfiles.scm +++ b/gnu/home/services/dotfiles.scm @@ -58,7 +58,11 @@ (define (import-dotfiles directory files) generated by recursively visiting DIRECTORY and mapping its contents to the user's home directory, excluding files that match any of the patterns in EXCLUDED." (define (strip file) - (string-drop file (+ 1 (string-length directory)))) + (string-join + (cdr + (string-split (string-drop file (+ 1 (string-length directory))) + #\/)) + "/")) (define (format file) ;; Remove from FILE characters that cannot be used in the store. base-commit: bf7991a8c767abd32cfb2c92e3d57665a7cabf00 -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 06 19:54:43 2024 Received: (at 68857) by debbugs.gnu.org; 7 Feb 2024 00:54:43 +0000 Received: from localhost ([127.0.0.1]:55409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXWD5-0004XQ-3M for submit@debbugs.gnu.org; Tue, 06 Feb 2024 19:54:43 -0500 Received: from confino.investici.org ([93.190.126.19]:20039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXWD3-0004XH-K9 for 68857@debbugs.gnu.org; Tue, 06 Feb 2024 19:54:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1707267267; bh=+3haXULhqxPgxHbBNi4GdvawkF6Q3ELdXTYLPI+DPAs=; h=Date:To:Cc:From:Subject:From; b=i4J7jwQnvvD/wW7sMIY+efd9aWLR/kELLT3eveq6xEbZ+4ZXtnLZjJJw70aNpLkMV a/noQCksdeg/1lBMKM14WeUrKTpid7vKQcnsB2bqrSL9Q3daqAJtSs7xQClKLTCjHO y1InK8L173e7L1BXsbPgj9j0IQa8jLqfFN6Lt1U8= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TV1pq4DDmz113f; Wed, 7 Feb 2024 00:54:27 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TV1pq28kxz113X; Wed, 7 Feb 2024 00:54:27 +0000 (UTC) Message-ID: Date: Wed, 7 Feb 2024 01:54:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Content-Language: en-US To: 68857@debbugs.gnu.org From: paul Subject: Re: [bug#68857] [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68857 Cc: =?UTF-8?Q?Ludovic_Court=c3=a8s?= , Sergey Trofimov , andrew@trop.in, janneke@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.7 (-) Hi Janneke, could you try whether this patch solves https://issues.guix.gnu.org/68848 for you? Thank you for your time, giacomo From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 07 03:06:07 2024 Received: (at 68857) by debbugs.gnu.org; 7 Feb 2024 08:06:07 +0000 Received: from localhost ([127.0.0.1]:55646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXcwY-0008B1-St for submit@debbugs.gnu.org; Wed, 07 Feb 2024 03:06:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXcwV-0008AM-V7 for 68857@debbugs.gnu.org; Wed, 07 Feb 2024 03:06:04 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXcw8-0003dk-Um; Wed, 07 Feb 2024 03:05:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=QsojFwBrXY9rNcmZSSYY1fbJ90/7EHeBr5vQxjw9vQA=; b=cl8yVYT6pOO6knibsd9G FxTDS7G7Lruv9uzUD5EX+r5gCwrCaNEI9tR3mpQOboj0xbkGNBdBm8ezrpvqprCBvaRD5vFtwk8tq Pjwk/rzgDXD+LwRsyZjzmjzNBlFrwdSOuTZp6VLiavBoj0AyrQMRNsxLjOJIsVAJM4jN7O93jrWlb eztAQCB/G/DeSz9oCq3ide7SrorT948bl0W+P8XX04BhzOdQIYl69zoQfB5vX+0kSSQIRQvLx4Hdl ewOtLA1FzgX005uv1PwCeiHeSXgatWjvAc1chp9Ymab5hasCJFFwH+KW9fFK7up0O7aYNhhOuS4eg JDYCKgQJZI2jSg==; From: Janneke Nieuwenhuizen To: paul Subject: Re: [bug#68857] [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: (paul's message of "Wed, 7 Feb 2024 01:54:27 +0100") Organization: AvatarAcademy.nl References: X-Url: http://AvatarAcademy.nl Date: Wed, 07 Feb 2024 09:05:33 +0100 Message-ID: <87cyt8d7hu.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68857 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , Sergey Trofimov , 68857@debbugs.gnu.org, andrew@trop.in 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: -3.3 (---) paul writes: Hi Paul, > could you try whether this patch solves > https://issues.guix.gnu.org/68848 for you? Yes, that fixes it. Although I would rather write it something like --8<---------------cut here---------------start------------->8--- (define (strip file-name) (let ((dotfile-name (string-drop file-name (+1 (string-length directory))= ))) (match (string-split dotfile-name #\/) ((package parts ...) (string-join parts "/"))))) --8<---------------cut here---------------end--------------->8--- > Thank you for your time, No problem, somehow I looked for a patch and didn't see it before. Thanks for the ping and for fixing this. Greetings, Janneke --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 07 03:38:01 2024 Received: (at 68857) by debbugs.gnu.org; 7 Feb 2024 08:38:02 +0000 Received: from localhost ([127.0.0.1]:55674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXdRR-0000mG-HW for submit@debbugs.gnu.org; Wed, 07 Feb 2024 03:38:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXdRP-0000m3-2d for 68857@debbugs.gnu.org; Wed, 07 Feb 2024 03:38:00 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXdR1-0000yk-Bi; Wed, 07 Feb 2024 03:37:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=LAAye3SNbO4kEK4Yq2UXL6i427GCFVL3Fk6ormnIl5g=; b=na9I70sq1b1Z2dQT1psf 4DuoLKrIZYgjzlfOvtxgvA3kjPQMzIjHEwnaqPzernn6HXLy0MocmnJAzMdit3g2ntQjC3MmclFYJ irZehXzQdyelGCoAKDjKQF9kRwJSVqZt0BaT2sfu3FKk5uAaK7iLOr2eakGk1R3xTj90cCZGRBtbw VOkvKmw6QAy6+/3jXxnXdt4AWkPN1C+SzoWtdj26oT8jfMHZP+CcYP9JP5t1r+T+jYs65ShwrsYQ2 elTOXOTz8vMC8bv8YesbtOR/wTMWC9VzSUJUUYgcycXeH1cDLU5XKP0Su3H/t9XVcpMjRf0KFNmUc VaOg0eVSLjElGA==; From: Janneke Nieuwenhuizen To: paul Subject: Re: [bug#68857] [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: <87cyt8d7hu.fsf@gnu.org> (Janneke Nieuwenhuizen's message of "Wed, 07 Feb 2024 09:05:33 +0100") Organization: AvatarAcademy.nl References: <87cyt8d7hu.fsf@gnu.org> X-Url: http://AvatarAcademy.nl Date: Wed, 07 Feb 2024 09:37:30 +0100 Message-ID: <878r3wd60l.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68857 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , Sergey Trofimov , 68857@debbugs.gnu.org, andrew@trop.in 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: -3.3 (---) Janneke Nieuwenhuizen writes: > paul writes: > > Hi Paul, > >> could you try whether this patch solves >> https://issues.guix.gnu.org/68848 for you? > > Yes, that fixes it. Although I would rather write it something like > > (define (strip file-name) > (let ((dotfile-name (string-drop file-name (+1 (string-length directory= ))))) Err that should have been 1+, of course, so --8<---------------cut here---------------start------------->8--- (define (strip file-name) (let ((dotfile-name (string-drop file-name (1+ (string-length directory))= ))) (match (string-split dotfile-name #\/) ((package parts ...) (string-join parts "/"))))) --8<---------------cut here---------------end--------------->8--- --=20 Janneke Nieuwenhuizen | GNU LilyPond https://LilyPond.org Freelance IT https://www.JoyOfSource.com | Avatar=C2=AE https://AvatarAcade= my.com From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 16 12:17:04 2024 Received: (at 68857) by debbugs.gnu.org; 16 Feb 2024 17:17:04 +0000 Received: from localhost ([127.0.0.1]:60158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb1pf-0001lJ-Oq for submit@debbugs.gnu.org; Fri, 16 Feb 2024 12:17:04 -0500 Received: from confino.investici.org ([93.190.126.19]:64529) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb1pc-0001kl-E9 for 68857@debbugs.gnu.org; Fri, 16 Feb 2024 12:17:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1708103792; bh=6VV2Ta90vW+PMygY81qkEvFcl6zth72D4Kb6RJxxqL4=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=cSKJMkat4vZAIGb1ctgMxV9Of2T2NjDX3WHZKCiR+o1it80O9zh0A8JXfwDeTnO+3 Hd3H74DgTxsZffy6er7lXKU6Hc8+NOmLDooOwmhNlS2s0T3MOehw5ifViEijotsxF9 RkqVqHND2AXultimyQN7rbJmm7x/WzeukrZKSJVs= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4Tbz9r4HvGz1146; Fri, 16 Feb 2024 17:16:32 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4Tbz9r2jLMz1144; Fri, 16 Feb 2024 17:16:32 +0000 (UTC) Message-ID: <736b3c27-c913-38b2-f89a-ccc5f486a665@autistici.org> Date: Fri, 16 Feb 2024 18:16:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [bug#68857] [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Language: en-US From: paul To: 68857@debbugs.gnu.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 68857 Cc: =?UTF-8?Q?Ludovic_Court=c3=a8s?= , Sergey Trofimov , janneke@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: -6.9 (------) Hi everyone, thank you for your help and comments so far. I have a proposal that should: - solve https://issues.guix.gnu.org/68848 - allow for both plain and GNU Stow's layouts - for GNU Stow layouts, allows to select a subset of application dotfiles to be provisioned in the user's home directory. Please Sergey let me know if this covers your use case . Ludo' , Janneke, let me know your thoughts on this v2 and if it works for your directory layouts. Thank you again everyone for your efforts. giacomo From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 16 12:18:14 2024 Received: (at 68857) by debbugs.gnu.org; 16 Feb 2024 17:18:14 +0000 Received: from localhost ([127.0.0.1]:60162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb1qn-0001oY-8B for submit@debbugs.gnu.org; Fri, 16 Feb 2024 12:18:14 -0500 Received: from confino.investici.org ([93.190.126.19]:28607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb1qk-0001oJ-Fk for 68857@debbugs.gnu.org; Fri, 16 Feb 2024 12:18:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1708103870; bh=KiRu0SH/JHFERLusnyhuKpHkly0uD3LO7KTuOx0iPQc=; h=From:To:Cc:Subject:Date:From; b=GjFk7X3ZIUhzI4GOIaq6yxLBu37PtzpqhsVWgG12Shjtjzq/gV/yI2vkbCtOe5aWQ 7QDFaIT91zf3pJ9tqwzGhYdW0eyzW/7kxWSsSVjtq3dcpWUU2giEOmeLCP1DYV4eGb nVEfhlYEJzZwHIlqG8WZeAvvS+A2hffemm1lRE5A= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TbzCL3gfLz1146; Fri, 16 Feb 2024 17:17:50 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TbzCL2vf2z1144; Fri, 16 Feb 2024 17:17:50 +0000 (UTC) From: Giacomo Leidi To: 68857@debbugs.gnu.org Subject: [PATCH v2] gnu: home: dotfiles: Properly support both plain and Stow directory layouts. Date: Fri, 16 Feb 2024 18:17:19 +0100 Message-ID: <20240216171724.22171-1-goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 68857 Cc: Giacomo Leidi 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: -3.6 (---) The current implementation of the home-dotfiles-service-type contradicts the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch properly implements both the plain and Stow dotfiles directory layouts. It does so by creating a new record type for each directory layout. This approach, compared to having a single field in home-dotfiles-configuration, allows for having different layouts for different directories and to carry additional information that might be required for some layouts. Implementing a new layout should just be a matter of creating a new record type, defining a strip-*-dotfile procedure and plugging them into the home-dotfiles-service-type. * gnu/home/services/dotfiles (home-dotfiles-stow-directory): New variable; (home-dotfiles-plain-directory): new variable; (home-dotfiles-configuration): migrate to (gnu services configuration); (strip-stow-dotfile): new variable; (strip-plain-dotfile): new variable; (home-dotfiles-configuration->files): use the new record types; [directory-contents]: allow for selecting a subset of application dotfile directories; * doc/guix.texi: document the new layouts. Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 --- doc/guix.texi | 147 ++++++++++++++++++++++++++++----- gnu/home/services/dotfiles.scm | 143 ++++++++++++++++++++++++++------ 2 files changed, 244 insertions(+), 46 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 04119a5955..21adfb1fc0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -44368,17 +44368,39 @@ directory, and some way of automatically deploy changes to their user home. @cindex Stow-like dot file management The @code{home-dotfiles-service-type} from @code{(gnu home services dotfiles)} is designed to ease the way into using Guix Home for this kind of users, -allowing them to point the service to their dotfiles directory, which must -follow the layout suggested by -@uref{https://www.gnu.org/software/stow/, GNU Stow}, -and have their dotfiles automatically deployed to their user home, without +allowing them to point the service to their dotfiles directory without migrating them to Guix native configurations. -The dotfiles directory layout is expected to be structured as follows. Please -keep in mind that it is advisable to keep your dotfiles directories under +Please keep in mind that it is advisable to keep your dotfiles directories under version control, for example in the same repository where you'd track your Guix Home configuration. +There are two supported dotfiles directory layouts, for now. The +@code{home-dotfiles-plain-directory} layout, which is structured as follows: + +@example +~$ tree -a ./dotfiles/ +dotfiles/ +├── .gitconfig +├── .gnupg +│ ├── gpg-agent.conf +│ └── gpg.conf +├── .guile +├── .config +│ ├── guix +│ │ └── channels.scm +│ └── nixpkgs +│ └── config.nix +├── .nix-channels +├── .tmux.conf +└── .vimrc +@end example + +and the @code{home-dotfiles-stow-directory} layout, which must +follow the layout suggested by +@uref{https://www.gnu.org/software/stow/, GNU Stow} and presents and additional +application specific directory layer, just like: + @example ~$ tree -a ./dotfiles/ dotfiles/ @@ -44408,8 +44430,9 @@ dotfiles/ @end example For an informal specification please refer to the Stow manual -(@pxref{Top,,, stow, Introduction}). A suitable configuration would then -be: +(@pxref{Top,,, stow, Introduction}). + +A suitable configuration with a @emph{plain} layout could be: @lisp (home-environment @@ -44417,7 +44440,10 @@ be: (services (service home-dotfiles-service-type (home-dotfiles-configuration - (directories (list "./dotfiles")))))) + (directories + (list + (home-dotfiles-plain-directory + (name "./dotfiles")))))))) @end lisp The expected home directory state would then be: @@ -44444,32 +44470,113 @@ Return a service which is very similiar to @code{home-files-service-type} (and actually extends it), but designed to ease the way into using Guix Home for users that already track their dotfiles under some kind of version control. This service allows users to point Guix Home to their dotfiles -directory and have their files automatically deployed to their home directory -just like Stow would, without migrating all of their dotfiles to Guix native +directory and have their files automatically provisioned to their home +directory, without migrating all of their dotfiles to Guix native configurations. @end defvar +@c %start of fragment + @deftp {Data Type} home-dotfiles-configuration Available @code{home-dotfiles-configuration} fields are: @table @asis -@item @code{source-directory} (default: @code{(current-source-directory)}) -The path where dotfile directories are resolved. By default dotfile directories -are resolved relative the source location where +@item @code{source-directory} (default: @code{(current-source-directory)}) (type: string) +The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where @code{home-dotfiles-configuration} appears. -@item @code{directories} (type: list-of-strings) -The list of dotfiles directories where @code{home-dotfiles-service-type} will -look for application dotfiles. +@item @code{directories} (default: @code{'()}) (type: list-of-plain-or-stow-directories) +The list of dotfiles directories where @code{home-dotfiles-service-type} +will look for application dotfiles. Each element of the list is supposed to be +either a @code{home-dotfiles-plain-directory} or a +@code{home-dotfiles-stow-directory} record. + +@item @code{excluded} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) (type: list-of-strings) +The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting each one of the @code{directories}. + +@end table + +@end deftp + + +@c %end of fragment + +@c %start of fragment + +@deftp {Data Type} home-dotfiles-plain-directory + +This record represents the simplest layout supported. In this layout the +dotfiles directory contains a tree of files which will be directly mapped into +the user directory: + +@example +~$ tree -a ./dotfiles/ +dotfiles/ +├── .guile +├── .config +│ └── guix +│ └── channels.scm +├── .tmux.conf +└── .vimrc +@end example + +Available @code{home-dotfiles-plain-directory} fields are: -@item @code{exclude} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) -The list of file patterns @code{home-dotfiles-service-type} will exclude while -visiting each one of the @code{directories}. +@table @asis +@item @code{name} (type: string) +The name of the dotfile directory where +@code{home-dotfiles-service-type} will look for plain dotfiles. @end table @end deftp +@c %start of fragment + +@deftp {Data Type} home-dotfiles-stow-directory + +This record represents GNU Stow's usual layout. In this layout the +dotfiles directory contains a layer of application directories, each one +containing a home file tree. The @code{home-dotfiles-service-type} will +take care of provisioning dotfiles just like Stow would. + +@example +~$ tree -a ./dotfiles/ +dotfiles/ +├── guile +│ └── .guile +├── guix +│ └── .config +│ └── guix +│ └── channels.scm +├── tmux +│ └── .tmux.conf +└── vim + └── .vimrc + +@end example + +Available @code{home-dotfiles-stow-directory} fields are: + +@table @asis +@item @code{name} (type: string) +The name of the dotfile directory where +@code{home-dotfiles-service-type} will look for application dotfiles. + +@item @code{applications} (type: maybe-list-of-strings) +A subset of the names of the application layer directories. When +provided the @code{home-dotfiles-service-type} will only provision +dotfiles from this subset of applications. + +@end table + +@end deftp + + +@c %end of fragment + @defvar home-xdg-configuration-files-service-type The service is very similar to @code{home-files-service-type} (and actually extends it), but used for defining files, which will go to diff --git a/gnu/home/services/dotfiles.scm b/gnu/home/services/dotfiles.scm index 6a740c42ce..ebe9600585 100644 --- a/gnu/home/services/dotfiles.scm +++ b/gnu/home/services/dotfiles.scm @@ -20,16 +20,33 @@ (define-module (gnu home services dotfiles) #:use-module (gnu home services) #:use-module (gnu services) + #:use-module (gnu services configuration) #:autoload (guix build utils) (find-files) + #:use-module (guix diagnostics) #:use-module (guix gexp) - #:use-module (guix records) + #:use-module (guix i18n) #:use-module ((guix utils) #:select (current-source-directory)) #:use-module (srfi srfi-1) #:use-module (ice-9 ftw) + #:use-module (ice-9 match) #:use-module (ice-9 regex) #:export (home-dotfiles-service-type + home-dotfiles-configuration->files + + home-dotfiles-stow-directory + home-dotfiles-stow-directory? + home-dotfiles-stow-directory-fields + home-dotfiles-stow-directory-name + home-dotfiles-stow-directory-applications + + home-dotfiles-plain-directory + home-dotfiles-plain-directory? + home-dotfiles-plain-directory-fields + home-dotfiles-plain-directory-name + home-dotfiles-configuration home-dotfiles-configuration? + home-dotfiles-configuration-fields home-dotfiles-configuration-source-directory home-dotfiles-configuration-directories home-dotfiles-configuration-excluded)) @@ -40,26 +57,79 @@ (define %home-dotfiles-excluded "\\.git" "\\.gitignore")) -(define-record-type* - home-dotfiles-configuration make-home-dotfiles-configuration - home-dotfiles-configuration? - (source-directory home-dotfiles-configuration-source-directory - (default (current-source-directory)) - (innate)) - (directories home-dotfiles-configuration-directories ;list of strings - (default '())) - (excluded home-dotfiles-configuration-excluded ;list of strings - (default %home-dotfiles-excluded))) - -(define (import-dotfiles directory files) +(define list-of-strings? + (list-of string?)) + +(define-maybe list-of-strings) + +(define-configuration/no-serialization home-dotfiles-stow-directory + (name + (string) + "The name of the dotfile directory where @code{home-dotfiles-service-type} +will look for application dotfiles.") + (applications + (maybe-list-of-strings) + "A subset of the names of the application layer directories. When provided +the @code{home-dotfiles-service-type} will only provision dotfiles from this +subset of applications.")) + +(define-configuration/no-serialization home-dotfiles-plain-directory + (name + (string) + "The name of the dotfile directory where @code{home-dotfiles-service-type} +will look for plain dotfiles.")) + +(define (list-of-plain-or-stow-directories? value) + (unless (list? value) + (raise + (formatted-message + (G_ "directories field of home-dotfiles-configuration should be a list but +~a was found.") + value))) + (for-each + (lambda (d) + (unless (or (home-dotfiles-plain-directory? d) + (home-dotfiles-stow-directory? d)) + (raise + (formatted-message + (G_ "directories field of home-dotfiles-configuration should contain +only home-dotfiles-plain-directory or home-dotfiles-stow-directory records, but +~a was found.") + d)))) + value)) + +(define-configuration/no-serialization home-dotfiles-configuration + (source-directory + (string (current-source-directory)) + "The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where +@code{home-dotfiles-configuration} appears.") + (directories + (list-of-plain-or-stow-directories '()) + "The list of dotfiles directories where @code{home-dotfiles-service-type} +will look for application dotfiles. Each element of the list is supposed to be +either a @code{home-dotfiles-plain-directory} or a +@code{home-dotfiles-stow-directory} record.") + (excluded + (list-of-strings %home-dotfiles-excluded) + "The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting each one of the @code{directories}.")) + +(define (strip-stow-dotfile file-name directory) + (let ((dotfile-name (string-drop file-name (1+ (string-length directory))))) + (match (string-split dotfile-name #\/) + ((package parts ...) + (string-join parts "/"))))) + +(define (strip-plain-dotfile file-name directory) + (string-drop file-name (+ 1 (string-length directory)))) + +(define (import-dotfiles directory files strip) "Return a list of objects compatible with @code{home-files-service-type}'s value. Each object is a pair where the first element is the relative path of a file and the second is a gexp representing the file content. Objects are generated by recursively visiting DIRECTORY and mapping its contents to the user's home directory, excluding files that match any of the patterns in EXCLUDED." - (define (strip file) - (string-drop file (+ 1 (string-length directory)))) - (define (format file) ;; Remove from FILE characters that cannot be used in the store. (string-append @@ -73,7 +143,7 @@ (define (format file) file))) (map (lambda (file) - (let ((stripped (strip file))) + (let ((stripped (strip file directory))) (list stripped (local-file file (format stripped) #:recursive? #t)))) @@ -88,11 +158,18 @@ (define excluded (define exclusion-rx (make-regexp (string-append "^.*(" (string-join excluded "|") ")$"))) - (define (directory-contents directory) - (find-files directory - (lambda (file stat) - (not (regexp-exec exclusion-rx - (basename file)))))) + (define* (directory-contents directory #:key (applications #f)) + (define (filter-files directory) + (find-files directory + (lambda (file stat) + (not (regexp-exec exclusion-rx + (basename file)))))) + (if applications + (append-map filter-files + (map (lambda (app) + (string-append directory "/" app)) + applications)) + (filter-files directory))) (define (resolve directory) ;; Resolve DIRECTORY relative to the 'source-directory' field of CONFIG. @@ -101,10 +178,24 @@ (define (resolve directory) (in-vicinity (home-dotfiles-configuration-source-directory config) directory))) - (append-map (lambda (directory) - (let* ((directory (resolve directory)) - (contents (directory-contents directory))) - (import-dotfiles directory contents))) + (append-map (lambda (record) + (let* ((name (if (home-dotfiles-plain-directory? record) + (home-dotfiles-plain-directory-name record) + (home-dotfiles-stow-directory-name record))) + (strip (if (home-dotfiles-plain-directory? record) + strip-plain-dotfile + strip-stow-dotfile)) + (applications + (and (home-dotfiles-stow-directory? record) + (let ((apps + (home-dotfiles-stow-directory-applications + record))) + (and (maybe-value-set? apps) apps)))) + (directory (resolve name)) + (contents + (directory-contents directory + #:applications applications))) + (import-dotfiles directory contents strip))) (home-dotfiles-configuration-directories config))) (define-public home-dotfiles-service-type base-commit: bd87416648929f38c0173f047776d7675ea8a10d -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 16 14:07:27 2024 Received: (at 68857) by debbugs.gnu.org; 16 Feb 2024 19:07:27 +0000 Received: from localhost ([127.0.0.1]:60210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb3YU-0004Vh-Sq for submit@debbugs.gnu.org; Fri, 16 Feb 2024 14:07:27 -0500 Received: from mail-lf1-f50.google.com ([209.85.167.50]:53753) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rb3YP-0004VQ-0J for 68857@debbugs.gnu.org; Fri, 16 Feb 2024 14:07:24 -0500 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-511898b6c9eso3006263e87.3 for <68857@debbugs.gnu.org>; Fri, 16 Feb 2024 11:07:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sarg.org.ru; s=google; t=1708110355; x=1708715155; darn=debbugs.gnu.org; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=WhaJXe2T3Wbb6tdsY5oB9gFTHOYpxXLCbPOjh1j270Y=; b=BTW6nQbGkl9YvQrvWFkyNqAEz7rOzOrjKW+C6XxlJZa4oPJbGHbLPCNQsXQzpUvBnv SWoo8lFv9GzOiDBdcnKgMjmKIORfH+1yoqa75zxbfRLoW9CYGzoy0sbJfr1IGkDfw1yq /DdBQ0tQzHfGbBlHD2ouVh3VZiYaxW/dn4Evc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708110355; x=1708715155; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WhaJXe2T3Wbb6tdsY5oB9gFTHOYpxXLCbPOjh1j270Y=; b=LxPPIa+vNjloAVVqgfKPaROqw0PImjH6DB/jEVPQ7nyBJw9oKkmJXEWYDg/f+HtXEA RB8492Bc+CeRUTRlVAWADrQ2KRLq7KGi5OKGNDEco2jLxnAHeUMpj1h/5pTu1/vBnw+a Bh6HRUUmhPRv5Fr+6IDBzZLUwxvJA0T8VYvgdHf1cBYaK3veStqOPGb9zwVcKPoJWV6n lbYHKpcnI4DWy1uZKrU4PinniBO6t9iHFTyqRYto7tFAVc5s9S+yfDAS4VoIFREeYe6t Jmz2nnjSOZruoYOGOSrolNezlE4ijOGeEHc81XDpIowPLKF9LQY4MyrKg+s6dkWZ4v2u nzEA== X-Gm-Message-State: AOJu0YxcZV6mvCsPGSQxHJDQqUDQ5ckXiBBF7Op5/RCrq4d6/Yi9snP8 W3VGacBBG6Zg3sKd2F2mFqWglRSmMZ45XouerxESRF5oEZjFjCPL13BbaWdy58A= X-Google-Smtp-Source: AGHT+IEz9nlEi+9Ia3E8vDi5ibui6EY3uFf9db9ToHN5h3zkxNt2HCA59DR3OGU62Rxx3vQfAWq8WQ== X-Received: by 2002:ac2:5a4a:0:b0:512:8717:127a with SMTP id r10-20020ac25a4a000000b005128717127amr3469634lfn.24.1708110355386; Fri, 16 Feb 2024 11:05:55 -0800 (PST) Received: from localhost ([2a02:2454:a09d:d000:3f1e:a87:ccd2:4aec]) by smtp.gmail.com with ESMTPSA id c18-20020a50f612000000b00561fbfebdb5sm265584edn.96.2024.02.16.11.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:05:55 -0800 (PST) References: <736b3c27-c913-38b2-f89a-ccc5f486a665@autistici.org> User-agent: mu4e 1.10.8; emacs 29.1 From: Sergey Trofimov To: paul Subject: Re: [bug#68857] [PATCH] gnu: home: dotfiles: Avoid creating extra directory in $HOME. Date: Fri, 16 Feb 2024 19:57:24 +0100 In-reply-to: <736b3c27-c913-38b2-f89a-ccc5f486a665@autistici.org> Message-ID: <87le7kmdpq.fsf@sarg.org.ru> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 68857 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 68857@debbugs.gnu.org, janneke@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 (--) Hi Paul, paul writes: > Hi everyone, > > thank you for your help and comments so far. I have a proposal > that should: > > - solve https://issues.guix.gnu.org/68848 > > - allow for both plain and GNU Stow's layouts > > - for GNU Stow layouts, allows to select a subset of application > dotfiles to be > provisioned in the user's home directory. Please Sergey let me > know if this > covers your use case . > My dotfiles tree is (relative to ~/.dotfiles): ./guix/home.scm ./backup/.config/.. ./android/.config/.. ... It works with such config: --8<---------------cut here---------------start------------->8--- (service home-dotfiles-service-type (home-dotfiles-configuration (directories (list (home-dotfiles-stow-directory (name "..") (applications '("backup" "android" "email" "xsession" "git" "qutebrowser" "desktop"))))))) --8<---------------cut here---------------end--------------->8--- `name` is in fact a relative path, so this field should be renamed. `applications` are called `PACKAGES` in `stow` man page, so I'd rename it to match. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 20 04:37:43 2024 Received: (at 68857) by debbugs.gnu.org; 20 Feb 2024 09:37:44 +0000 Received: from localhost ([127.0.0.1]:44290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcMZL-00038a-Bh for submit@debbugs.gnu.org; Tue, 20 Feb 2024 04:37:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcMZI-00038I-Bl for 68857@debbugs.gnu.org; Tue, 20 Feb 2024 04:37:41 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcMYp-0007ZC-Mg; Tue, 20 Feb 2024 04:37:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=iaJYdtEiNKGhq+DapAK2FuwKvVkiCGvgCQm126fx4S4=; b=g7DzkYzfqENHBo9ygcOa bO2qo2WEUbW8CXQiGD5Hn4UV0iS3KT9dzZJ3aJtZVuIf5YgR/IZAoS5/GIt1PjGhyB/dwwOI9WjU+ EVHj1w6JkNFlN1H/MQjlioFxtSwvyk0uq8z4ev9AUM+0bv38XL2V5unJrkwAoUhk4NJXMgeY2bE/d pNpy/lUmJTVGBWvATsuAo7gYR9SJWTrkwLeX9SOMkimSy46SJrvSsHFtDTI2FFg6wRw8qvyGw+9sZ /796fqtCAltVB+zVI3dLtaCVsRY1WR4q8zokXCDdFP1llwaJs34jD3oIP0hsTuOqmjxwTf0hpdJ5+ rk7lH7TzCwxF9A==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Giacomo Leidi Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: <20240216171724.22171-1-goodoldpaul@autistici.org> (Giacomo Leidi's message of "Fri, 16 Feb 2024 18:17:19 +0100") References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <20240216171724.22171-1-goodoldpaul@autistici.org> Date: Tue, 20 Feb 2024 10:37:08 +0100 Message-ID: <87msrvmq7v.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 68857 Cc: 68857@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: -5.2 (-----) Hello Giacomo! Giacomo Leidi skribis: > The current implementation of the home-dotfiles-service-type contradicts > the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch > properly implements both the plain and Stow dotfiles directory layouts. > > It does so by creating a new record type for each directory layout. This > approach, compared to having a single field in > home-dotfiles-configuration, > allows for having different layouts for different directories and to > carry additional information that might be required for some layouts. > > Implementing a new layout should just be a matter of creating a new > record type, defining a strip-*-dotfile procedure and plugging them into > the home-dotfiles-service-type. > > * gnu/home/services/dotfiles (home-dotfiles-stow-directory): New > variable; > (home-dotfiles-plain-directory): new variable; > (home-dotfiles-configuration): migrate to (gnu services configuration); > (strip-stow-dotfile): new variable; > (strip-plain-dotfile): new variable; > (home-dotfiles-configuration->files): use the new record types; > [directory-contents]: allow for > selecting a subset of application dotfile directories; > * doc/guix.texi: document the new layouts. > > Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 Thanks for working on it! > +There are two supported dotfiles directory layouts, for now. The > +@code{home-dotfiles-plain-directory} layout, which is structured as foll= ows: > + > +@example > +~$ tree -a ./dotfiles/ > +dotfiles/ > +=E2=94=9C=E2=94=80=E2=94=80 .gitconfig > +=E2=94=9C=E2=94=80=E2=94=80 .gnupg > +=E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 gpg-agent.conf > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 gpg.conf > +=E2=94=9C=E2=94=80=E2=94=80 .guile > +=E2=94=9C=E2=94=80=E2=94=80 .config > +=E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 guix > +=E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 channels.scm > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 nixpkgs > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 config.nix > +=E2=94=9C=E2=94=80=E2=94=80 .nix-channels > +=E2=94=9C=E2=94=80=E2=94=80 .tmux.conf > +=E2=94=94=E2=94=80=E2=94=80 .vimrc > +@end example I=E2=80=99d add a sentence like: =E2=80=9CThis tree structure is installed = as is to the home directory upon @command{guix home reconfigure}.=E2=80=9D > -(define-record-type* > - home-dotfiles-configuration make-home-dotfiles-configuration > - home-dotfiles-configuration? > - (source-directory home-dotfiles-configuration-source-directory > - (default (current-source-directory)) > - (innate)) > - (directories home-dotfiles-configuration-directories ;list= of strings > - (default '())) > - (excluded home-dotfiles-configuration-excluded ;list of= strings > - (default %home-dotfiles-excluded))) > - > -(define (import-dotfiles directory files) > +(define list-of-strings? > + (list-of string?)) > + > +(define-maybe list-of-strings) > + > +(define-configuration/no-serialization home-dotfiles-stow-directory [...] > +(define-configuration/no-serialization home-dotfiles-configuration I think we should keep =E2=80=98home-dotfiles-configuration=E2=80=99 for co= mpatibility (this patch keeps the exports but removes the actual definition IIUC). Also, as a rule of thumb, the configuration of a given service type is usually monomorphic (always the same configuration record type), which I find clearer. Instead of having these two record types, would it be an option to add a =E2=80=98type=E2=80=99 field (or similar) to ,= as discussed earlier? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 20 13:38:36 2024 Received: (at 68857) by debbugs.gnu.org; 20 Feb 2024 18:38:36 +0000 Received: from localhost ([127.0.0.1]:46546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcV0m-0000r8-9M for submit@debbugs.gnu.org; Tue, 20 Feb 2024 13:38:36 -0500 Received: from confino.investici.org ([93.190.126.19]:51879) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcV0h-0000qt-J4 for 68857@debbugs.gnu.org; Tue, 20 Feb 2024 13:38:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1708454281; bh=EDoRqsb6NtegefhnC7jomG1czPzQcB9MojNbN3hoqRM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=U/iZHJxl+jQYtYw5xyszPsUytbSXNO89HeF05Hbp16pSk+XVezKEwmh1mzYrv345a 55OzuPrWO1EwzsBl4YB2LrNsIpy5CGqRAm9+AiJh4yBdvj7ZCXcgcIpxrSac6puYQ5 nBDr7Iv6tE0Tcx8xmZp5MvMlufjbkdJGVVotsOHg= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TfSp12J3wz119q; Tue, 20 Feb 2024 18:38:01 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TfSp10Vghz119n; Tue, 20 Feb 2024 18:38:01 +0000 (UTC) Message-ID: <24f9f59a-79e8-27bc-5fe4-da160ed64187@autistici.org> Date: Tue, 20 Feb 2024 19:38:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <20240216171724.22171-1-goodoldpaul@autistici.org> <87msrvmq7v.fsf_-_@gnu.org> From: paul In-Reply-To: <87msrvmq7v.fsf_-_@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 68857 Cc: 68857@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: -6.9 (------) Hi Ludo’ , On 2/20/24 10:37, Ludovic Courtès wrote: > Hello Giacomo! > > Giacomo Leidi skribis: > >> The current implementation of the home-dotfiles-service-type contradicts >> the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch >> properly implements both the plain and Stow dotfiles directory layouts. >> >> It does so by creating a new record type for each directory layout. This >> approach, compared to having a single field in >> home-dotfiles-configuration, >> allows for having different layouts for different directories and to >> carry additional information that might be required for some layouts. >> >> Implementing a new layout should just be a matter of creating a new >> record type, defining a strip-*-dotfile procedure and plugging them into >> the home-dotfiles-service-type. >> >> * gnu/home/services/dotfiles (home-dotfiles-stow-directory): New >> variable; >> (home-dotfiles-plain-directory): new variable; >> (home-dotfiles-configuration): migrate to (gnu services configuration); >> (strip-stow-dotfile): new variable; >> (strip-plain-dotfile): new variable; >> (home-dotfiles-configuration->files): use the new record types; >> [directory-contents]: allow for >> selecting a subset of application dotfile directories; >> * doc/guix.texi: document the new layouts. >> >> Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 > Thanks for working on it! > >> +There are two supported dotfiles directory layouts, for now. The >> +@code{home-dotfiles-plain-directory} layout, which is structured as follows: >> + >> +@example >> +~$ tree -a ./dotfiles/ >> +dotfiles/ >> +├── .gitconfig >> +├── .gnupg >> +│ ├── gpg-agent.conf >> +│ └── gpg.conf >> +├── .guile >> +├── .config >> +│ ├── guix >> +│ │ └── channels.scm >> +│ └── nixpkgs >> +│ └── config.nix >> +├── .nix-channels >> +├── .tmux.conf >> +└── .vimrc >> +@end example > I’d add a sentence like: “This tree structure is installed as is to the > home directory upon @command{guix home reconfigure}.” I'm adding this to the manual, thanks! >> +(define-configuration/no-serialization home-dotfiles-configuration > I think we should keep ‘home-dotfiles-configuration’ for compatibility > (this patch keeps the exports but removes the actual > definition IIUC). We are keeping home-dotfiles-configuration , it's just now it is implemented with validation from (gnu services configuration) . The only thing changing is that home-dotfiles-configuration's directories field is now a list of either home-dotfiles-plain-directory or home-dotfiles-stow-directory records. > Also, as a rule of thumb, the configuration of a given service type is > usually monomorphic (always the same configuration record type), which I > find clearer. > > Instead of having these two record types, would it be an option to add a > ‘type’ field (or similar) to , as discussed > earlier? As I tried explaining in the commit message, this approach, compared to having a single field in home-dotfiles-configuration , allows for having different layouts for different directories and to carry additional information that might be needed for a given layout type. Such as the application field required to support some Stow's users workflows. What do you think about this approach? It should be general enough to support any kind of layout. Thank you for your time, giacomo From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 05:20:23 2024 Received: (at 68857) by debbugs.gnu.org; 27 Feb 2024 10:20:24 +0000 Received: from localhost ([127.0.0.1]:40872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1reuZT-0008Et-Br for submit@debbugs.gnu.org; Tue, 27 Feb 2024 05:20:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1reuZQ-0008E3-UX for 68857@debbugs.gnu.org; Tue, 27 Feb 2024 05:20:21 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1reuWL-0002kX-FW; Tue, 27 Feb 2024 05:17:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=Hn9SsLUzVo8lXbxPRcmz9WuyVBAbrof1bre2gHRED6E=; b=TnnzQBoEGknzFqfl+rCq HWFUOV/vqr/sBb92ChBwTPqocdFcOhKS4doYzTJFl9djg7Sj9gTJfm0Yha1BPNoW/KVsZpiddOvYA HTCMi6oJ4uUwHsxQDYIySwxY4FPGR99Or6izkZYiegdxjGhCITRn0sWNmc0Tf/zOkvaJv7JlI7pJ2 CD+Y8X9DO7hCWgUChxQv11PNqCyKLLLvsInHrJJI1VNl+0e1q+kNZTAF8sUwUK7xXJnH55iZknYhC ztEd/97h69Vw3dIroS163JSwBjy12WtEA7Lbn1Nw67d4qfIlpej1VtMWbDkPnpXTNUNhBFZeQ/btz DJOx8ZKyYf44IA==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: paul Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: <24f9f59a-79e8-27bc-5fe4-da160ed64187@autistici.org> (paul's message of "Tue, 20 Feb 2024 19:38:00 +0100") References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <20240216171724.22171-1-goodoldpaul@autistici.org> <87msrvmq7v.fsf_-_@gnu.org> <24f9f59a-79e8-27bc-5fe4-da160ed64187@autistici.org> Date: Tue, 27 Feb 2024 11:17:07 +0100 Message-ID: <87bk82i53w.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68857 Cc: 68857@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: -3.3 (---) Hi, paul skribis: > As I tried explaining in the commit message, this approach, compared > to having a single field in home-dotfiles-configuration , allows for > having different layouts for different directories and to carry > additional information that might be needed for a given layout > type. Such as the application field required to support some Stow's > users workflows. What do you think about this approach? It should be > general enough to support any kind of layout. I think we=E2=80=99ll only want to support two layouts: Stow and =E2=80=9Cp= lain=E2=80=9D; we should avoid overengineering that. That=E2=80=99s why a simple (layout 'st= ow) field seems good enough for me. WDYT? Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 06:33:25 2024 Received: (at 68857) by debbugs.gnu.org; 27 Feb 2024 11:33:25 +0000 Received: from localhost ([127.0.0.1]:45384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1revi7-0006Qz-Dm for submit@debbugs.gnu.org; Tue, 27 Feb 2024 06:33:25 -0500 Received: from confino.investici.org ([93.190.126.19]:30509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1revi4-0006Qk-0Z for 68857@debbugs.gnu.org; Tue, 27 Feb 2024 06:33:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1709033564; bh=29T0ATxMx4j1Nnonh0CSfj8nk84tQe0VvLJ0mafuIAs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=VEoMei8NsbrYhVRW93esWiNgQzs4srEWtY4P8xLRdezGEc1sKlFOYj7PHB55fUxw9 mOjdD33ocFbwhGoviyTN8Zfzjid5rM95CwK5neb5SOVins03oCJEqoyNScIb+7+7dh 3m3DA86rAXnV05WkuMfcVX72VEUqHk9dG2WXsFhQ= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4Tkb241Cx7z1128; Tue, 27 Feb 2024 11:32:44 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4Tkb240b2wz1125; Tue, 27 Feb 2024 11:32:44 +0000 (UTC) Message-ID: <91b3e9ec-b07d-342b-c525-63c6a4ffc09b@autistici.org> Date: Tue, 27 Feb 2024 12:32:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <20240216171724.22171-1-goodoldpaul@autistici.org> <87msrvmq7v.fsf_-_@gnu.org> <24f9f59a-79e8-27bc-5fe4-da160ed64187@autistici.org> <87bk82i53w.fsf_-_@gnu.org> From: paul In-Reply-To: <87bk82i53w.fsf_-_@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 68857 Cc: 68857@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: -5.0 (-----) Ah obviously I replied to you with the wrong address (leidigiacomo@outlook.com) thanks to Thunderbird :( apologies for the confusion. giacomo From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 07:36:21 2024 Received: (at 68857) by debbugs.gnu.org; 27 Feb 2024 12:36:21 +0000 Received: from localhost ([127.0.0.1]:49505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rewh1-0003kP-Kt for submit@debbugs.gnu.org; Tue, 27 Feb 2024 07:36:21 -0500 Received: from confino.investici.org ([93.190.126.19]:33223) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rewgx-0003k9-Qd for 68857@debbugs.gnu.org; Tue, 27 Feb 2024 07:36:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1709037347; bh=iAV6imcRZ3DZT2XV3MMhXOqgG4JdwcrwvhbuZex+h9g=; h=From:To:Cc:Subject:Date:From; b=fQBFO/CEuJhQGroa+9xcor1axXLTaoAZiRFl6BLwzNKlqMMq+EzHBhD3Meu9Jh/Y8 wpJr4XVlqjoosUmSFGUvtonl8Y7mlcwJSthWgfrNaltdgQGWlHpXShA71TcyvZOlRt m0xBVGe+vMMwncOeGMXy66L6cMi6w3JEZsIneQoo= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4TkcQq6K19z115m; Tue, 27 Feb 2024 12:35:47 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4TkcQq5S5kz111P; Tue, 27 Feb 2024 12:35:47 +0000 (UTC) From: Giacomo Leidi To: 68857@debbugs.gnu.org Subject: [PATCH v3] gnu: home: dotfiles: Properly support both plain and Stow directory layouts. Date: Tue, 27 Feb 2024 13:35:08 +0100 Message-ID: <413c752eb714951dfe350517fd0f783710a26386.1709037308.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Debbugs-Cc: ( , Andrew Tropin , Ludovic Courtès Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68857 Cc: Giacomo Leidi 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.7 (-) The current implementation of the home-dotfiles-service-type contradicts the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch properly implements both the plain and Stow dotfiles directory layouts. It does so by refactoring home-dotfiles-configuration, renaming the directories field to a single directory, adding a new packages field to support GNU Stow's users workflow and introducing a new layout field to switch between the two directory layouts. * gnu/home/services/dotfiles (home-dotfiles-configuration): Migrate to (gnu services configuration); [directories]: rename to...; [directory]: ...this, new field; [packages]: new field; [layout]: new field; (strip-stow-dotfile): new variable; (strip-plain-dotfile): new variable; (home-dotfiles-configuration->files): use the new fields; [directory-contents]: allow for selecting a subset of application dotfile directories; * doc/guix.texi: document the new layouts. Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 --- doc/guix.texi | 84 ++++++++++++++++------ gnu/home/services/dotfiles.scm | 123 ++++++++++++++++++++++++--------- 2 files changed, 154 insertions(+), 53 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index f6476e0d81..89f9887fe3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -111,7 +111,7 @@ Copyright @copyright{} 2022 John Kehayias@* Copyright @copyright{} 2022⁠–⁠2023 Bruno Victal@* Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@* -Copyright @copyright{} 2023 Giacomo Leidi@* +Copyright @copyright{} 2023-2024 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby@* Copyright @copyright{} 2023 Nathaniel Nicandro@* @@ -44444,17 +44444,42 @@ Essential Home Services @cindex Stow-like dot file management The @code{home-dotfiles-service-type} from @code{(gnu home services dotfiles)} is designed to ease the way into using Guix Home for this kind of users, -allowing them to point the service to their dotfiles directory, which must -follow the layout suggested by -@uref{https://www.gnu.org/software/stow/, GNU Stow}, -and have their dotfiles automatically deployed to their user home, without +allowing them to point the service to their dotfiles directory without migrating them to Guix native configurations. -The dotfiles directory layout is expected to be structured as follows. Please -keep in mind that it is advisable to keep your dotfiles directories under +Please keep in mind that it is advisable to keep your dotfiles directories under version control, for example in the same repository where you'd track your Guix Home configuration. +There are two supported dotfiles directory layouts, for now. The +@code{'plain} layout, which is structured as follows: + +@example +~$ tree -a ./dotfiles/ +dotfiles/ +├── .gitconfig +├── .gnupg +│ ├── gpg-agent.conf +│ └── gpg.conf +├── .guile +├── .config +│ ├── guix +│ │ └── channels.scm +│ └── nixpkgs +│ └── config.nix +├── .nix-channels +├── .tmux.conf +└── .vimrc +@end example + +This tree structure is installed as is to the +home directory upon @command{guix home reconfigure}. + +The @code{'stow} layout, which must +follow the layout suggested by +@uref{https://www.gnu.org/software/stow/, GNU Stow} presents an additional +application specific directory layer, just like: + @example ~$ tree -a ./dotfiles/ dotfiles/ @@ -44484,8 +44509,10 @@ Essential Home Services @end example For an informal specification please refer to the Stow manual -(@pxref{Top,,, stow, Introduction}). A suitable configuration would then -be: +(@pxref{Top,,, stow, Introduction}). This tree structure is installed following +GNU Stow's logic to the home directory upon @command{guix home reconfigure}. + +A suitable configuration with a @code{'plain} layout could be: @lisp (home-environment @@ -44493,7 +44520,7 @@ Essential Home Services (services (service home-dotfiles-service-type (home-dotfiles-configuration - (directories (list "./dotfiles")))))) + (directory "./dotfiles"))))) @end lisp The expected home directory state would then be: @@ -44520,32 +44547,47 @@ Essential Home Services (and actually extends it), but designed to ease the way into using Guix Home for users that already track their dotfiles under some kind of version control. This service allows users to point Guix Home to their dotfiles -directory and have their files automatically deployed to their home directory -just like Stow would, without migrating all of their dotfiles to Guix native +directory and have their files automatically provisioned to their home +directory, without migrating all of their dotfiles to Guix native configurations. @end defvar +@c %start of fragment + @deftp {Data Type} home-dotfiles-configuration Available @code{home-dotfiles-configuration} fields are: @table @asis -@item @code{source-directory} (default: @code{(current-source-directory)}) -The path where dotfile directories are resolved. By default dotfile directories -are resolved relative the source location where +@item @code{source-directory} (default: @code{(current-source-directory)}) (type: string) +The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where @code{home-dotfiles-configuration} appears. -@item @code{directories} (type: list-of-strings) -The list of dotfiles directories where @code{home-dotfiles-service-type} will -look for application dotfiles. +@item @code{layout} (default: @code{'plain}) (type: symbol) +The intended layout of the specified @code{directory}. It can be either +@code{'stow} or @code{'plain}. + +@item @code{directory} (type: string) +The dotfiles directory where @code{home-dotfiles-service-type} +will look for application dotfiles. + +@item @code{packages} (type: maybe-list-of-strings) +The names of a subset of the GNU Stow package layer directories. When provided +the @code{home-dotfiles-service-type} will only provision dotfiles from this +subset of applications. This field will be ignored if @code{layout} is set +to @code{'plain}. -@item @code{exclude} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) -The list of file patterns @code{home-dotfiles-service-type} will exclude while -visiting each one of the @code{directories}. +@item @code{excluded} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) (type: list-of-strings) +The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting each one of the @code{directories}. @end table @end deftp + +@c %end of fragment + @defvar home-xdg-configuration-files-service-type The service is very similar to @code{home-files-service-type} (and actually extends it), but used for defining files, which will go to diff --git a/gnu/home/services/dotfiles.scm b/gnu/home/services/dotfiles.scm index 6a740c42ce..c7886e3763 100644 --- a/gnu/home/services/dotfiles.scm +++ b/gnu/home/services/dotfiles.scm @@ -20,18 +20,26 @@ (define-module (gnu home services dotfiles) #:use-module (gnu home services) #:use-module (gnu services) + #:use-module (gnu services configuration) #:autoload (guix build utils) (find-files) + #:use-module (guix diagnostics) #:use-module (guix gexp) - #:use-module (guix records) + #:use-module (guix i18n) #:use-module ((guix utils) #:select (current-source-directory)) #:use-module (srfi srfi-1) #:use-module (ice-9 ftw) + #:use-module (ice-9 match) #:use-module (ice-9 regex) #:export (home-dotfiles-service-type + home-dotfiles-configuration->files + home-dotfiles-configuration home-dotfiles-configuration? + home-dotfiles-configuration-fields + home-dotfiles-configuration-layout home-dotfiles-configuration-source-directory - home-dotfiles-configuration-directories + home-dotfiles-configuration-packages + home-dotfiles-configuration-directory home-dotfiles-configuration-excluded)) (define %home-dotfiles-excluded @@ -40,26 +48,64 @@ (define %home-dotfiles-excluded "\\.git" "\\.gitignore")) -(define-record-type* - home-dotfiles-configuration make-home-dotfiles-configuration - home-dotfiles-configuration? - (source-directory home-dotfiles-configuration-source-directory - (default (current-source-directory)) - (innate)) - (directories home-dotfiles-configuration-directories ;list of strings - (default '())) - (excluded home-dotfiles-configuration-excluded ;list of strings - (default %home-dotfiles-excluded))) - -(define (import-dotfiles directory files) +(define %home-dotfiles-layouts + '(plain stow)) + +(define (sanitize-layout value) + (if (member value %home-dotfiles-layouts) + value + (raise + (formatted-message + (G_ "layout field of home-dotfiles-configuration should be either 'plain +or 'stow, but ~a was found.") + value)))) + +(define list-of-strings? + (list-of string?)) + +(define-maybe list-of-strings) + +(define-configuration/no-serialization home-dotfiles-configuration + (source-directory + (string (current-source-directory)) + "The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where +@code{home-dotfiles-configuration} appears.") + (layout + (symbol 'plain) + "The intended layout of the specified @code{directory}. It can be either +@code{'stow} or @code{'plain}." + (sanitizer sanitize-layout)) + (directory + (string) + "The dotfiles directory where @code{home-dotfiles-service-type} +will look for application dotfiles.") + (packages + (maybe-list-of-strings) + "The names of a subset of the GNU Stow package layer directories. When provided +the @code{home-dotfiles-service-type} will only provision dotfiles from this +subset of applications. This field will be ignored if @code{layout} is set +to @code{'plain}.") + (excluded + (list-of-strings %home-dotfiles-excluded) + "The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting @code{directory}.")) + +(define (strip-stow-dotfile file-name directory) + (let ((dotfile-name (string-drop file-name (1+ (string-length directory))))) + (match (string-split dotfile-name #\/) + ((package parts ...) + (string-join parts "/"))))) + +(define (strip-plain-dotfile file-name directory) + (string-drop file-name (+ 1 (string-length directory)))) + +(define (import-dotfiles directory files strip) "Return a list of objects compatible with @code{home-files-service-type}'s value. Each object is a pair where the first element is the relative path of a file and the second is a gexp representing the file content. Objects are generated by recursively visiting DIRECTORY and mapping its contents to the user's home directory, excluding files that match any of the patterns in EXCLUDED." - (define (strip file) - (string-drop file (+ 1 (string-length directory)))) - (define (format file) ;; Remove from FILE characters that cannot be used in the store. (string-append @@ -73,7 +119,7 @@ (define (import-dotfiles directory files) file))) (map (lambda (file) - (let ((stripped (strip file))) + (let ((stripped (strip file directory))) (list stripped (local-file file (format stripped) #:recursive? #t)))) @@ -81,18 +127,25 @@ (define (import-dotfiles directory files) (define (home-dotfiles-configuration->files config) "Return a list of objects compatible with @code{home-files-service-type}'s -value, generated following GNU Stow's algorithm for each of the -directories in CONFIG, excluding files that match any of the patterns configured." +value, excluding files that match any of the patterns configured." + (define stow? (eq? (home-dotfiles-configuration-layout config) 'stow)) (define excluded (home-dotfiles-configuration-excluded config)) (define exclusion-rx (make-regexp (string-append "^.*(" (string-join excluded "|") ")$"))) - (define (directory-contents directory) - (find-files directory - (lambda (file stat) - (not (regexp-exec exclusion-rx - (basename file)))))) + (define* (directory-contents directory #:key (packages #f)) + (define (filter-files directory) + (find-files directory + (lambda (file stat) + (not (regexp-exec exclusion-rx + (basename file)))))) + (if (and stow? packages (maybe-value-set? packages)) + (append-map filter-files + (map (lambda (pkg) + (string-append directory "/" pkg)) + packages)) + (filter-files directory))) (define (resolve directory) ;; Resolve DIRECTORY relative to the 'source-directory' field of CONFIG. @@ -101,17 +154,23 @@ (define (home-dotfiles-configuration->files config) (in-vicinity (home-dotfiles-configuration-source-directory config) directory))) - (append-map (lambda (directory) - (let* ((directory (resolve directory)) - (contents (directory-contents directory))) - (import-dotfiles directory contents))) - (home-dotfiles-configuration-directories config))) + (let* ((directory (resolve (home-dotfiles-configuration-directory config))) + (packages + (home-dotfiles-configuration-packages config)) + (contents + (directory-contents directory + #:packages packages)) + (strip + (if stow? strip-stow-dotfile strip-plain-dotfile))) + (import-dotfiles directory contents strip))) (define-public home-dotfiles-service-type (service-type (name 'home-dotfiles) (extensions (list (service-extension home-files-service-type - home-dotfiles-configuration->files))) - (default-value (home-dotfiles-configuration)) + (lambda (config) + (when config + (home-dotfiles-configuration->files config)))))) + (default-value #f) (description "Files that will be put in the user's home directory following GNU Stow's algorithm, and further processed during activation."))) base-commit: 75bad75367fcf2c289fae3b40dbcc850f92177be -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 27 08:17:02 2024 Received: (at 68857) by debbugs.gnu.org; 27 Feb 2024 13:17:02 +0000 Received: from localhost ([127.0.0.1]:52263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rexKP-0005kb-0r for submit@debbugs.gnu.org; Tue, 27 Feb 2024 08:17:02 -0500 Received: from mail-vi1eur02olkn2037.outbound.protection.outlook.com ([40.92.48.37]:11648 helo=EUR02-VI1-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1revfy-0006GH-TG for 68857@debbugs.gnu.org; Tue, 27 Feb 2024 06:31:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z5g3IeGSesoOcvFlLQD6pCfnChUmsVwYwDvnalgNn5KdJctm81oV/2DqFEADI2pUZ0ByllVWRGdpOffxHHV4hvf/s3U6RlEEVxk7SFK0C3WMvYAMJQkCMoKCjPzNUEz9eiQ9uB//EvQzWnzcsZfV8w4+EO6y9tyr4kE/E8ZflfDVxecbS/sy2EWicUYVxXY+Bfn76aA0dyrOtzdKRAsuFVCmpgr9ktLyjuHczJ/AeX2txN+m34eWnJTUD13S88DiAsqashoHUq5ThTwjBCY7/JS84uyRevbGBMBDtdAQczxgaT9LIIYZktnusjw7msAJo+uUSC8oHIW6bQGfykwIyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uBBQ3/ZYnLQx0+QD5DyhrJoJ0kfWW4x2Ic/5QTiAa1A=; b=IsfcrEKbq0LaN10vYFHWwGiO39g6DFzpi6CJoK4RDO7TTh+Mr1TwM5nl//25euatdv4J5aso44q0c4wnWAaAK6CEQiTXtgx9oAa74Zda0DnoJ3oA4DM7A4rGfQ7OHKAQ04cP+8q3mbsu7i3KtO3rrpjxzlJMXzc5u0EKB/oiKtBJSZK0dyAqcXifRFrUvMNys/nEuoInrgrIbhhqhflgxrXwNfJSqsvPmKO+v/f/QDFcIUsH82eLiU16nswX/EdS6pKrjUU3/bpgSFJOlHZee93yxiM1kGwAxXkOuNH3ghvrqoxsvawpP+ygxneHrO6NHo4j1CSyFvErqFcMyodfMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uBBQ3/ZYnLQx0+QD5DyhrJoJ0kfWW4x2Ic/5QTiAa1A=; b=WLYjbuIXNfDyJtIULkinR+xNGFESGrSrveDajUTzu2Syb1TrfLC4LpI8as/RjWCWzkhb9poZp37/MiH0CUCxEW8eVk7JJu9KRplbP15KXKWQxFl2bzr1E9Rmlz0D8avmG2/+zlCgfh+fFkKwffBCws3UAGYg18eUrmNuiY7E+rWABfaN8h4KIvbuZsPY72rKZzw2ahsghYqgIV/awJZ7smz3b1TwEw85VVvuSXdcpfcZvuu5MO/ytQeg0D1hnHsphoxnNxb0H3DRE5y1CgFTxpW6MGpJS2fUlI94zX2F2KUAp0Bx9Vkq4AgSGF87+KyEsFB6BkddP4nYLS3EGe6LHw== Received: from AM8P189MB1396.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:24c::9) by VE1P189MB0959.EURP189.PROD.OUTLOOK.COM (2603:10a6:800:167::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Tue, 27 Feb 2024 11:30:38 +0000 Received: from AM8P189MB1396.EURP189.PROD.OUTLOOK.COM ([fe80::48f5:fb55:f689:41e9]) by AM8P189MB1396.EURP189.PROD.OUTLOOK.COM ([fe80::48f5:fb55:f689:41e9%6]) with mapi id 15.20.7316.023; Tue, 27 Feb 2024 11:30:38 +0000 Content-Type: multipart/alternative; boundary="------------SDp66iXtCnycEy62ZQQIHkQf" Message-ID: Date: Tue, 27 Feb 2024 12:30:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [bug#68857] gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <20240216171724.22171-1-goodoldpaul@autistici.org> <87msrvmq7v.fsf_-_@gnu.org> <24f9f59a-79e8-27bc-5fe4-da160ed64187@autistici.org> <87bk82i53w.fsf_-_@gnu.org> From: Giacomo Leidi In-Reply-To: <87bk82i53w.fsf_-_@gnu.org> X-TMN: [MEU2qTqbiuvc5W99kAQiLqvpNgStKpa6vmC5lEmC/6S9o8I8mfdHHNMm+kLwUMHz] X-ClientProxiedBy: MI1P293CA0020.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:3::18) To AM8P189MB1396.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:24c::9) X-Microsoft-Original-Message-ID: <48625ed1-b061-cd8e-4eec-05c0c84983b4@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM8P189MB1396:EE_|VE1P189MB0959:EE_ X-MS-Office365-Filtering-Correlation-Id: 0815f760-cc34-48aa-52eb-08dc37878592 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ow6AuFLNMWw9ImNSh7sh7iPE7m5bHGOYgz8arp44h2ODY9wq9LIn9Q7Mpc4VJiLRT/x9YGd/hjDzGBOl7QHOzs5VG8Ntjb+5jBkYX4U7TpItEIJ1HNkltiCt6h+Y/YEcGLqOrGPuczrtbqBqDnG3CRKqZL3ghJD8oyFDI9PremvjRobNTTpjexZF3W8Zq9+v0wKuJZk17lobLe4hjyx2eLvHGJvlz2YMgynSfiNtsxAxyrxrnc5h7M5AnnlYSaE3waq6bxCLaOwezQZ5mOYmLOYCHGni+QmAL1w5B7HmyHGhn8rrj6TneZ4fcneSHkK8Y9a9bWxzc6mvdaaA9/coS5ux9zwScKeMGAylY2OQw+Tjw5YHuUDbzubnFcWnwO5WJM4j6a+J/j0JlNjXU4J2KcdgU5ec6IcctFsOUCGyD/XkNDJVpfbko97Ku0vTWM2T/sz5P6YYzebwM8w/5iXxhA+6GY0VpfLVu340xaJ6+YjIHelHh1hzbWBruyKDhy+G6gDPKAC68PWxGi1KYsEei5O8ksp6MHbek2aJjVStVQB9L/KECcE4LAp0XnVowWfw X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N2JRVWd2bEpLTGNmRlBGbjF3eGFHNVJ1R3YxMmU2VHhnTm40ZitaNlpRZm4v?= =?utf-8?B?akZrVmJuWkl1ZGJQZTlXRkZiU0twUnpsN3N0MGhqamRENHRMMGNveUJTTVhm?= =?utf-8?B?Ykl2a3NaS0FwcVFzTDRHeWFDa2lmUnhvd3o1NEZrZEc1L3pPR0hNSGw5Q2xD?= =?utf-8?B?NW5SOEd3RjVQTVYvYkpqcUJ0RGc4cTVFRmhKbTZMRGpGaXZ2VFhRalFjc1Zi?= =?utf-8?B?STVnNGFnUHNESXR0cWMrVFRhcFhPbzJKaGxzc3pGVWNLVmRKa2dYQnR4S2lF?= =?utf-8?B?c28reWU0bWFCTlYwcDJLUnVBaU5zQkpCc0pnSm84Q3luWVhRYXVBdGtMMkxH?= =?utf-8?B?Z0FBK2ZGaXE3KzZoQWlQcThCZHZZUklOWlBBcmROVE5MQlRNNFkxTVJFeWlk?= =?utf-8?B?MDZkaVlFL0NIZWtxZWEzU1M0clBHaFlTbVJ6L3l6UmFGNUFCVXZJQkRsSmN3?= =?utf-8?B?dzR6ZnVta1RqTWJkaHhsZjZkM2pIcG9ickVzbkpXcktvaitIWFo2cG9lZTJx?= =?utf-8?B?MnNzZ1A5eFNWSHdVUkEwMUczYktFUXJNeS81Um1RaFZQOVJ5QmRDa09UcGZQ?= =?utf-8?B?WDR1NmZtZmlzS3JjS2JQL1QrYnlIR0JHMzhNbVVDOVJFUE1lNklqYXhoVnpF?= =?utf-8?B?S1EvNWlubFBKOFg1eWNGQ2c3cTFvaGx4UC92S3AzdTlYM1YvMG5kT2dVeFpT?= =?utf-8?B?dCtha2I5Y21Pc1RvajMyZzh4cUFCYy84ejMweXFQak5YMVROaFEvVE9kWFlm?= =?utf-8?B?dUxIMG8rSjNPa3lHeU9kSC9MK3JRemVrQTdGcG1jU3doVENYZVByZ0pEeHdG?= =?utf-8?B?UTZiQTl0WDkydjBUZzFZZjdWREUzRVpnMWMyeE1BL2ZKaWRjNlZXZW1PRDFu?= =?utf-8?B?bWFoZ1ZyZTcwQW0xSUZUVkkzUFBTWHBqQ1YxZENrWmYrdzgwNlV0VUVqWmRD?= =?utf-8?B?SUMzL1NKZTR2UTF5d1IzVndJRlFubG9SbVVSL1AyR0pucExwbzhnWkZORW5y?= =?utf-8?B?VEVGQW9vcDhybW5jdFZaV1IySEdYUjRkQkxVck1KSENsMWRjSWgrYUhrK3Z4?= =?utf-8?B?ZHhBVWlrOW9kNkpFd3Z4YjBhcncxQXNJS1JoVXRUWHMzT3JRVWVXTnI0L3Ir?= =?utf-8?B?VjRKNHZ1VmFLbW80YUNhSEM4bkNjN0IydFNTTkhSNFJOZGxTbVZ4ZkYwWkVv?= =?utf-8?B?cGFFeDZkc3cyUjM4QzBtM01ESTZSNEJrQkp1LzQyNmpFM28yTVU3anZmRyts?= =?utf-8?B?ak1yNG0vNmlRcmxtUUJKL3dUQXVzTGtFNmJmeHJ5bUVlNS9qNit0ZnNDRDM2?= =?utf-8?B?QlNiVXF4R3FaUGNvclFpbWxxZ0RyVTdNUWNxUURuV0IwK0NQTVpUek1IeGRZ?= =?utf-8?B?Tld2YjNmeldneGk1ZW0wTjJYN0RBTjZMZm5GQTBlcm15WjlNRUJnTTFVbGdJ?= =?utf-8?B?eUZSeWo1T2RIR0VLZ25UUDYwQVhvd29MdW8za0VMakNIdi9QQWN6ZXJwNitI?= =?utf-8?B?YlRWSktIUzE1bG56dXNISGRXTERncXB6MzdtcEhqbzRzNStYclJveWJkdzM1?= =?utf-8?B?VHhEMmpZNDZoRnhQb3V2dlUvT2s0UTFPaFo3VFA1ZU1ySGQvY21kc0tiWlBy?= =?utf-8?B?ZCtQakQ2RTUyV1pGbk5oNi9mOE1mS0xhTEtBM2d6bEFReTR1ZXFVRWY2TWs3?= =?utf-8?B?V1BhYklCUzFCR0wvR2V5R1VWMUdCNHZ4WG8yOGhYMG9OdDBwaXJ6bWx2N1RD?= =?utf-8?Q?yJ7vSiQIoX9txC57kY9/y9FQ5o5A/85rezDMkmj?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0815f760-cc34-48aa-52eb-08dc37878592 X-MS-Exchange-CrossTenant-AuthSource: AM8P189MB1396.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 11:30:38.2870 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1P189MB0959 X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: 68857 X-Mailman-Approved-At: Tue, 27 Feb 2024 08:16:59 -0500 Cc: 68857@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: -4.3 (----) --------------SDp66iXtCnycEy62ZQQIHkQf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Ludo' , First of all thank you for putting the time for working on this, I hope we are close to a solution :) On 2/27/24 11:17, Ludovic Courtès wrote: > I think we’ll only want to support two layouts: Stow and “plain”; we > should avoid overengineering that. That’s why a simple (layout 'stow) > field seems good enough for me. > > WDYT? I think it is important, if the effort is feasible, to not leave anyone behind (in terms of what the features of this service are) . Having a single field without further changes will introduce some ambiguity imo. We have these requirements in my understanding: 1. The service should support Stow's users workflows. This is a hard requirement in my opinion. Hence we need a way to select a subset the applications directories (the applications field of home-dotfiles-stow-directory in v2 of the patch). 2. The service should support Stow's users workflows. This is also a hard requirement. For this we just need the path of the dotfiles directory. 3. The service should support multiple dotfiles directories. This is not a hard requirement i believe, but we currently have this feature (the directories field of home-dotfiles-configuration is a list of strings not a string). Introducing a single layout field makes it impossible to unambiguously implement requirement 1. If the user has more than directory it really makes no sense to select the same subset of applications for each one of them. This is to say that I believe it makes little sense to have multiple directories if the layout and applications information are not linked somehow with each directory. I wouldn't call this overengineering, just implementing the features users need from this service. I hope you agree. Also since I first sent this service around Jan 2023 (when it was still the home-stow-migration-service), and it has been broken on master for some time I'd like to provide a fix for this situation as soon as possible (clearly the definition of brokennes and what changes to the API would be breaking user configs depends on the requirements one intends for the home-dotfiles-service-type, especially since the changes that broke master were introduced without consensus). I'm changing the code to: use the layout field, support Stow's users workflow adding a new optional field called packages, which makes sense only if the layout is 'stow, and I'm making the directories field a string instead of a list of strings. Please let me know your thoughts on this v3. Thank your for your work, giacomo --------------SDp66iXtCnycEy62ZQQIHkQf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi Ludo' ,

First of all thank you for putting the time for working on this, I hope we are close to a solution :)

On 2/27/24 11:17, Ludovic Courtès wrote:
I think we’ll only want to support two layouts: Stow and “plain”; we
should avoid overengineering that.  That’s why a simple (layout 'stow)
field seems good enough for me.

WDYT?

I think it is important, if the effort is feasible, to not leave anyone behind (in terms of what the features of this service are) . Having a single field without further changes will introduce some ambiguity imo. We have these requirements in my understanding:

  1. The service should support Stow's users workflows. This is a hard requirement in my opinion. Hence we need a way to select a subset the applications directories (the applications field of home-dotfiles-stow-directory in v2 of the patch).
  2. The service should support Stow's users workflows. This is also a hard requirement. For this we just need the path of the dotfiles directory.
  3. The service should support multiple dotfiles directories. This is not a hard requirement i believe, but we currently have this feature (the directories field of home-dotfiles-configuration is a list of strings not a string).
Introducing a single layout field makes it impossible to unambiguously implement requirement 1. If the user has more than directory it really makes no sense to select the same subset of applications for each one of them. This is to say that I believe it makes little sense to have multiple directories if the layout and applications information are not linked somehow with each directory. I wouldn't call this overengineering, just implementing the features users need from this service. I hope you agree.

Also since I first sent this service around Jan 2023 (when it was still the home-stow-migration-service), and it has been broken on master for some time I'd like to provide a fix for this situation as soon as possible (clearly the definition of brokennes and what changes to the API would be breaking user configs depends on the requirements one intends for the home-dotfiles-service-type, especially since the changes that broke master were introduced without consensus).

I'm changing the code to: use the layout field, support Stow's users workflow adding a new optional field called packages, which makes sense only if the layout is 'stow, and I'm making the directories field a string instead of a list of strings. Please let me know your thoughts on this v3.


Thank your for your work,


giacomo

--------------SDp66iXtCnycEy62ZQQIHkQf-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 04 10:47:16 2024 Received: (at 68857) by debbugs.gnu.org; 4 Mar 2024 15:47:16 +0000 Received: from localhost ([127.0.0.1]:44521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhAX6-0001RK-2s for submit@debbugs.gnu.org; Mon, 04 Mar 2024 10:47:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhAX4-0001R3-M2 for 68857@debbugs.gnu.org; Mon, 04 Mar 2024 10:47:15 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhAWU-00027e-3N; Mon, 04 Mar 2024 10:46:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=0HWVm22kqN9f1k1a6T/3oYYJYdJqrcRKzst7yxkVofk=; b=P3jEgtFE6V7G2yrEKDwC 88sQJHdet0q2G/KWLi+7h2ICPBeaalhKB9JSwlYv4G8F85wM3nsgm0lqIzZu5ULmNudeU1T/MTMU3 g657dZCDYa+ujqSi59quzH6zDmPbBrwmqzEuqmnaGNxBrdY4c0+O3KZSQKAwb/zSqL9mkqL+xiNzz WoZX8lUSt2THljQwyjp4xinanW2yXpBT52n+Ogg0R/7upPL8HiqbCHFu3PxBUspbW094oP0yhsP+V Cm9KNitPt6WqbiPxOQ1swueLo/KdFxNaRvUNF3uTAyz2kKd/XH/vHQ56uK7y2Vq3dJWqcg9tGpBtl 1lm73O8WQQBHiQ==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Giacomo Leidi Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: <413c752eb714951dfe350517fd0f783710a26386.1709037308.git.goodoldpaul@autistici.org> (Giacomo Leidi's message of "Tue, 27 Feb 2024 13:35:08 +0100") References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <413c752eb714951dfe350517fd0f783710a26386.1709037308.git.goodoldpaul@autistici.org> Date: Mon, 04 Mar 2024 16:46:35 +0100 Message-ID: <87bk7uf19g.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68857 Cc: paren@disroot.org, 68857@debbugs.gnu.org, Andrew Tropin 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: -3.3 (---) Hi, Giacomo Leidi skribis: > The current implementation of the home-dotfiles-service-type contradicts > the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch > properly implements both the plain and Stow dotfiles directory layouts. > > It does so by refactoring home-dotfiles-configuration, renaming the > directories field to a single directory, adding a new packages field to > support GNU Stow's users workflow and introducing a new layout field to > switch between the two directory layouts. > > * gnu/home/services/dotfiles (home-dotfiles-configuration): Migrate to > (gnu services configuration); > [directories]: rename to...; > [directory]: ...this, new field; > [packages]: new field; > [layout]: new field; > (strip-stow-dotfile): new variable; > (strip-plain-dotfile): new variable; > (home-dotfiles-configuration->files): use the new fields; > [directory-contents]: allow for > selecting a subset of application dotfile directories; > * doc/guix.texi: document the new layouts. > > Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 LGTM, but=E2=80=A6 > - (directories home-dotfiles-configuration-directories ;list= of strings > - (default '())) [...] > + (directory > + (string) > + "The dotfiles directory where @code{home-dotfiles-service-type} > +will look for application dotfiles.") This is an incompatible change. Can we keep the old =E2=80=98directories= =E2=80=99 field? (Maybe this change is worthwhile, but it=E2=80=99s beyond the scope of this patch series IMO, so I=E2=80=99d suggest discussing it separately.) > (define-public home-dotfiles-service-type > (service-type (name 'home-dotfiles) > (extensions > (list (service-extension home-files-service-type > - home-dotfiles-configuration->f= iles))) > - (default-value (home-dotfiles-configuration)) > + (lambda (config) > + (when config > + (home-dotfiles-configurati= on->files config)))))) > + (default-value #f) Better not provide a default value than provide one that is invalid. My suggestion would be to remove the =E2=80=98default-value=E2=80=99 field her= e. Apologies for the delays and thanks for your work and for your patience! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 06 15:52:41 2024 Received: (at 68857) by debbugs.gnu.org; 6 Mar 2024 20:52:41 +0000 Received: from localhost ([127.0.0.1]:51738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhyFl-0001jR-53 for submit@debbugs.gnu.org; Wed, 06 Mar 2024 15:52:41 -0500 Received: from confino.investici.org ([93.190.126.19]:57845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhyFj-0001jJ-Je for 68857@debbugs.gnu.org; Wed, 06 Mar 2024 15:52:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1709758320; bh=oT5TKZNfWbprgpHNOkjTXuYfDJ7+dCxEcTy41lnXHLg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=E70o+eFvAQmh23sc8d2VuptLJrBr9KgDgtGyiT0kEJzezAfTKc9RaySgQzU4odtjX ScPEF2yUOhCGPdM/Tzf2ey+oBojAZ01nnCIXVswVdHJs6TmBrOnHn3VaYDtaZz2gLH E8KnbriK/NfSYWYyXJ8UTf6Uo9XZg0+D+Hz64/LE= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4Tql3h096tz119V; Wed, 6 Mar 2024 20:52:00 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4Tql3g4GCPz119P; Wed, 6 Mar 2024 20:51:59 +0000 (UTC) Message-ID: <01faf36b-11a8-4cd4-7d15-89b6dd072a96@autistici.org> Date: Wed, 6 Mar 2024 21:51:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. Content-Language: en-US To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> <413c752eb714951dfe350517fd0f783710a26386.1709037308.git.goodoldpaul@autistici.org> <87bk7uf19g.fsf_-_@gnu.org> From: paul In-Reply-To: <87bk7uf19g.fsf_-_@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 68857 Cc: paren@disroot.org, 68857@debbugs.gnu.org, Andrew Tropin 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: -5.0 (-----) Hi Ludo , I should have addressed everything, I hope. Thank you again for your time reviewing this. I'm sending a  v4. giacomo From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 06 15:53:58 2024 Received: (at 68857) by debbugs.gnu.org; 6 Mar 2024 20:53:58 +0000 Received: from localhost ([127.0.0.1]:51742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhyGz-0001lF-I1 for submit@debbugs.gnu.org; Wed, 06 Mar 2024 15:53:58 -0500 Received: from confino.investici.org ([93.190.126.19]:58623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhyGx-0001l6-0E for 68857@debbugs.gnu.org; Wed, 06 Mar 2024 15:53:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1709758396; bh=KyTKp9+Y5tOvao5FVH6T7zBau3qai8s+o3jrfyGx8X4=; h=From:To:Cc:Subject:Date:From; b=ug1Swmrx1+9S6RlOkQfR3Y+nj8su95/ceWoYZ5AMymjKb69knQequp4P+Z7KXpmAv Xh7eY6To/slRaS/QfxCMT6pEWDUllq/ZqKQ3hH5HWFfGGFsiIgubwmlqK7CJGj9mSb Yvbx/QMebZbJG8YGx3tbjlkavaWeLTKxB/9duBaQ= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4Tql581LTnz119V; Wed, 6 Mar 2024 20:53:16 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4Tql57567pz119P; Wed, 6 Mar 2024 20:53:15 +0000 (UTC) From: Giacomo Leidi To: 68857@debbugs.gnu.org Subject: [PATCH v4] gnu: home: dotfiles: Properly support both plain and Stow directory layouts. Date: Wed, 6 Mar 2024 21:52:42 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Debbugs-Cc: ( , Andrew Tropin , Ludovic Courtès Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 68857 Cc: Giacomo Leidi 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.7 (-) The current implementation of the home-dotfiles-service-type contradicts the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch properly implements both the plain and Stow dotfiles directory layouts. It does so by refactoring home-dotfiles-configuration adding a new packages field to support GNU Stow's users workflow and introducing a new layout field to switch between the two directory layouts. * gnu/home/services/dotfiles (home-dotfiles-configuration): Migrate to (gnu services configuration); [packages]: new field; [layout]: new field; (strip-stow-dotfile): new variable; (strip-plain-dotfile): new variable; (home-dotfiles-configuration->files): use the new fields; [directory-contents]: allow for selecting a subset of application dotfile directories; * doc/guix.texi: document the new layouts. Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 --- doc/guix.texi | 84 ++++++++++++++++++------ gnu/home/services/dotfiles.scm | 115 +++++++++++++++++++++++++-------- 2 files changed, 151 insertions(+), 48 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 87fe9f803c..8a33c4aa55 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -111,7 +111,7 @@ Copyright @copyright{} 2022 John Kehayias@* Copyright @copyright{} 2022⁠–⁠2023 Bruno Victal@* Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@* -Copyright @copyright{} 2023 Giacomo Leidi@* +Copyright @copyright{} 2023-2024 Giacomo Leidi@* Copyright @copyright{} 2022 Antero Mejr@* Copyright @copyright{} 2023 Karl Hallsby@* Copyright @copyright{} 2023 Nathaniel Nicandro@* @@ -44667,17 +44667,42 @@ Essential Home Services @cindex Stow-like dot file management The @code{home-dotfiles-service-type} from @code{(gnu home services dotfiles)} is designed to ease the way into using Guix Home for this kind of users, -allowing them to point the service to their dotfiles directory, which must -follow the layout suggested by -@uref{https://www.gnu.org/software/stow/, GNU Stow}, -and have their dotfiles automatically deployed to their user home, without +allowing them to point the service to their dotfiles directory without migrating them to Guix native configurations. -The dotfiles directory layout is expected to be structured as follows. Please -keep in mind that it is advisable to keep your dotfiles directories under +Please keep in mind that it is advisable to keep your dotfiles directories under version control, for example in the same repository where you'd track your Guix Home configuration. +There are two supported dotfiles directory layouts, for now. The +@code{'plain} layout, which is structured as follows: + +@example +~$ tree -a ./dotfiles/ +dotfiles/ +├── .gitconfig +├── .gnupg +│ ├── gpg-agent.conf +│ └── gpg.conf +├── .guile +├── .config +│ ├── guix +│ │ └── channels.scm +│ └── nixpkgs +│ └── config.nix +├── .nix-channels +├── .tmux.conf +└── .vimrc +@end example + +This tree structure is installed as is to the +home directory upon @command{guix home reconfigure}. + +The @code{'stow} layout, which must +follow the layout suggested by +@uref{https://www.gnu.org/software/stow/, GNU Stow} presents an additional +application specific directory layer, just like: + @example ~$ tree -a ./dotfiles/ dotfiles/ @@ -44707,8 +44732,10 @@ Essential Home Services @end example For an informal specification please refer to the Stow manual -(@pxref{Top,,, stow, Introduction}). A suitable configuration would then -be: +(@pxref{Top,,, stow, Introduction}). This tree structure is installed following +GNU Stow's logic to the home directory upon @command{guix home reconfigure}. + +A suitable configuration with a @code{'plain} layout could be: @lisp (home-environment @@ -44716,7 +44743,7 @@ Essential Home Services (services (service home-dotfiles-service-type (home-dotfiles-configuration - (directories (list "./dotfiles")))))) + (directories '("./dotfiles")))))) @end lisp The expected home directory state would then be: @@ -44743,32 +44770,47 @@ Essential Home Services (and actually extends it), but designed to ease the way into using Guix Home for users that already track their dotfiles under some kind of version control. This service allows users to point Guix Home to their dotfiles -directory and have their files automatically deployed to their home directory -just like Stow would, without migrating all of their dotfiles to Guix native +directory and have their files automatically provisioned to their home +directory, without migrating all of their dotfiles to Guix native configurations. @end defvar +@c %start of fragment + @deftp {Data Type} home-dotfiles-configuration Available @code{home-dotfiles-configuration} fields are: @table @asis -@item @code{source-directory} (default: @code{(current-source-directory)}) -The path where dotfile directories are resolved. By default dotfile directories -are resolved relative the source location where +@item @code{source-directory} (default: @code{(current-source-directory)}) (type: string) +The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where @code{home-dotfiles-configuration} appears. -@item @code{directories} (type: list-of-strings) -The list of dotfiles directories where @code{home-dotfiles-service-type} will -look for application dotfiles. +@item @code{layout} (default: @code{'plain}) (type: symbol) +The intended layout of the specified @code{directory}. It can be either +@code{'stow} or @code{'plain}. + +@item @code{directories} (default: @code{'()}) (type: list-of-strings) +The list of dotfiles directories where @code{home-dotfiles-service-type} +will look for application dotfiles. + +@item @code{packages} (type: maybe-list-of-strings) +The names of a subset of the GNU Stow package layer directories. When provided +the @code{home-dotfiles-service-type} will only provision dotfiles from this +subset of applications. This field will be ignored if @code{layout} is set +to @code{'plain}. -@item @code{exclude} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) -The list of file patterns @code{home-dotfiles-service-type} will exclude while -visiting each one of the @code{directories}. +@item @code{excluded} (default: @code{'(".*~" ".*\\.swp" "\\.git" "\\.gitignore")}) (type: list-of-strings) +The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting each one of the @code{directories}. @end table @end deftp + +@c %end of fragment + @defvar home-xdg-configuration-files-service-type The service is very similar to @code{home-files-service-type} (and actually extends it), but used for defining files, which will go to diff --git a/gnu/home/services/dotfiles.scm b/gnu/home/services/dotfiles.scm index 6a740c42ce..823bdb03fb 100644 --- a/gnu/home/services/dotfiles.scm +++ b/gnu/home/services/dotfiles.scm @@ -20,17 +20,25 @@ (define-module (gnu home services dotfiles) #:use-module (gnu home services) #:use-module (gnu services) + #:use-module (gnu services configuration) #:autoload (guix build utils) (find-files) + #:use-module (guix diagnostics) #:use-module (guix gexp) - #:use-module (guix records) + #:use-module (guix i18n) #:use-module ((guix utils) #:select (current-source-directory)) #:use-module (srfi srfi-1) #:use-module (ice-9 ftw) + #:use-module (ice-9 match) #:use-module (ice-9 regex) #:export (home-dotfiles-service-type + home-dotfiles-configuration->files + home-dotfiles-configuration home-dotfiles-configuration? + home-dotfiles-configuration-fields + home-dotfiles-configuration-layout home-dotfiles-configuration-source-directory + home-dotfiles-configuration-packages home-dotfiles-configuration-directories home-dotfiles-configuration-excluded)) @@ -40,26 +48,64 @@ (define %home-dotfiles-excluded "\\.git" "\\.gitignore")) -(define-record-type* - home-dotfiles-configuration make-home-dotfiles-configuration - home-dotfiles-configuration? - (source-directory home-dotfiles-configuration-source-directory - (default (current-source-directory)) - (innate)) - (directories home-dotfiles-configuration-directories ;list of strings - (default '())) - (excluded home-dotfiles-configuration-excluded ;list of strings - (default %home-dotfiles-excluded))) - -(define (import-dotfiles directory files) +(define %home-dotfiles-layouts + '(plain stow)) + +(define (sanitize-layout value) + (if (member value %home-dotfiles-layouts) + value + (raise + (formatted-message + (G_ "layout field of home-dotfiles-configuration should be either 'plain +or 'stow, but ~a was found.") + value)))) + +(define list-of-strings? + (list-of string?)) + +(define-maybe list-of-strings) + +(define-configuration/no-serialization home-dotfiles-configuration + (source-directory + (string (current-source-directory)) + "The path where dotfile directories are resolved. By default dotfile +directories are resolved relative the source location where +@code{home-dotfiles-configuration} appears.") + (layout + (symbol 'plain) + "The intended layout of the specified @code{directory}. It can be either +@code{'stow} or @code{'plain}." + (sanitizer sanitize-layout)) + (directories + (list-of-strings '()) + "The list of dotfiles directories where @code{home-dotfiles-service-type} +will look for application dotfiles.") + (packages + (maybe-list-of-strings) + "The names of a subset of the GNU Stow package layer directories. When provided +the @code{home-dotfiles-service-type} will only provision dotfiles from this +subset of applications. This field will be ignored if @code{layout} is set +to @code{'plain}.") + (excluded + (list-of-strings %home-dotfiles-excluded) + "The list of file patterns @code{home-dotfiles-service-type} will exclude +while visiting @code{directory}.")) + +(define (strip-stow-dotfile file-name directory) + (let ((dotfile-name (string-drop file-name (1+ (string-length directory))))) + (match (string-split dotfile-name #\/) + ((package parts ...) + (string-join parts "/"))))) + +(define (strip-plain-dotfile file-name directory) + (string-drop file-name (+ 1 (string-length directory)))) + +(define (import-dotfiles directory files strip) "Return a list of objects compatible with @code{home-files-service-type}'s value. Each object is a pair where the first element is the relative path of a file and the second is a gexp representing the file content. Objects are generated by recursively visiting DIRECTORY and mapping its contents to the user's home directory, excluding files that match any of the patterns in EXCLUDED." - (define (strip file) - (string-drop file (+ 1 (string-length directory)))) - (define (format file) ;; Remove from FILE characters that cannot be used in the store. (string-append @@ -73,7 +119,7 @@ (define (import-dotfiles directory files) file))) (map (lambda (file) - (let ((stripped (strip file))) + (let ((stripped (strip file directory))) (list stripped (local-file file (format stripped) #:recursive? #t)))) @@ -81,18 +127,25 @@ (define (import-dotfiles directory files) (define (home-dotfiles-configuration->files config) "Return a list of objects compatible with @code{home-files-service-type}'s -value, generated following GNU Stow's algorithm for each of the -directories in CONFIG, excluding files that match any of the patterns configured." +value, excluding files that match any of the patterns configured." + (define stow? (eq? (home-dotfiles-configuration-layout config) 'stow)) (define excluded (home-dotfiles-configuration-excluded config)) (define exclusion-rx (make-regexp (string-append "^.*(" (string-join excluded "|") ")$"))) - (define (directory-contents directory) - (find-files directory - (lambda (file stat) - (not (regexp-exec exclusion-rx - (basename file)))))) + (define* (directory-contents directory #:key (packages #f)) + (define (filter-files directory) + (find-files directory + (lambda (file stat) + (not (regexp-exec exclusion-rx + (basename file)))))) + (if (and stow? packages (maybe-value-set? packages)) + (append-map filter-files + (map (lambda (pkg) + (string-append directory "/" pkg)) + packages)) + (filter-files directory))) (define (resolve directory) ;; Resolve DIRECTORY relative to the 'source-directory' field of CONFIG. @@ -103,15 +156,23 @@ (define (home-dotfiles-configuration->files config) (append-map (lambda (directory) (let* ((directory (resolve directory)) - (contents (directory-contents directory))) - (import-dotfiles directory contents))) + (packages + (home-dotfiles-configuration-packages config)) + (contents + (directory-contents directory + #:packages packages)) + (strip + (if stow? strip-stow-dotfile strip-plain-dotfile))) + (import-dotfiles directory contents strip))) (home-dotfiles-configuration-directories config))) (define-public home-dotfiles-service-type (service-type (name 'home-dotfiles) (extensions (list (service-extension home-files-service-type - home-dotfiles-configuration->files))) + (lambda (config) + (when config + (home-dotfiles-configuration->files config)))))) (default-value (home-dotfiles-configuration)) (description "Files that will be put in the user's home directory following GNU Stow's algorithm, and further processed during activation."))) base-commit: f18d13b5f89c161c6ee88d15ecdaa8d973ee4503 -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 06 17:16:17 2024 Received: (at 68857-done) by debbugs.gnu.org; 6 Mar 2024 22:16:17 +0000 Received: from localhost ([127.0.0.1]:51820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhzYe-0006a5-LH for submit@debbugs.gnu.org; Wed, 06 Mar 2024 17:16:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rhzYa-0006Zh-Nm; Wed, 06 Mar 2024 17:16:13 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhzXy-00069v-HL; Wed, 06 Mar 2024 17:15:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=+2FjXT1+ejfUQ8vgq1EhQEhb3rAqMHL4+oFotBDgiZw=; b=NSVTeORf8ORoVWEowiCv MAvWgUFmqrLaxhOX+jX/xf1BjUziu462cq1TK6sw8k5gn8l6iuD7psBirWCep5cH/GN0zjgxa+btD qqXgXrZSLR3DCl2k9uHN1GO5GgTuk4D+AzsrTkL1xEZrv4nTSWWh1wgpafWBbjHclQJBTv50ThFxV w20oX82S8zUIYlwuzvWbTxA9odOOWVX5+l//XXcqBXiORitrSS3S9zy18m03T46B7mNXN11FzTI91 CuVl7EWKi+pEkURwKyL0romI1PuMj23jOQ86sXmbvBjRkzf9lLaU/7UIjpdzLSJ/QshruTCg62pmO RZpt5ne3EBFJvA==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Giacomo Leidi Subject: Re: bug#68857: gnu: home: dotfiles: Avoid creating extra directory in $HOME. In-Reply-To: (Giacomo Leidi's message of "Wed, 6 Mar 2024 21:52:42 +0100") References: <14bc720d-7fdc-516a-3018-58294c1cafcd@autistici.org> Date: Wed, 06 Mar 2024 23:15:03 +0100 Message-ID: <87v85z6m8o.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 68857-done Cc: paren@disroot.org, 68848-done@debbugs.gnu.org, Andrew Tropin , 68857-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: -3.3 (---) Hi, Giacomo Leidi skribis: > The current implementation of the home-dotfiles-service-type contradicts > the Guix manual (see https://issues.guix.gnu.org/68848 ). This patch > properly implements both the plain and Stow dotfiles directory layouts. > > It does so by refactoring home-dotfiles-configuration adding a new > packages field to support GNU Stow's users workflow and introducing > a new layout field to switch between the two directory layouts. > > * gnu/home/services/dotfiles (home-dotfiles-configuration): Migrate to > (gnu services configuration); > [packages]: new field; > [layout]: new field; > (strip-stow-dotfile): new variable; > (strip-plain-dotfile): new variable; > (home-dotfiles-configuration->files): use the new fields; > [directory-contents]: allow for > selecting a subset of application dotfile directories; > * doc/guix.texi: document the new layouts. > > Change-Id: I2e96037608353e360828290f055ec5271cfdfd48 Applied, thanks again! Ludo=E2=80=99. From unknown Sat Aug 09 05:01:00 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 04 Apr 2024 11:24:22 +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