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'.
This commit is contained in:
Ludovic Courtès 2022-08-08 23:35:22 +02:00
parent 64a070717c
commit 57f1892d36
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -120,6 +120,10 @@ (define-module (gnu packages package-management)
#: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 @@ (define-public guix-minimal
(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))
(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)
;;
;; 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)
(version (string-append (package-version guix) "+"))
(source (local-file (force repository-root) "guix-current"
#:recursive? #t
#:select? (force select?))))))))
(source source)
(build-system channel-build-system)
(inputs '())
(native-inputs '())
(propagated-inputs '())))
(#f #f)))))
(define-public current-guix
(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