~abcdw/rde-devel

gnu: home-services: state: Add support for Hg repos. v1 APPLIED

Xinglu Chen: 1
 gnu: home-services: state: Add support for Hg repos.

 2 files changed, 24 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~abcdw/rde-devel/patches/23471/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] gnu: home-services: state: Add support for Hg repos. Export this patch

* gnu/home-services/state.scm (state-hg): New procedure.
* gnu/home-services/version-control.scm: Export ‘serialize-hg-config’.
---
The state services probably need a refactor, I think you mentioned that
specific state services should be put into other modules, e.g. (gnu
home-services version-control) for ‘state-git’ and ‘state-hg’.
 gnu/home-services/state.scm           | 23 +++++++++++++++++++++++
 gnu/home-services/version-control.scm |  1 +
 2 files changed, 24 insertions(+)

diff --git a/gnu/home-services/state.scm b/gnu/home-services/state.scm
index 1c3b901..6c1a762 100644
--- a/gnu/home-services/state.scm
+++ b/gnu/home-services/state.scm
@@ -17,9 +17,32 @@
  #:export (home-state-service-type
	    state-generic
	    state-git
            state-hg
	    state-rsync))

(use-modules (gnu packages version-control))
(define* (state-hg path remote #:key (config #f))
  (state-generic
   path
   #:init-gexp
   #~(lambda* (_ self)
       (let* ((meta (car (action self 'metadata)))
              (path (assoc-ref meta 'path))
              (remote (assoc-ref meta 'remote)))
         (format #t "Initializing ~a.\n" self)
         (let* ((port ((@@ (guix build utils) open-pipe-with-stderr)
                       #$(file-append mercurial "/bin/hg") "clone" remote path)))
           (waitpid WAIT_ANY)
           (display ((@@ (ice-9 rdelim) read-delimited) "" port))
           (close-port port))

         (when '#$config
           (call-with-output-file (string-append path "/.hg/hgrc")
             (lambda (port) (display (string-append
                                      #$@(serialize-hg-config config)) port))))))
   #:additional-metadata `((remote . ,remote)
                           (general-sync? . #f))))

(define* (state-git path remote #:key (config #f))
  (state-generic
   path
diff --git a/gnu/home-services/version-control.scm b/gnu/home-services/version-control.scm
index 2c2aa7a..335afd1 100644
--- a/gnu/home-services/version-control.scm
+++ b/gnu/home-services/version-control.scm
@@ -21,6 +21,7 @@

            home-hg-configuration
            home-hg-extension
            serialize-hg-config
            home-hg-service-type))

;;; Commentary:

base-commit: 262c7fb2db7454fdf4f67bbc53ec0c0306a8fbaf
-- 
2.32.0
Xinglu Chen <public@yoctocell.xyz> writes: