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 OEeXG37WxmOg+gAAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 18:10:22 +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 IFKBG37WxmP5RQAA9RJhRA (envelope-from ) for ; Tue, 17 Jan 2023 18:10:22 +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 C4148A902 for ; Tue, 17 Jan 2023 18:10:21 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHpTL-0000OQ-RC; Tue, 17 Jan 2023 12:10:07 -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 1pHpTH-0000Ng-N2 for guix-patches@gnu.org; Tue, 17 Jan 2023 12:10:03 -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 1pHpTG-0004SO-UE for guix-patches@gnu.org; Tue, 17 Jan 2023 12:10:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHpTG-0001tP-CC for guix-patches@gnu.org; Tue, 17 Jan 2023 12:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60521] [PATCH] home: Add home-stow-migration-service. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Jan 2023 17: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.16739753917253 (code B ref 60521); Tue, 17 Jan 2023 17:10:02 +0000 Received: (at 60521) by debbugs.gnu.org; 17 Jan 2023 17:09:51 +0000 Received: from localhost ([127.0.0.1]:38102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHpT2-0001so-04 for submit@debbugs.gnu.org; Tue, 17 Jan 2023 12:09:51 -0500 Received: from smtpm5.myservices.hosting ([185.26.105.236]:43322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHpSx-0001sc-I3 for 60521@debbugs.gnu.org; Tue, 17 Jan 2023 12:09:47 -0500 Received: from mail1.netim.hosting (unknown [185.26.106.172]) by smtpm5.myservices.hosting (Postfix) with ESMTP id D09B620CB0; Tue, 17 Jan 2023 18:09:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 7DBE780096; Tue, 17 Jan 2023 18:09:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-1.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QAXOCNCFw8bL; Tue, 17 Jan 2023 18:09:35 +0100 (CET) Received: from [192.168.1.239] (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id 2913180093; Tue, 17 Jan 2023 18:09:34 +0100 (CET) Message-ID: Date: Tue, 17 Jan 2023 17:09:34 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US References: <0a8d7bce31856292baa06a08260494c0@autistici.org> <20230103165534.25644-1-goodoldpaul@autistici.org> From: Bruno Victal In-Reply-To: <20230103165534.25644-1-goodoldpaul@autistici.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=none; 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=1673975422; a=rsa-sha256; cv=none; b=FAL3QoSuD7thQqJNXpGLFjbB7ZCeLUYGHtdnbo70Oc/I0y3ljccwGD29LUAzgjK/6eidb9 gPuJlk2JZlaqLvOSXUn3NHK3B19rtNRmRVr932mU4oEDpkOzTZVkNhYK5vpPHBLCnasfk6 cmL1GLIOmxu5GTklNDbBA1sz9evPVYwxHMCmFjZT6p2sjYQJ9+W/lejCaqT3JzHNcK67aD 50OEAOvdHDKjGyz6KaqevhpPfIVZSl1LlokBWRYBYcQWeuLmw5QiX/Qcw/rliN5XcWh4ii aODaKFPrt9OwfUmjhtO/jodyIqIvZiSGg6zcrs1Mf4kt+kiZ++EwKgyeyfwMtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673975422; 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; bh=eax25bFxvf+2vpNtLGbc4R8yJHztosqRAJK+ntEODJc=; b=YstYsN93aSucLkIOVhyqIcgg3o2LXHujs89yrBcKHg4QONH5Oh3QhlO8BFECjaA+C6fUHt lu7Y/Gk5ljJ07M661YuQtOIncNoSIlya1wObyeNcK7LEEutgdzh0C2Zs6NiobEys3n8R+F HT9wEHsAsXNz8ve5bpEKTn9cquSFrGVHkFiE/SqAkPIawVsbg/t/3qxMAW9uVumXyKKgA4 pZPv3vvruazQ5sINn3+O0PG9Ffj/IUNTNylujPyl88Wbw4rKbPtQjE5v2HIZlyeeEXdlz+ 3I7u+PiOveJyc7PlleXSq/Wfm4MfUHbe1ERi06cFiVAd8Xb8dbTyQwaI5ge/kQ== Authentication-Results: aspmx1.migadu.com; dkim=none; 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: -3.13 X-Spam-Score: -3.13 X-Migadu-Queue-Id: C4148A902 X-Migadu-Scanner: scn1.migadu.com X-TUID: BIf58hA5grR7 On 2023-01-03 16:55, Giacomo Leidi via Guix-patches via wrote: > * 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. > --- > doc/guix.texi | 50 +++++++++++++++++++++++++++++++++++++++++++ > gnu/home/services.scm | 49 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 99 insertions(+) > > diff --git a/doc/guix.texi b/doc/guix.texi > index 5c85680831..40c36f65c4 100644 > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -109,6 +109,7 @@ Copyright @copyright{} 2022 Reily Siegel@* > Copyright @copyright{} 2022 Simon Streit@* > Copyright @copyright{} 2022 (@* > Copyright @copyright{} 2022 John Kehayias@* > +Copyright @copyright{} 2023 Giacomo Leidi@* > > Permission is granted to copy, distribute and/or modify this document > under the terms of the GNU Free Documentation License, Version 1.3 or > @@ -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 > +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 Procedures in Guix are almost always Scheme functions, perhaps you could write this as: @defun home-stow-migration-service > +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 > +@end deffn > + > @defvr {Scheme Variable} home-xdg-configuration-files-service-type > The service is very similiar to @code{home-files-service-type} (and > actually extends it), but used for defining files, which will go to In a similar vein, this could be written as: @defvar home-xdg-configuration-files-service-type > diff --git a/gnu/home/services.scm b/gnu/home/services.scm > index 99035686f1..996647c592 100644 > --- a/gnu/home/services.scm > +++ b/gnu/home/services.scm > @@ -1,6 +1,7 @@ > ;;; GNU Guix --- Functional package management for GNU > ;;; Copyright © 2021 Andrew Tropin > ;;; Copyright © 2021 Xinglu Chen > +;;; Copyright © 2023 Giacomo Leidi > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -21,6 +22,7 @@ (define-module (gnu home services) > #:use-module (gnu services) > #:use-module ((gnu packages package-management) #:select (guix)) > #:use-module ((gnu packages base) #:select (coreutils)) > + #:use-module (guix build utils) > #:use-module (guix channels) > #:use-module (guix monads) > #:use-module (guix store) > @@ -33,13 +35,16 @@ (define-module (gnu home services) > #:use-module (guix i18n) > #:use-module (guix modules) > #:use-module (srfi srfi-1) > + #:use-module (ice-9 ftw) > #:use-module (ice-9 match) > + #:use-module (ice-9 string-fun) > #:use-module (ice-9 vlist) > > #:export (home-service-type > home-profile-service-type > home-environment-variables-service-type > home-files-service-type > + home-stow-migration-service > home-xdg-configuration-files-service-type > home-xdg-data-files-service-type > home-run-on-first-login-service-type > @@ -49,6 +54,7 @@ (define-module (gnu home services) > > environment-variable-shell-definitions > home-files-directory > + home-stow-migration-configuration > xdg-configuration-files-directory > xdg-data-files-directory > > @@ -315,6 +321,49 @@ (define home-files-service-type > (description "Files that will be put in > @file{~~/.guix-home/files}, and further processed during activation."))) > > +(define (dotfiles-for-app app-dir) > + "Return a list of objects compatible with @{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 APP-DIR and mapping its contents to the Instead of `APP-DIR', you can use the @var command: @var{app-dir} > +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 "/") > + ""))) > + (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)))) > + > +(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." Same as above. > + (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)))) > + > +(define-public (home-stow-migration-service stow-dir) > + "Return a service extending @{home-files-service-type} with files from > +STOW-DIR. Files will be put in the user's home directory following GNU Same as above. > +Stow's algorithm, and further processed during activation." > + (simple-service 'home-stow-migration-service > + home-files-service-type > + (home-stow-migration-configuration stow-dir))) > + > (define xdg-configuration-files-directory ".config") > > (define (xdg-configuration-files files) > > base-commit: 473692b812b4ab4267d9bddad0fb27787d2112ff Cheers, Bruno