guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: hydra: Add Guix CRAN repository updater.


From: Ricardo Wurmus
Subject: branch master updated: hydra: Add Guix CRAN repository updater.
Date: Thu, 01 Jun 2023 17:00:03 -0400

This is an automated email from the git hooks/post-receive script.

rekado pushed a commit to branch master
in repository maintenance.

The following commit(s) were added to refs/heads/master by this push:
     new 4be0947  hydra: Add Guix CRAN repository updater.
4be0947 is described below

commit 4be0947783d230eca8b4d1ca336a7227b6ed7102
Author: Lars-Dominik Braun <ldb@leibniz-psychology.org>
AuthorDate: Wed May 10 11:45:48 2023 +0200

    hydra: Add Guix CRAN repository updater.
    
    * hydra/modules/sysadmin/packages.scm (guix-cran-scripts): New variable.
    * hydra/modules/sysadmin/services.scm (guix-cran-job, %guix-cran-accounts,
    guix-cran-service-type): New variables.
    * hydra/berlin.scm <services>: Add guix-cran-service-type.
---
 hydra/berlin.scm                    |   3 +
 hydra/modules/sysadmin/packages.scm | 114 +++++++++++++++++++++++++++++++++---
 hydra/modules/sysadmin/services.scm |  31 ++++++++++
 3 files changed, 140 insertions(+), 8 deletions(-)

diff --git a/hydra/berlin.scm b/hydra/berlin.scm
index 0c5afaa..6d86c7d 100644
--- a/hydra/berlin.scm
+++ b/hydra/berlin.scm
@@ -601,6 +601,9 @@ An incremental send is attempted if a PARENT snapshot is 
provided."
              ;; For the Mumi mailer queue
              (service redis-service-type)
 
+             ;; Guix CRAN updater
+             (service guix-cran-service-type)
+
              ;; Stop Cuirass when disk space is low.
              (service disk-space-watchdog-service-type
                       (list (* 500 GiB) (* 50 GiB)))
diff --git a/hydra/modules/sysadmin/packages.scm 
b/hydra/modules/sysadmin/packages.scm
index b1b6b26..862c34e 100644
--- a/hydra/modules/sysadmin/packages.scm
+++ b/hydra/modules/sysadmin/packages.scm
@@ -16,18 +16,25 @@
 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (sysadmin packages)
-  #:use-module (guix packages)
-  #:use-module (guix git-download)
-  #:use-module (guix build-system gnu)
-  #:use-module ((guix licenses) #:prefix license:)
-  #:use-module (gnu packages web)
-  #:use-module (gnu packages ssh)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages guile-xyz)
-  #:use-module (gnu packages autotools)
+  #:use-module (gnu packages package-management)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages ssh)
   #:use-module (gnu packages version-control)
-  #:use-module (gnu packages package-management))
+  #:use-module (gnu packages web)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix packages)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26))
 
 (define-public qa-frontpage
   (let ((commit "4c77d2917ed9b5da6d8fde208fbc2ee841e3b906")
@@ -99,3 +106,94 @@ that means assisting with testing patches, but in the 
intended scope
 is any and all quality assurance tasks.")
       (home-page "https://git.cbaines.net/guix/qa-frontpage";)
       (license license:agpl3+))))
+
+(define-public guix-cran-scripts
+  (let ((commit "13bb8217a7b1b781752c886082d4d66ed97b4378")
+        (revision "2"))
+  (package
+    (name "guix-cran-scripts")
+    (version (git-version "0" revision commit))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/guix-science/guix-cran-scripts.git";)
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0vm54dyp8nm4plc0ny0kw0hd7csj5llz76wyjgcbikv3z22acmz7"))))
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let* ((output (assoc-ref %outputs "out"))
+                 (bin (string-append output "/bin"))
+                 (source (assoc-ref %build-inputs "source"))
+                 (import-scm (string-append bin "/import.scm"))
+                 (update-sh (string-append bin "/update.sh"))
+                 (shell #$(file-append bash-minimal "/bin/bash")))
+            (mkdir-p bin)
+            (copy-file (string-append source "/import.scm") import-scm)
+            ;; No interpreter, cannot use wrap-script.
+            ;; Don't wrap, because it has to be called with `guix repl`
+            #;
+            (wrap-program import-scm
+              #:sh shell
+              `("PATH" ":" prefix (,#$(file-append git "/bin"))))
+            (call-with-output-file update-sh
+              (lambda (port)
+                (display (string-append "#!" shell "\n"
+                                        "# Guix CRAN update script.
+
+# Bail out on errors, so we don't have to && everything.
+set -e
+
+# Git should not ask anything.
+export GIT_TERMINAL_PROMPT=0
+# `guix import cran` needs a proper locale, otherwise it'll fail.
+export LANG=C.utf8
+
+# Init, if we run the first time.
+test ! -d output && \
+  git clone git@github.com:guix-science/guix-cran.git output
+
+pushd output
+# Update, in case any manual changes happened.
+git pull
+popd
+
+# Make sure we only use default Guix channels, no matter how the system
+# is configured.
+cat <<EOF > channels.scm
+%default-channels
+EOF
+guix pull -C channels.scm -p profile
+
+export GUIX_PROFILE=`pwd`/profile
+source $GUIX_PROFILE/etc/profile
+
+mkdir -p cache/{description,contents}
+rm -f cache/description/*
+guix repl " import-scm " output guix-cran
+
+pushd output
+git push origin --all
+popd
+
+rm -f profile profile-*-link channels.scm
+
+exit 0
+") port)))
+            (chmod update-sh #o555)
+            (wrap-program update-sh
+              #:sh shell
+              `("PATH" ":" prefix (,#$(file-append coreutils "/bin")
+                                   ,#$(file-append git "/bin"))))))))
+    (home-page "https://github.com/guix-science/guix-cran-scripts";)
+    (synopsis "Automated CRAN to Guix import")
+    (description "Script, which automates the import of all packages from
+CRAN into a separate Guix channel.")
+    (license license:gpl3+))))
diff --git a/hydra/modules/sysadmin/services.scm 
b/hydra/modules/sysadmin/services.scm
index b2024ca..a765b0a 100644
--- a/hydra/modules/sysadmin/services.scm
+++ b/hydra/modules/sysadmin/services.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2022 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2023 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2023 Lars-Dominik Braun <ldb@leibniz-psychology.org>
 ;;;
 ;;; This program is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -1306,3 +1307,33 @@ to a selected directory.")
                                         
guix-packages-website-shepherd-services)))
    (default-value (guix-packages-website-configuration))
    (description "Run the Guix Packages website.")))
+
+;;;
+;;; Guix CRAN
+;;;
+
+(define guix-cran-job
+  #~(job "0 4 * * *" #$(file-append guix-cran-scripts "/bin/update.sh")
+         #:user "guix-cran"))
+
+(define %guix-cran-accounts
+  (list
+   (user-group (name "guix-cran") (system? #t))
+   (user-account
+    (name "guix-cran")
+    (group "guix-cran")
+    (system? #t)
+    (comment "User for Guix CRAN updates")
+    (home-directory "/var/lib/guix-cran")
+    (shell (file-append shadow "/sbin/nologin")))))
+
+(define-public guix-cran-service-type
+  (service-type (name 'guix-cran)
+                (extensions
+                 (list (service-extension mcron-service-type
+                                          (const (list guix-cran-job)))
+                       (service-extension account-service-type
+                                          (const %guix-cran-accounts))))
+                (description
+                 "Update the Guix CRAN channel")
+                (default-value #f)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]