From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 uCvcEjS9xmMhfQEAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 16:22:28 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QGrAEjS9xmNnWgEAauVa8A (envelope-from ) for ; Tue, 17 Jan 2023 16:22:28 +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 0CF3C2E9AF for ; Tue, 17 Jan 2023 16:22:28 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHnmm-0007nV-MN; Tue, 17 Jan 2023 10:22:04 -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 1pHnmk-0007bk-Cs for guix-patches@gnu.org; Tue, 17 Jan 2023 10:22:02 -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 1pHnmj-0003cz-RJ for guix-patches@gnu.org; Tue, 17 Jan 2023 10:22:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHnmj-0002t7-M1 for guix-patches@gnu.org; Tue, 17 Jan 2023 10:22:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60521] [PATCH] home: Add home-stow-migration-service. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Jan 2023 15:22:01 +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: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Giacomo Leidi Cc: 60521@debbugs.gnu.org Received: via spool by 60521-submit@debbugs.gnu.org id=B60521.167396887811052 (code B ref 60521); Tue, 17 Jan 2023 15:22:01 +0000 Received: (at 60521) by debbugs.gnu.org; 17 Jan 2023 15:21:18 +0000 Received: from localhost ([127.0.0.1]:37966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHnm2-0002s7-5t for submit@debbugs.gnu.org; Tue, 17 Jan 2023 10:21:18 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:50863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHnlz-0002rg-Iz for 60521@debbugs.gnu.org; Tue, 17 Jan 2023 10:21:17 -0500 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id D4A6C240009; Tue, 17 Jan 2023 15:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1673968869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c6+ywVxtgkuhPp9R4Omjs5CrnZL64H60upoX7gizUbE=; b=RzzwnMke+g7CINLM5AwnG7Fa1GrEFLxnlRSzAvPuz9URFt7MW8z26sPL21Ex1iemBPAKOX bKFgrEfZ7mLapxeLkyIdbb0fPLbCkgAyRYm/6zGHyrBI/quqoqgWF4qZuD9M9Obv4NU1GY JmAZ/0+GrBNx9h9s/algU5IQKVOVOMk5JjyX24aoJAyMhL2NsZMSIRsRwCil0yISJRJpiY 1u36F50FTYURV2/SJc3wRtYu7uaK9DhJECjGS+l6VZmLfJBErNmsSlQtJgi//SoQHGVtIV Eh4xk00TyGJH5qDR6NOb1kZAYVyC5uzvcGRMQVE0R7Xbb9FswQyM6VZA9GxyvQ== From: Andrew Tropin In-Reply-To: <87o7qxi9ym.fsf_-_@gnu.org> References: <0a8d7bce31856292baa06a08260494c0@autistici.org> <20230103165534.25644-1-goodoldpaul@autistici.org> <87o7qxi9ym.fsf_-_@gnu.org> Date: Tue, 17 Jan 2023 19:21:04 +0400 Message-ID: <87tu0p89wf.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: 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-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=RzzwnMke; 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=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673968948; a=rsa-sha256; cv=none; b=ZTcOs3skPgDpfnME3VLNtdi/uzYIb1P4uHd0yZP/GmSLp1ta7RpQ78c/dPsPqCL2I9pEcQ rn0uvRq1VHcIkPQFvDd1oFL8ejbcW5EozV1J024En+AE3O9raNFZpYem6FI+LWgG2i49Vz p4CNZ/RG/VrVr7Elq1XxDRoTnL4SHW9ra5UmDApBXtOiVkmO8DwsgCCZUAvYvUeIYZsEfI CaETqK8ScRNL6Y0Ql7EjM7Z1gIEWlptvuyWxzSVFtDrgHa54qDC37UXEURjIUeNXoMf2fZ 0AlYhGgSs+fajDMXersOIjmaUmM9+ZTFUPJm560L8Qtb/waGj2ojyAjWOYqI4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673968948; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=c6+ywVxtgkuhPp9R4Omjs5CrnZL64H60upoX7gizUbE=; b=iCp78cWgbymqWmDp0Zj25YmkLBPycXdxwcIfNmkARXp4ceOp/8b/4Uk9U05OVGif0uR92H cDicYWydaBTfS8JkHmEyQbLadz6CxODWnFkyWdhkqU3WTxNDvUf7HhY8LAWKdWUs/s/2Al hGmeYYAl7BqrHoGYswJd88ex4hD7YigZ336oHJYvtdtvz+EF7tU+ItRhtHpiWIMJruFbeu W7WJ/HZP4+knaS9+vxhrbNzyamyYHQl0YlTv7rmlkVfn483dPvpT1FBhz/dqGjlgkM08M7 JC3B4D70TMGJ2IO7ODejoBcuIPeB28R0kzArcLEU6KTPP94Gixnz6onWP7ol7Q== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=RzzwnMke; 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=none X-Migadu-Spam-Score: -4.33 X-Spam-Score: -4.33 X-Migadu-Queue-Id: 0CF3C2E9AF X-Migadu-Scanner: scn1.migadu.com X-TUID: 1MoIOV/sj9Wn --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2023-01-17 14:09, Ludovic Court=C3=A8s wrote: > 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 a= dvanced 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-typ= e} >> +(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 thei= r 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 direct= ory. >> +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 The service looks neat! Thank you, Giacomo. Ludo, wouldn't it be better and safer to use (local-file "./dotfiles" #:recursive? #t) here? I find it kinda dangerous for reproducibility to reference local files and make logic inside the service to depend on it. > > 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 j= ust > 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 p= ath >> +of a file and the second is a gexp representing the file content. Obje= cts are >> +generated by recursively visiting APP-DIR and mapping its contents to t= he >> +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-= path "/") >> + ""))) > > 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= =9Csearch paths=E2=80=9D; here > we=E2=80=99d instead use =E2=80=9Cfile name=E2=80=9D, but you can also ca= ll 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. > > > =2D-=20 Best regards, Andrew Tropin --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmPGvOAACgkQIgjSCVjB 3rD4BA//fWFIt2fMw42Pd/Fag7aiHJL6QDvgo0fSNRvbrf7mySUlGfbDrJBX6mn7 DvQ6GnuiNr6y/PPswA3kIUaODwxlAeB1bHX1QU3S7Kjk3GCdi/h53rLFhlO4hXxj g+PJ5pJ/ATr5+zd9XdekhT6a1aIPZYGqJHfNM7nMFQeoH+qptgvlkEUqqqdILyxi 1NJJgQUIxyuCGDqqW9RmjKN6b7kN9dIag0F8mRFcReIkBwknwTf9ohGeDcBU5i8T GUVbp/5NGDs7cErsz8Lu9uS0GQpKVbcpnoLnMrnlxAGVJU6Caexen06LR1wUDXnS WJ7MeOaeuJ3BRcODZJqMlOSf6kI68KeSmjHQIwZ80j7ui6EhtEsbjjx3bf93wxe8 arUGJo/mXLaJj7w7W2Xv8Ke+1EXY0WBr0x89ZEoQf5LZWVeCrz255+mXDsQDleFa 0REDqiXvoHGAbGfW3D7A6B157it1J4BUzeghp9irSFBZD2RYhgMExChAbvMD3ZU8 VfUe0rOi2Y1yofqS/eFNme4SiE4BxhjlNhSEuut2Ljb05fiXIYe4iwfBzCm/Ly+x qMT+/6AA5cyZGdzcZLA4CjNFduoVmG0XRrqFW8NKNb19KncQrWpwVxjszdB8Cisq B/fqVUMxg0W1kUPHiJKxgZj/nyaxiozoWL6mTpcsr0yPtPPxjZk= =Zozo -----END PGP SIGNATURE----- --=-=-=--