From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CP+oNkuexmM0jwAAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 14:10:35 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yLWvNkuexmOdoQAA9RJhRA (envelope-from ) for ; Tue, 17 Jan 2023 14:10:35 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 43A9628F8E for ; Tue, 17 Jan 2023 14:10:35 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHljF-0007zK-Rt; Tue, 17 Jan 2023 08:10:17 -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 1pHlj3-0007wF-7I for guix-patches@gnu.org; Tue, 17 Jan 2023 08:10:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHlj0-00065D-R6 for guix-patches@gnu.org; Tue, 17 Jan 2023 08:10:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHlj0-00054m-CQ for guix-patches@gnu.org; Tue, 17 Jan 2023 08:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60521] [PATCH] home: Add home-stow-migration-service. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Jan 2023 13:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60521 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Giacomo Leidi Cc: 60521@debbugs.gnu.org Received: via spool by 60521-submit@debbugs.gnu.org id=B60521.167396098919488 (code B ref 60521); Tue, 17 Jan 2023 13:10:02 +0000 Received: (at 60521) by debbugs.gnu.org; 17 Jan 2023 13:09:49 +0000 Received: from localhost ([127.0.0.1]:36090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlim-00054G-TM for submit@debbugs.gnu.org; Tue, 17 Jan 2023 08:09:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlik-00053y-Jz for 60521@debbugs.gnu.org; Tue, 17 Jan 2023 08:09:47 -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 1pHlid-00061V-TO; Tue, 17 Jan 2023 08:09:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=xJCQOpG71vR4rQqb4cciTF7It16fwjz+ekL+WlglYFM=; b=U8spHIw+djMcWYLQQ/RK VuxesR9rEeqZt+VVVh054REnc0569EcXwozC9Vns6UcXe+TaTbmyZi7qFO1C4BiyRZwlpJNGC+3sx Ag1CYPkxYe3S5rA3rI83kZx5PXsWerZB8nqblehUaUkWWcwsgjfhOZZBobY/rj7qokjKw/PoX6mNr 03gGUF95M9mzZ648avd01Bx+dXVcjcq4XhdoNvi11f3C/eFN0440aijIWrxev2/LTYOw36QQln0Xr 9bCj3XHcxPElByV8ZH7F4gy42YtiN4NOXrecyqd3LAac+hDVCt2uTOBoDQhoPR3XOZepeDIYVOklb 3OI/dBSPeAuLZg==; Received: from [193.50.110.246] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHlid-0000lD-8K; Tue, 17 Jan 2023 08:09:39 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <0a8d7bce31856292baa06a08260494c0@autistici.org> <20230103165534.25644-1-goodoldpaul@autistici.org> Date: Tue, 17 Jan 2023 14:09:37 +0100 In-Reply-To: <20230103165534.25644-1-goodoldpaul@autistici.org> (Giacomo Leidi's message of "Tue, 3 Jan 2023 17:55:34 +0100") Message-ID: <87o7qxi9ym.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673961035; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xJCQOpG71vR4rQqb4cciTF7It16fwjz+ekL+WlglYFM=; b=XzFrrfE0Xd2CXtSa3duJv4gTi55nBBlpH9BKu3u/vSIu1sBJicsAcdJVs0y8iTMgWAfYdK IFfPPl5ElGBJItZ/lfPsqKfugWMhXALRYlPdT/wBvKNxHP+SbUgVbvOD9rRZCs8VhuhvOA btY2yi4/iwDtfc0Iy/Mqstjm5w2U57pgEP/f/dv7A7vyd5ijnhNf8l+GscHCHSjGR1hI1A yhnHYU8pRZMjfx40qfUHGX7+ehTA3bsLqnM6y/vcYwhmEgb3Pd9KRz1w5wUB2rabTHp6FX jbjjHJrVlwJ2dVG58k3XCoooLb/9y3ubeHzcs58nGw7pXCp5rtU/F3GH/a7ICw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=U8spHIw+; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673961035; a=rsa-sha256; cv=none; b=H0sQqagzDXzoSFjgtmmTWqBB0IJYU7R492gmTbyILNxwbJiz7/Jiw5o6l0FtEoaWrEN27U ypRjPe0XrqzxtQt7WBt+yzRp93F+AUgS5Nkkd9qfd0DYLAOPCUJhBhq0DV/QyBWTSQ1LgK PZETj2J4xVWi7gSLsKa6LaBnw88qYygfpUTmSi+xUT6z0bW2tz128g0IQbRdFvDOSBVPBM Wp+oolrpJaxvaXbn+SqtGJGedAlbdLa8fvdvQwcJA9rg94+lpTKfNaI+AbTSAriMT8yYRa 2y7pBmfMeJ4i3D6CqbqeLWIcFsHigkmvinrz8kM5pvGUZEusNqn0nFHwRHQT1w== X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -5.43 X-Spam-Score: -5.43 X-Migadu-Queue-Id: 43A9628F8E Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=U8spHIw+; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org X-TUID: jgSD9fVMvxAq Hi! Giacomo Leidi skribis: > * gnu/home/services.scm (dotfiles-for-app): New variable; > (home-stow-migration-configuration): new variable; > (home-stow-migration-service): new variable. > * doc/guix.texi: Document it. That looks very useful! > @@ -41119,6 +41120,55 @@ to use alternative services to implement more ad= vanced use cases like > read-only home. Feel free to experiment and share your results. > @end defvr >=20=20 > +@deffn {Scheme Procedure} home-stow-migration-service Perhaps write a short intro (one or two sentences) above? > +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 GNU Stow users. This service allows users to point Guix Home to > +their Stow directory and have their file automatically deployed to their= home > +directory just like Stow would, without migrating all of their dotfiles = to Guix > +native configurations. > + > +A typical Stow setup consists of a source directory and a target directo= ry. > +The source directory must be structured as follows: > + > +@example > +~$ tree -a .dotfiles/ > +.dotfiles/ > +=E2=94=9C=E2=94=80=E2=94=80 git > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .gitconfig > +=E2=94=9C=E2=94=80=E2=94=80 gpg > +=E2=94=82 =E2=94=94=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=82 =E2=94=94=E2=94=80=E2=94=80 .guile > +=E2=94=9C=E2=94=80=E2=94=80 guix > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .config > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 guix > +=E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 channels.scm > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .gitignore > +=E2=94=9C=E2=94=80=E2=94=80 nix > +=E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 .config > +=E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 nixpkgs > +=E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 config.nix > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .nix-channels > +=E2=94=9C=E2=94=80=E2=94=80 tmux > +=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .tmux.conf > +=E2=94=94=E2=94=80=E2=94=80 vim > + =E2=94=94=E2=94=80=E2=94=80 .vimrc > + > +13 directories, 10 files > +@end example > + > +A suitable configuration would then be: > + > +@lisp > + (home-stow-migration-service > + (string-append (getenv "HOME") > + "/.dotfiles")) > +@end lisp Maybe add a description of what it=E2=80=99s going to do with those files? = It=E2=80=99s kinda implicit but better be clear. Also, I feel like there=E2=80=99s nothing really Stow-specific here; it just happens to be a file layout convention that=E2=80=99s used by Stow, right? = So I wonder if could frame it differently, by describing the expected file tree structure first, and mentioning Stow only then? Last, I suggest adding a cross-reference to the Stow manual, as in: @pxref{Top,,, stow, GNU Stow Manual} > +(define (dotfiles-for-app app-dir) > + "Return a list of objects compatible with @{home-files-service-type}'s ^ Typo, should be @code. > +value. Each object is a pair where the first element is the relative pa= th > +of a file and the second is a gexp representing the file content. Objec= ts are > +generated by recursively visiting APP-DIR and mapping its contents to the > +user's home directory." > + (let ((app-absolute-path (canonicalize-path app-dir))) > + (map (lambda (path) > + (let ((app-file-relative-path > + (string-replace-substring path > + (string-append app-absolute-p= ath "/") > + ""))) Or just (string-drop path (string-length app-absolute-path)). > + (list app-file-relative-path > + (local-file path > + (string-append "home-stow-migration-" > + (string-replace-substring > + app-file-relative-path > + "/" "-")))))) > + (find-files app-absolute-path)))) Nitpick: by convention, the term =E2=80=9Cpath=E2=80=9D refers to =E2=80=9C= search paths=E2=80=9D; here we=E2=80=99d instead use =E2=80=9Cfile name=E2=80=9D, but you can also call= the variable just =E2=80=98file=E2=80=99. The other convention is to avoid abbreviations in identifiers, and to avoid long identifiers for local variables. So s/app-dir/directory/ etc. > +(define (home-stow-migration-configuration stow-dir) > + "Return a list of objects compatible with @{home-files-service-type}'s > +value, generated following GNU Stow's algorithm using STOW-DIR as input > +directory." > + (define (dir-contents dir) > + (scandir dir > + (lambda (name) > + (not (member name '("." "..")))))) > + (fold append > + '() > + (map (lambda (app-dir) > + (dotfiles-for-app > + (string-append stow-dir "/" app-dir))) > + (dir-contents stow-dir)))) You can replace (fold append =E2=80=A6) with (append-map =E2=80=A6). > +(define-public (home-stow-migration-service stow-dir) You can drop this procedure. Users are expected to write: (service home-stow-migration-service) Could you send an updated patch? Thanks! Ludo=E2=80=99.