~abcdw/rde-devel

feature-laminar v1 NEEDS REVISION

These patches add a home feature-laminar, which can help with
continuous integration of projects.

The laminar service in Guix uses a special system account, which doesn't
have access to user projects repositories, which makes it very difficult
to actually use on a project. Instead, this version integrates quite
well with local project development: you can have your laminar jobs
versionned in projects and simply link the job in
$LAMINAR_HOME/cfg/jobs properly.

Nicolas Graves (2):
  rde: Add a laminar home service.
  rde: Add feature-laminar.

 src/contrib/features/ci.scm  | 52 +++++++++++++++++++++
 src/gnu/home-services/ci.scm | 89 ++++++++++++++++++++++++++++++++++++
 2 files changed, 141 insertions(+)
 create mode 100644 src/contrib/features/ci.scm
 create mode 100644 src/gnu/home-services/ci.scm

-- 
2.41.0
I'm a bit slow on response for this one :)

A couple notes on this one: (gnu home-services) is deperecated, re-using
system's configuration record can be confusing.  Other than that looks
good for me.

Marking as NEED_REVISION.
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/44696/mbox | git am -3
Learn more about email & git

[PATCH 1/2] rde: Add a laminar home service. Export this patch

---
 src/gnu/home-services/ci.scm | 89 ++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 src/gnu/home-services/ci.scm

diff --git a/src/gnu/home-services/ci.scm b/src/gnu/home-services/ci.scm
new file mode 100644
index 00000000..9e2ebcd7
--- /dev/null
+++ b/src/gnu/home-services/ci.scm
@@ -0,0 +1,89 @@
;;; rde --- Reproducible development environment.
;;;
;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; This file is part of rde.
;;;
;;; rde is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; rde is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with rde.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu home-services ci)
  #:use-module (guix gexp)
  #:use-module (guix records)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages ci)
  #:use-module (gnu home services)
  #:use-module (gnu services ci)
  #:use-module (gnu home services shepherd)
  #:use-module (ice-9 match)
  #:export (home-laminar-service-type))

;;;; Commentary:
;;;
;;; This module implements a service that to run instances of Laminar, a
;;; continuous integration tool.
;;;
;;; The version in Guix uses a special system account laminar, which doesn't
;;; have access to user projects repositories, which makes it very difficult
;;; to use. Instead, this version integrates quite well with local project
;;; development: you can have your laminar jobs versionned in projects and
;;; simply link the job in $LAMINAR_HOME/cfg/jobs properly.
;;;
;;;; Code:

(define laminar-shepherd-service
  (match-lambda
    (($ (@@ (gnu services ci) <laminar-configuration>)
        laminar home-directory
        bind-http bind-rpc
        title keep-rundirs archive-url
        base-url)
     (list (shepherd-service
            (documentation "Run Laminar.")
            (provision '(laminar))
            ;; (requirement '(networking))  ; considered provided by the system
            (start #~(make-forkexec-constructor
                      (list #$(file-append laminar "/sbin/laminard"))
                      #:environment-variables
                      `(,(string-append "LAMINAR_HOME="
                                        #$home-directory)
                        ,(string-append "LAMINAR_BIND_HTTP="
                                        #$bind-http)
                        ,(string-append "LAMINAR_BIND_RPC="
                                        #$bind-rpc)
                        ,(string-append "LAMINAR_TITLE="
                                        #$title)
                        ,(string-append "LAMINAR_KEEP_RUNDIRS="
                                        #$(number->string
                                           keep-rundirs))
                        ,@(if #$archive-url
                              (list
                               (string-append "LAMINAR_ARCHIVE_URL="
                                              #$archive-url))
                              '())
                        ,@(if #$base-url
                              (list
                               (string-append "LAMINAR_BASE_URL="
                                              #$base-url))
                              '()))))
            (stop #~(make-kill-destructor)))))))

(define home-laminar-service-type
  (service-type
   (name 'home-laminar)
   (extensions
    (list
     (service-extension home-shepherd-service-type laminar-shepherd-service)))
   (default-value (laminar-configuration))
   (description
    "Run the Laminar continuous integration service.")))
-- 
2.41.0

[PATCH v2 1/2] rde: Add a laminar home service. Export this patch

---
 src/gnu/home-services/ci.scm | 90 ++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)
 create mode 100644 src/gnu/home-services/ci.scm

diff --git a/src/gnu/home-services/ci.scm b/src/gnu/home-services/ci.scm
new file mode 100644
index 00000000..3d8c86f2
--- /dev/null
+++ b/src/gnu/home-services/ci.scm
@@ -0,0 +1,90 @@
;;; rde --- Reproducible development environment.
;;;
;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; This file is part of rde.
;;;
;;; rde is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; rde is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with rde.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu home-services ci)
  #:use-module (guix gexp)
  #:use-module (guix records)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages ci)
  #:use-module (gnu home services)
  #:use-module (gnu services ci)
  #:use-module (gnu home services shepherd)
  #:use-module (ice-9 match)
  #:export (home-laminar-service-type)
  #:re-export (laminar-configuration))

;;;; Commentary:
;;;
;;; This module implements a service that to run instances of Laminar, a
;;; continuous integration tool.
;;;
;;; The version in Guix uses a special system account laminar, which doesn't
;;; have access to user projects repositories, which makes it very difficult
;;; to use. Instead, this version integrates quite well with local project
;;; development: you can have your laminar jobs versionned in projects and
;;; simply link the job in $LAMINAR_HOME/cfg/jobs properly.
;;;
;;;; Code:

(define laminar-shepherd-service
  (match-lambda
    (($ (@@ (gnu services ci) <laminar-configuration>)
        laminar home-directory
        bind-http bind-rpc
        title keep-rundirs archive-url
        base-url)
     (list (shepherd-service
            (documentation "Run Laminar.")
            (provision '(laminar))
            ;; (requirement '(networking))  ; considered provided by the system
            (start #~(make-forkexec-constructor
                      (list #$(file-append laminar "/sbin/laminard"))
                      #:environment-variables
                      `(,(string-append "LAMINAR_HOME="
                                        #$home-directory)
                        ,(string-append "LAMINAR_BIND_HTTP="
                                        #$bind-http)
                        ,(string-append "LAMINAR_BIND_RPC="
                                        #$bind-rpc)
                        ,(string-append "LAMINAR_TITLE="
                                        #$title)
                        ,(string-append "LAMINAR_KEEP_RUNDIRS="
                                        #$(number->string
                                           keep-rundirs))
                        ,@(if #$archive-url
                              (list
                               (string-append "LAMINAR_ARCHIVE_URL="
                                              #$archive-url))
                              '())
                        ,@(if #$base-url
                              (list
                               (string-append "LAMINAR_BASE_URL="
                                              #$base-url))
                              '()))))
            (stop #~(make-kill-destructor)))))))

(define home-laminar-service-type
  (service-type
   (name 'home-laminar)
   (extensions
    (list
     (service-extension home-shepherd-service-type laminar-shepherd-service)))
   (default-value (laminar-configuration))
   (description
    "Run the Laminar continuous integration service.")))
-- 
2.41.0
I'm a bit slow on response for this one :)

A couple notes on this one: (gnu home-services) is deperecated, re-using
system's configuration record can be confusing.  Other than that looks
good for me.

Marking as NEED_REVISION.

[PATCH 2/2] rde: Add feature-laminar. Export this patch

---
 src/contrib/features/ci.scm | 52 +++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 src/contrib/features/ci.scm

diff --git a/src/contrib/features/ci.scm b/src/contrib/features/ci.scm
new file mode 100644
index 00000000..4a51e5c5
--- /dev/null
+++ b/src/contrib/features/ci.scm
@@ -0,0 +1,52 @@
;;; rde --- Reproducible development environment.
;;;
;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; This file is part of rde.
;;;
;;; rde is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; rde is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with rde.  If not, see <http://www.gnu.org/licenses/>.

(define-module (contrib features ci)
  #:use-module (rde features)
  #:use-module (gnu packages golang)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu home services)
  #:use-module (gnu home-services ci)
  #:use-module (guix gexp)

  #:export (feature-laminar))

(define* (feature-laminar
          #:key
          (laminar laminar))
  "This feature sets up laminar for local continuous integration. Compared to
the version in Guix, this feature has access to the directories of the current
user, making laminar usable locally. For instance, it can be used to build
guix locally with a post-merge hook. It is in contrib, because most of what
can be done with laminar can be done with simple git hooks or scripts, the
value added being user experience."
  (ensure-pred file-like? laminar)

  (define (get-home-services config)
    (list
     (simple-service
      'laminar-add-laminar-package
      home-profile-service-type
      (list laminar))))

  (feature
   (name 'laminar)
   (values `((laminar . #t)))
   (home-services-getter get-home-services)))
-- 
2.41.0

[PATCH v2 2/2] rde: Add feature-laminar. Export this patch

---
 src/contrib/features/ci.scm | 71 +++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 src/contrib/features/ci.scm

diff --git a/src/contrib/features/ci.scm b/src/contrib/features/ci.scm
new file mode 100644
index 00000000..e5f4a85a
--- /dev/null
+++ b/src/contrib/features/ci.scm
@@ -0,0 +1,71 @@
;;; rde --- Reproducible development environment.
;;;
;;; Copyright © 2023 Nicolas Graves <ngraves@ngraves.fr>
;;;
;;; This file is part of rde.
;;;
;;; rde is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; rde is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with rde.  If not, see <http://www.gnu.org/licenses/>.

(define-module (contrib features ci)
  #:use-module (rde features)
  #:use-module (rde features predicates)
  #:use-module (gnu packages ci)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (gnu home services xdg)
  #:use-module (gnu home services)
  #:use-module (gnu home-services ci)
  #:use-module (guix gexp)

  #:export (feature-laminar))

(define* (feature-laminar
          #:key
          (laminar laminar)
          (home-directory #f))
  "This feature sets up laminar for local continuous integration. Compared to
the version in Guix, this feature has access to the directories of the current
user, making laminar usable locally. For instance, it can be used to build
guix locally with a post-merge hook. It is in contrib, because most of what
can be done with laminar can be done with simple git hooks or scripts, the
value added being user experience."
  (ensure-pred file-like? laminar)
  (ensure-pred maybe-string? home-directory)

  (define (get-home-services config)
    (when (not home-directory)
      (require-value 'home-directory config)
      (require-value 'xdg-base-directories-configuration config))
    (list
     (service home-laminar-service-type
              (laminar-configuration
               (home-directory
                (if home-directory
                    home-directory
                    (string-append
                     (get-value 'home-directory config)
                     (string-drop
                      (home-xdg-base-directories-configuration-state-home
                       (get-value 'xdg-base-directories-configuration config))
                      (string-length "$HOME"))
                     "/laminar")))))
     (simple-service
      'laminar-add-laminar-package
      home-profile-service-type
      (list laminar))))

  (feature
   (name 'laminar)
   (values `((laminar . #t)))
   (home-services-getter get-home-services)))
-- 
2.41.0