guix-commits
[Top][All Lists]
Advanced

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

01/06: build-system: Add 'channel-build-system'.


From: guix-commits
Subject: 01/06: build-system: Add 'channel-build-system'.
Date: Tue, 9 Aug 2022 09:18:50 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 5bce4c82422de6beb3ce6120ba1592be898c2b72
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Aug 5 17:09:10 2022 +0200

    build-system: Add 'channel-build-system'.
    
    * gnu/ci.scm (channel-build-system, channel-source->package): Remove.
    * gnu/packages/package-management.scm (channel-source->package): New
    procedure, moved from (gnu ci).
    * guix/build-system/channel.scm: New file, with code moved from (gnu ci).
    * doc/guix.texi (Build Systems): Document it.
---
 Makefile.am                         |  1 +
 doc/guix.texi                       |  9 ++++++
 etc/system-tests.scm                |  3 +-
 gnu/ci.scm                          | 42 ++-------------------------
 gnu/packages/package-management.scm | 16 ++++++++++
 guix/build-system/channel.scm       | 58 +++++++++++++++++++++++++++++++++++++
 6 files changed, 87 insertions(+), 42 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f7c42e8153..f707b930b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -142,6 +142,7 @@ MODULES =                                   \
   guix/build-system/android-ndk.scm            \
   guix/build-system/ant.scm                    \
   guix/build-system/cargo.scm                  \
+  guix/build-system/channel.scm                        \
   guix/build-system/chicken.scm                        \
   guix/build-system/clojure.scm                        \
   guix/build-system/cmake.scm                  \
diff --git a/doc/guix.texi b/doc/guix.texi
index 9a6a5c307d..5dab9cf169 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9568,6 +9568,15 @@ with @code{build-expression->derivation} 
(@pxref{Derivations,
 @code{build-expression->derivation}}).
 @end defvr
 
+@defvr {Scheme Variable} channel-build-system
+This variable is exported by @code{(guix build-system channel)}.
+
+This build system is meant primarily for internal use.  It requires two
+arguments, @code{#:commit} and @code{#:source}, and builds a Guix
+instance from that channel, in the same way @command{guix time-machine}
+would do it (@pxref{Channels}).
+@end defvr
+
 @node Build Phases
 @section Build Phases
 
diff --git a/etc/system-tests.scm b/etc/system-tests.scm
index cd22b7e6d3..221a63bb7f 100644
--- a/etc/system-tests.scm
+++ b/etc/system-tests.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016, 2018-2020, 2022 Ludovic Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,7 +20,6 @@
              (gnu packages package-management)
              (guix monads)
              (guix store)
-             ((gnu ci) #:select (channel-source->package))
              ((guix git-download) #:select (git-predicate))
              ((guix utils) #:select (current-source-directory))
              (git)
diff --git a/gnu/ci.scm b/gnu/ci.scm
index 9389b43824..9cc3a1a81f 100644
--- a/gnu/ci.scm
+++ b/gnu/ci.scm
@@ -21,9 +21,9 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu ci)
-  #:use-module (guix channels)
+  #:use-module (guix build-system channel)
   #:use-module (guix config)
-  #:use-module (guix describe)
+  #:autoload   (guix describe) (package-channels)
   #:use-module (guix store)
   #:use-module (guix grafts)
   #:use-module (guix profiles)
@@ -32,7 +32,6 @@
   #:use-module (guix channels)
   #:use-module (guix config)
   #:use-module (guix derivations)
-  #:use-module (guix build-system)
   #:use-module (guix monads)
   #:use-module (guix gexp)
   #:use-module (guix ui)
@@ -71,7 +70,6 @@
             image->job
 
             %core-packages
-            channel-source->package
 
             arguments->systems
             cuirass-jobs))
@@ -288,42 +286,6 @@ otherwise use the IMAGE name."
               '()))
       '()))
 
-(define channel-build-system
-  ;; Build system used to "convert" a channel instance to a package.
-  (let* ((build (lambda* (name inputs
-                               #:key source commit system
-                               #:allow-other-keys)
-                  (mlet* %store-monad ((source (if (string? source)
-                                                   (return source)
-                                                   (lower-object source)))
-                                       (instance
-                                        -> (checkout->channel-instance
-                                            source #:commit commit)))
-                    (channel-instances->derivation (list instance)))))
-         (lower (lambda* (name #:key system source commit
-                               #:allow-other-keys)
-                  (bag
-                    (name name)
-                    (system system)
-                    (build build)
-                    (arguments `(#:source ,source
-                                 #:commit ,commit))))))
-    (build-system (name 'channel)
-                  (description "Turn a channel instance into a package.")
-                  (lower lower))))
-
-(define* (channel-source->package source #:key commit)
-  "Return a package for the given channel SOURCE, a lowerable object."
-  (package
-    (inherit guix)
-    (version (string-append (package-version guix) "+"))
-    (build-system channel-build-system)
-    (arguments `(#:source ,source
-                 #:commit ,commit))
-    (inputs '())
-    (native-inputs '())
-    (propagated-inputs '())))
-
 (define* (system-test-jobs store system
                            #:key source commit)
   "Return a list of jobs for the system tests."
diff --git a/gnu/packages/package-management.scm 
b/gnu/packages/package-management.scm
index c22c9f7a43..b9cd74eb27 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -110,6 +110,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages version-control)
+  #:autoload   (guix build-system channel) (channel-build-system)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system guile)
@@ -489,6 +490,21 @@ the Nix package manager.")
       (license license:gpl3+)
       (properties '((ftp-server . "alpha.gnu.org"))))))
 
+(define* (channel-source->package source #:key commit)
+  "Return a package for the given channel SOURCE, a lowerable object."
+  (package
+    (inherit guix)
+    (version (string-append (package-version guix) "."
+                            (if commit (string-take commit 7) "")))
+    (build-system channel-build-system)
+    (arguments `(#:source ,source
+                 #:commit ,commit))
+    (inputs '())
+    (native-inputs '())
+    (propagated-inputs '())))
+
+(export channel-source->package)
+
 (define-public guix-for-cuirass
   ;; Known-good revision before commit
   ;; bd86bbd300474204878e927f6cd3f0defa1662a5, which introduced
diff --git a/guix/build-system/channel.scm b/guix/build-system/channel.scm
new file mode 100644
index 0000000000..227eb08373
--- /dev/null
+++ b/guix/build-system/channel.scm
@@ -0,0 +1,58 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019-2021 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix 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.
+;;;
+;;; GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system channel)
+  #:use-module ((guix store) #:select (%store-monad))
+  #:use-module ((guix gexp) #:select (lower-object))
+  #:use-module (guix monads)
+  #:use-module (guix channels)
+  #:use-module (guix build-system)
+  #:export (channel-build-system))
+
+;;; Commentary:
+;;;
+;;; The "channel" build system lets you build Guix instances from channel
+;;; specifications, similar to how 'guix time-machine' would do it, as regular
+;;; packages.
+;;;
+;;; Code:
+
+(define channel-build-system
+  ;; Build system used to "convert" a channel instance to a package.
+  (let* ((build (lambda* (name inputs
+                               #:key source commit system
+                               #:allow-other-keys)
+                  (mlet* %store-monad ((source (if (string? source)
+                                                   (return source)
+                                                   (lower-object source)))
+                                       (instance
+                                        -> (checkout->channel-instance
+                                            source #:commit commit)))
+                    (channel-instances->derivation (list instance)))))
+         (lower (lambda* (name #:key system source commit
+                               #:allow-other-keys)
+                  (bag
+                    (name name)
+                    (system system)
+                    (build build)
+                    (arguments `(#:source ,source
+                                 #:commit ,commit))))))
+    (build-system (name 'channel)
+                  (description "Turn a channel instance into a package.")
+                  (lower lower))))
+



reply via email to

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