;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012-2020, 2022-2023 Ludovic Courtès ;;; Copyright © 2013 Mark H Weaver ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2016, 2017 Alex Kost ;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2022 Antero Mejr ;;; ;;; 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 . (define-module (gnu packages) #:use-module (guix packages) #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix diagnostics) #:use-module (guix discovery) #:use-module (guix memoization) #:use-module ((guix build utils) #:select ((package-name->name+version . hyphen-separated-name->name+version) mkdir-p)) #:use-module (guix profiles) #:use-module (guix describe) #:use-module (guix deprecation) #:use-module (ice-9 vlist) #:use-module (ice-9 match) #:use-module (ice-9 binary-ports) #:autoload (rnrs bytevectors) (bytevector?) #:autoload (system base compile) (compile) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (srfi srfi-39) #:use-module (srfi srfi-71) #:export (search-patch search-patches search-auxiliary-file %patch-path %auxiliary-files-path %package-module-path %default-package-module-path cache-is-authoritative? fold-packages fold-available-packages find-newest-available-packages find-packages-by-name find-package-locations find-best-packages-by-name specification->package specification->package+output specification->location specifications->manifest specifications->packages package-unique-version-prefix generate-package-cache)) ;;; Commentary: ;;; ;;; General utilities for the software distribution---i.e., the modules under ;;; (gnu packages ...). ;;; ;;; Code: ;; By default, we store patches and auxiliary files ;; alongside Guile modules. This is so that these extra files can be ;; found without requiring a special setup, such as a specific ;; installation directory and an extra environment variable. One ;; advantage of this setup is that everything just works in an ;; auto-compilation setting. (define %auxiliary-files-path (make-parameter (map (cut string-append <> "/gnu/packages/aux-files") %load-path))) (define (search-auxiliary-file file-name) "Search the auxiliary FILE-NAME. Return #f if not found." (search-path (%auxiliary-files-path) file-name)) (define (search-patch file-name) "Search the patch FILE-NAME. Raise an error if not found." (or (search-path (%patch-path) file-name) (raise (formatted-message (G_ "~a: patch not found") file-name)))) (define-syntax-rule (search-patches file-name ...) "Return the list of absolute file names corresponding to each FILE-NAME found in %PATCH-PATH." (list (search-patch file-name) ...)) (define %distro-root-directory ;; Absolute file name of the module hierarchy. Since (gnu packages …) might ;; live in a directory different from (guix), try to get the best match. (letrec-syntax ((dirname* (syntax-rules () ((_ file) (dirname file)) ((_ file head tail ...) (dirname (dirname* file tail ...))))) (try (syntax-rules () ((_ (file things ...) rest ...) (match (search-path %load-path file) (#f (try rest ...)) (absolute (dirname* absolute things ...)))) ((_) #f)))) (try ("gnu/packages/base.scm" gnu/ packages/) ("gnu/packages.scm" gnu/) ("guix.scm")))) (define %default-package-module-path ;; Default search path for package modules. `((,%distro-root-directory . "gnu/packages"))) (define (cache-is-authoritative?) "Return true if the pre-computed package cache is authoritative. It is not authoritative when entries have been added via GUIX_PACKAGE_PATH or '-L' flags." (equal? (%package-module-path) (append %default-package-module-path (package-path-entries)))) (define %package-module-path ;; Search path for package modules. Each item must be either a directory ;; name or a pair whose car is a directory and whose cdr is a sub-directory ;; to narrow the search. (let* ((not-colon (char-set-complement (char-set #\:))) (environment (string-tokenize (or (getenv "GUIX_PACKAGE_PATH") "") not-colon)) (channels-scm channels-go (package-path-entries))) ;; Automatically a