unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Tropin <andrew@trop.in>
To: "Ludovic Courtès" <ludo@gnu.org>,
	"Giacomo Leidi" <goodoldpaul@autistici.org>
Cc: 60521@debbugs.gnu.org
Subject: [bug#60521] [PATCH] home: Add home-stow-migration-service.
Date: Tue, 17 Jan 2023 19:21:04 +0400	[thread overview]
Message-ID: <87tu0p89wf.fsf@trop.in> (raw)
In-Reply-To: <87o7qxi9ym.fsf_-_@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5572 bytes --]

On 2023-01-17 14:09, Ludovic Courtès wrote:

> Hi!
>
> Giacomo Leidi <goodoldpaul@autistici.org> 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 advanced use cases like
>>  read-only home.  Feel free to experiment and share your results.
>>  @end defvr
>>  
>> +@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 directory.
>> +The source directory must be structured as follows:
>> +
>> +@example
>> +~$ tree -a .dotfiles/
>> +.dotfiles/
>> +├── git
>> +│   └── .gitconfig
>> +├── gpg
>> +│   └── .gnupg
>> +│       ├── gpg-agent.conf
>> +│       └── gpg.conf
>> +├── guile
>> +│   └── .guile
>> +├── guix
>> +│   └── .config
>> +│       └── guix
>> +│           ├── channels.scm
>> +│           └── .gitignore
>> +├── nix
>> +│   ├── .config
>> +│   │   └── nixpkgs
>> +│   │       └── config.nix
>> +│   └── .nix-channels
>> +├── tmux
>> +│   └── .tmux.conf
>> +└── vim
>> +    └── .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’s going to do with those files?  It’s
> kinda implicit but better be clear.
>
> Also, I feel like there’s nothing really Stow-specific here; it just
> happens to be a file layout convention that’s 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 path
>> +of a file and the second is a gexp representing the file content.  Objects 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-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 “path” refers to “search paths”; here
> we’d instead use “file name”, but you can also call the variable just
> ‘file’.
>
> 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 …) with (append-map …).
>
>> +(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’.
>
>
>

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2023-01-17 15:22 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 16:51 [bug#60521] [PATCH] home: Add home-stow-migration-service goodoldpaul--- via Guix-patches via
2023-01-03 16:55 ` Giacomo Leidi via Guix-patches via
2023-01-17 13:09   ` Ludovic Courtès
2023-01-17 15:21     ` Andrew Tropin [this message]
2023-01-23 10:23       ` Ludovic Courtès
2023-01-25  6:32         ` Andrew Tropin
2023-01-17 17:09   ` Bruno Victal
2023-02-12 17:36 ` goodoldpaul--- via Guix-patches via
2023-04-12 20:31   ` goodoldpaul--- via Guix-patches via
2023-02-12 17:36 ` [bug#60521] [v2] home: Add home-dotfiles-service Giacomo Leidi via Guix-patches via
2023-04-12 20:32 ` [bug#60521] [v3] " Giacomo Leidi via Guix-patches via
2023-04-24 20:33   ` [bug#60521] [PATCH] home: Add home-stow-migration-service Ludovic Courtès
2023-06-24 15:47 ` paul via Guix-patches via
2023-08-26  9:34   ` goodoldpaul--- via Guix-patches via
2023-09-22 12:59     ` paul via Guix-patches via
2023-06-24 16:01 ` [bug#60521] [PATCH-v4] home: Add home-dotfiles-service Giacomo Leidi via Guix-patches via
2023-08-26  9:39 ` Giacomo Leidi via Guix-patches via
2023-09-22 13:01 ` [bug#60521] [PATCH] " Giacomo Leidi via Guix-patches via
2023-10-02  2:19 ` [bug#60521] Nicolas Odermatt-Lemay
2023-10-06 21:17 ` [bug#60521] [PATCH] home: Add home-dotfiles-service paul via Guix-patches via
2023-10-06 21:22 ` Giacomo Leidi via Guix-patches via
2023-10-29 12:58 ` [bug#60521] [60521] Add home-dotfiles-service-type - Rebased on master paul via Guix-patches via
2024-01-21 17:06   ` paul via Guix-patches via
2024-01-22  0:16     ` [bug#60521] " tumashu
2024-01-22  8:12       ` Giacomo via Guix-patches via
2024-01-22 12:36     ` [bug#60521] " Feng Shu
2024-01-22 16:45       ` paul via Guix-patches via
2024-01-23 12:14         ` Feng Shu
2024-01-24 11:58     ` Feng Shu
2024-01-26 17:47       ` paul via Guix-patches via
2024-01-27  2:54         ` Feng Shu
2024-01-21 17:07   ` paul via Guix-patches via
2023-10-29 12:59 ` [bug#60521] [PATCH v4] home: Add home-dotfiles-service Giacomo Leidi via Guix-patches via
2023-11-06  0:55 ` [bug#60521] [PATCH] home: Add home-stow-migration-service Feng Shu
2023-11-07  8:58 ` Feng Shu
2023-11-09  0:59 ` Feng Shu
2024-01-21 17:08 ` [bug#60521] [PATCH v5] home: Add home-dotfiles-service Giacomo Leidi via Guix-patches via
2024-01-26 17:48 ` [bug#60521] [PATCH v6] " Giacomo Leidi via Guix-patches via
2024-01-27 22:56   ` Ludovic Courtès
2024-01-28 15:36     ` paul via Guix-patches via
2024-01-27 20:21 ` [bug#60521] [PATCH] home: Add home-stow-migration-service Sergey Trofimov
2024-01-27 20:21 ` Sergey Trofimov
2024-01-29 13:20   ` Ludovic Courtès
2024-01-29 13:40     ` Sergey Trofimov
2024-01-29 14:23       ` Giacomo via Guix-patches via
2024-01-29 15:19         ` Sergey Trofimov
2024-01-29 16:09           ` Giacomo via Guix-patches via
2024-01-29 18:34             ` Sergey Trofimov
2024-02-07 22:17         ` [bug#60521] Dot file layout for ‘home-dotfiles-service’ Ludovic Courtès
2024-02-09  0:44           ` paul via Guix-patches via
2024-02-09  0:45             ` paul via Guix-patches via
2024-02-10 10:03             ` Ludovic Courtès
2024-02-10 10:47               ` Janneke Nieuwenhuizen
2024-01-29 16:10       ` [bug#60521] [PATCH] home: Add home-stow-migration-service Ludovic Courtès
2024-01-28 15:37 ` [bug#60521] [PATCH v7] home: Add home-dotfiles-service Giacomo Leidi via Guix-patches via
2024-01-28 21:02   ` bug#60521: " Ludovic Courtès
2024-01-28 21:14     ` [bug#60521] " paul via Guix-patches via
2024-01-28 21:22       ` paul via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tu0p89wf.fsf@trop.in \
    --to=andrew@trop.in \
    --cc=60521@debbugs.gnu.org \
    --cc=goodoldpaul@autistici.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).