guix-commits
[Top][All Lists]
Advanced

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

04/06: gnu: guix: Default 'current-guix' is built using the current chan


From: guix-commits
Subject: 04/06: gnu: guix: Default 'current-guix' is built using the current channels.
Date: Tue, 9 Aug 2022 09:18:51 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 57f1892d366ea28083391577f90c4aa06b90aaf1
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Aug 8 23:35:22 2022 +0200

    gnu: guix: Default 'current-guix' is built using the current channels.
    
    * gnu/packages/package-management.scm (source-file?): Remove.
    (current-guix-package): Change default value to the promise of a
    package.
    (current-guix): Turn into a call to 'current-guix-package' possibly with
    'force'.
---
 gnu/packages/package-management.scm | 62 +++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/gnu/packages/package-management.scm 
b/gnu/packages/package-management.scm
index b9cd74eb27..01abd98d65 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -120,6 +120,10 @@
   #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix git-download)
+  #:autoload   (guix describe) (current-channels)
+  #:autoload   (guix channels) (channel?
+                                guix-channel?
+                                repository->guix-channel)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -600,45 +604,37 @@ the Nix package manager.")
       (modify-inputs (package-propagated-inputs guix)
         (delete "guile-ssh"))))))
 
-(define (source-file? file stat)
-  "Return true if FILE is likely a source file, false if it is a typical
-generated file."
-  (define (wrong-extension? file)
-    (or (string-suffix? "~" file)
-        (member (file-extension file)
-                '("o" "a" "lo" "so" "go"))))
-
-  (match (basename file)
-    ((or ".git" "autom4te.cache" "configure" "Makefile" "Makefile.in" ".libs")
-     #f)
-    ((? wrong-extension?)
-     #f)
-    (_
-     #t)))
-
 (define-public current-guix-package
   ;; This parameter allows callers to override the package that 'current-guix'
   ;; returns.  This is useful when 'current-guix' cannot compute it by itself,
   ;; for instance because it's not running from a source code checkout.
-  (make-parameter #f))
+  ;;
+  ;; The default value is obtained by creating a package from the 'guix'
+  ;; channel returned by 'current-channels' or, if that's the empty list, that
+  ;; returned by 'repository->guix-channel' for the current directory (which
+  ;; assumes that we're running from a Git checkout).  Delay computation so
+  ;; that the relevant modules can be loaded lazily.
+  (make-parameter
+   (delay (match (or (find guix-channel? (current-channels))
+                     (repository->guix-channel
+                      (current-source-directory)))
+            ((? channel? source)
+             (package
+               (inherit guix)
+               (source source)
+               (build-system channel-build-system)
+               (inputs '())
+               (native-inputs '())
+               (propagated-inputs '())))
+            (#f #f)))))
 
 (define-public current-guix
-  (let* ((repository-root (delay (canonicalize-path
-                                  (string-append (current-source-directory)
-                                                 "/../.."))))
-         (select? (delay (or (git-predicate (force repository-root))
-                             source-file?))))
-    (lambda ()
-      "Return a package representing Guix built from the current source tree.
-This works by adding the current source tree to the store (after filtering it
-out) and returning a package that uses that as its 'source'."
-      (or (current-guix-package)
-          (package
-            (inherit guix)
-            (version (string-append (package-version guix) "+"))
-            (source (local-file (force repository-root) "guix-current"
-                                #:recursive? #t
-                                #:select? (force select?))))))))
+  (lambda ()
+    "Return a package representing the currently-used Guix.  It can be
+overridden by setting the 'current-guix-package' parameter."
+    (match (current-guix-package)
+      ((? promise? package) (force package))
+      (package package))))
 
 (define-public guix-icons
   (package



reply via email to

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