aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Joshua S. Grant <jgrant@parenthetical.io>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; 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 (gnu)
  #:use-module (guix i18n)
  #:use-module (guix diagnostics)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (ice-9 match)
  #:use-module (guix packages)
  #:use-module (gnu packages)
  #:use-module (gnu services)
  #:export (use-package-modules
            use-service-modules
            use-system-modules))

;;; Commentary:
;;;
;;; This composite module re-exports core parts the (gnu …) public modules.
;;;
;;; Code:

(eval-when (eval load compile)
  (begin
    (define %public-modules
      '((gnu system)
        (gnu system mapped-devices)
        (gnu system file-systems)
        (gnu bootloader)
        (gnu bootloader grub)
        (gnu system keyboard)
        (gnu system pam)
        (gnu system shadow)                       ; 'user-account'
        (gnu system linux-initrd)
        (gnu system nss)
        (gnu services)
        (gnu services base)
        (gnu packages)
        (gnu packages base)
        (guix gexp)))                             ; so gexps can be used

    (for-each (let ((i (module-public-interface (current-module))))
                (lambda (m)
                  (module-use! i (resolve-interface m))))
              %public-modules)))

(define (%try-use-modules modules location make-hint)
  "Attempt to load all of MODULES.  Report errors as coming from LOCATION, a
<location> record, and use MAKE-HINT to produce a fix hint."
  (define (location->string loc)
    (match loc
      (#f "")
      (($ <location> file line column)
       (format #f "~a:~a:~a: " file line column))))

  (for-each (lambda (module)
              (catch 'misc-error
                (lambda ()
                  (process-use-modules `((,module))))
                (lambda _
                  (raise
                   (apply
                    make-compound-condition
                    (formatted-message (G_ "module ~a not found")
                                       module)
                    (condition
                     (&error-location (location location)))
                    (or (and=> (make-hint module) list)
                        '()))))))
            modules))

(define (package-module-hint module)
  (define last-name
    (match module
      ((_ ... last)
       (symbol->string last))))

  (match (find-packages-by-name last-name)
    (()
     (condition
      (&fix-hint
       (hint (G_ "\
You may use @command{guix package --show=foo | grep location} to search
for the location of package @code{foo}.
If you get the line @code{location: gnu/packages/bar.scm:174:2},
add @code{bar} to the @code{use-package-modules} form.")))))
    ((package _ ...)
     (condition
      (&fix-hint
       (hint (format #f (G_ "\
Try adding @code{(use-package-modules ~a)}.")
                     (basename (location-file (package-location package))
                               ".scm"))))))))

(define (service-module-hint module)
  (define last-name
    (match module
      ((_ ... last)
       last)))

  (match (lookup-service-types last-name)
    (()
     (condition
      (&fix-hint
       (hint (format #f (G_ "\
You may use @command{guix system search ~a} to search for a service
matching @code{~a}.
If you get the line @code{location: gnu/services/foo.scm:188:2},
add @code{foo} to the @code{use-service-modules} form.")
                     last-name last-name)))))
    ((package _ ...)
     (condition
      (&fix-hint
       (hint (format #f (G_ "\
Try adding @code{(use-service-modules ~a)}.")
                     (basename (location-file (service-type-location package))
                               ".scm"))))))))

(define-syntax-rule (try-use-modules hint modules ...)
  (eval-when (expand load eval)
    (%try-use-modules '(modules ...)
                      (source-properties->location
                       (current-source-location))
                      hint)))

(define-syntax-rule (use-package-modules module ...)
  (try-use-modules package-module-hint
                   (gnu packages module) ...))

(define-syntax-rule (use-service-modules module ...)
  (try-use-modules service-module-hint
                   (gnu services module) ...))

(define-syntax-rule (use-system-modules module ...)
  (try-use-modules (const #f)                     ;no hint
                   (gnu system module) ...))

;;; gnu.scm ends here
pagated-inputs]: Likewise. Ludovic Courtès 2023-06-09gnu: hubbub: Fix build....* gnu/packages/web.scm (hubbub)[source]: Add patch. * gnu/packages/patches/hubbub-maybe-uninitialized.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Signed-off-by: Andreas Enge <andreas@enge.fr> Andy Tai 2023-05-25gnu: tinyproxy: Update to 1.11.1....* gnu/packages/web.scm (tinyproxy): Update to 1.11.1. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Aleksandr Vityazev 2023-05-24gnu: htmlcxx: add --std=c++11 to configure flags....* gnu/packages/web.scm (htmlcxx): add CXXFLAGS to configure-flag. C++17 removed dynamic exception specifications. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Arne Babenhauserheide 2023-05-23gnu: guix-data-service: Update to 0.0.1-41.6885006....* gnu/packages/web.scm (guix-data-service): Update to 0.0.1-41.6885006. Christopher Baines 2023-05-15gnu: lighttpd: Update to 1.4.70....* gnu/packages/web.scm (lighttpd): Update to 1.4.70. Signed-off-by: 宋文武 <iyzsong@member.fsf.org> André Batista 2023-05-07gnu: esbuild: Fix test-suite on riscv64-linux....* gnu/packages/web.scm (esbuild)[arguments]: Adjust custom 'check phase to enable running the tests on riscv64-linux. Efraim Flashner 2023-05-06gnu: mod-wsgi: Update to 4.9.4....* gnu/packages/web.scm (mod-wsgi): Update to 4.9.4. Ludovic Courtès 2023-05-06gnu: guix-data-service: Update to 0.0.1-40.3734a85...* gnu/packages/web.scm (guix-data-service): Update to 0.0.1-40.3734a85. Christopher Baines 2023-04-30gnu: mod-wsgi: Make sure not to keep a store reference to HTTPD....* gnu/packages/web.scm (mod-wsgi)[inputs]: Move httpd ... [native-inputs]: ... to here. [arguments]: Forbid keeping a reference to httpd. Leo Famulari 2023-04-30gnu: httpd: Update to 2.4.57 [security fixes]....Fixes CVE-2023-27522, CVE-2023-25690, CVE-2022-37436, CVE-2022-36760, CVE-2006-20001, CVE-2022-31813, CVE-2022-30556, CVE-2022-30522, CVE-2022-29404, CVE-2022-28615, CVE-2022-28614, CVE-2022-28330, CVE-2022-26377, CVE-2022-23943, CVE-2022-22721, CVE-2022-22720, and CVE-2022-22719. * gnu/packages/web.scm (httpd): Update to 2.4.57. (httpd/pinned): New variable. * gnu/packages/gnome.scm (libsoup-minimal): Replace httpd with httpd/pinned. Leo Famulari 2023-04-27gnu: libwebsockets: Update to 4.3.2....* gnu/packages/web.scm (libwebsockets): Update to 4.3.2. [arguments]: Remove. [source]: Use GIT-FILE-NAME. Ricardo Wurmus 2023-04-26gnu: rapidjson: Update to 1.1.0-1.949c771....* gnu/packages/patches/rapidjson-gcc-compat.patch: Remove file. * gnu/local.mk (dist_patch_DATA): Remove it. * gnu/packages/web.scm (rapidjson): Update to 1.1.0-1.949c771. [source]: Remove obsolete patch. Ricardo Wurmus 2023-04-22Merge remote-tracking branch 'origin/master' into core-updatesAndreas Enge 2023-04-22gnu: Add binaryen....* gnu/packages/web.scm (binaryen): New variable. Ricardo Wurmus 2023-04-22gnu: wabt: Update to 1.0.32....* gnu/packages/web.scm (wabt): Update to 1.0.32. [source]: Fetch sources recursively; delete bundled gtest sources. [arguments]: Do build and run tests; add phase to set CC variable, and another phase to delete a broken test. [native-inputs]: Add python and googletest. [inputs]: Remove. Ricardo Wurmus 2023-04-14Merge branch 'master' into core-updates....Conflicts: gnu/local.mk gnu/packages/build-tools.scm gnu/packages/certs.scm gnu/packages/check.scm gnu/packages/compression.scm gnu/packages/cups.scm gnu/packages/fontutils.scm gnu/packages/gnuzilla.scm gnu/packages/guile.scm gnu/packages/ibus.scm gnu/packages/image-processing.scm gnu/packages/linux.scm gnu/packages/music.scm gnu/packages/nss.scm gnu/packages/pdf.scm gnu/packages/python-xyz.scm gnu/packages/qt.scm gnu/packages/ruby.scm gnu/packages/shells.scm gnu/packages/tex.scm gnu/packages/video.scm gnu/packages/vulkan.scm gnu/packages/web.scm gnu/packages/webkit.scm gnu/packages/wm.scm Maxim Cournoyer 2023-04-14gnu: perl-io-socket-ssl: Update to 2.081....* gnu/packages/web.scm (perl-io-socket-ssl): Update to 2.081. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Bruno Victal 2023-04-14gnu: perl-io-socket-ssl: Update to 2.075....* gnu/packages/web.scm (perl-io-socket-ssl): Update to 2.075. Marius Bakke 2023-04-14gnu: perl-http-daemon: Update to 6.14....* gnu/packages/web.scm (perl-http-daemon): Update to 6.14. [native-inputs]: Add PERL-MODULE-BUILD and PERL-TEST-NEEDS. Marius Bakke 2023-04-14gnu: perl-http-message: Update to 6.37....* gnu/packages/web.scm (perl-http-message): Update to 6.37. [native-inputs]: Add PERL-TEST-NEEDS. Marius Bakke