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
compatibility to also add python-3.8 compatibility. Adjust 'install-python to not hardcode the python version. Efraim Flashner 2020-04-30Merge branch 'master' into core-updates... Conflicts: gnu/local.mk gnu/packages/backup.scm gnu/packages/emacs-xyz.scm gnu/packages/guile.scm gnu/packages/lisp.scm gnu/packages/openldap.scm gnu/packages/package-management.scm gnu/packages/web.scm gnu/packages/xorg.scm Marius Bakke 2020-04-30gnu: kaldi-gstreamer-server: Fix bug....* gnu/packages/machine-learning.scm (kaldi-gstreamer-server)[arguments]: Patch master_server.py before build. Ricardo Wurmus 2020-04-30gnu: kaldi-gstreamer-server: Use Tornado 6....* gnu/packages/machine-learning.scm (kaldi-gstreamer-server)[inputs]: Replace python-tornado with python-tornado-6. Ricardo Wurmus 2020-04-29gnu: kaldi-gstreamer-server: Update to 0-2.f68cab4....* gnu/packages/machine-learning.scm (kaldi-gstreamer-server): Update to 0-2.f68cab4. [inputs]: Replace python-2 with python-wrapper, python2-pygobject with python-pygobject, python2-pyyaml with python-pyyaml, and python2-tornado with python-tornado; remove python2-ws4py-for-kaldi-gstreamer-server and python2-futures. Ricardo Wurmus 2020-04-28gnu: python-scikit-learn: Make python-joblib a propagated input....* gnu/packages/machine-learning.scm (python-scikit-learn) [native-inputs]: Move 'python-joblib' to ... [propagated-inputs]: ... here. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Konrad Hinsen 2020-04-28gnu: gst-kaldi-nnet2-online: Update to 0-2.cb227ef....* gnu/packages/machine-learning.scm (gst-kaldi-nnet2-online): Update to 0-2.cb227ef. Ricardo Wurmus 2020-04-28gnu: kaldi: Update to 0-2.d4791c0....* gnu/packages/machine-learning.scm (kaldi): Update to 0-2.d4791c0. Ricardo Wurmus 2020-04-27gnu: Add python-scikit-rebate....* gnu/packages/machine-learning.scm (python-scikit-rebate): New variable. Roel Janssen 2020-04-13Merge branch 'master' into core-updatesMarius Bakke 2020-04-12gnu: shogun: Fix grammar of "allows to combine" to "combines"....* gnu/packages/machine-learning (shogun): Fix grammar. Vagrant Cascadian 2020-03-30Merge branch 'master' into core-updates... Conflicts: gnu/packages/admin.scm gnu/packages/commencement.scm gnu/packages/guile.scm gnu/packages/linux.scm gnu/packages/package-management.scm gnu/packages/pulseaudio.scm gnu/packages/web.scm Marius Bakke 2020-03-29gnu: vowpal-wabbit: Don't use unstable tarball....* gnu/packages/machine-learning.scm (vowpal-wabbit)[source]: Download using git-fetch. [arguments]: Add custom 'make-files-writable phase. Efraim Flashner 2020-03-21Merge branch 'master' into core-updatesMarius Bakke 2020-03-21gnu: python-scikit-learn: Use HTTPS home page....* gnu/packages/machine-learning.scm (python-scikit-learn)[home-page]: Use HTTPS. Tobias Geerinckx-Rice 2020-03-21gnu: TensorFlow: Correct gRPC input....* gnu/packages/machine-learning.scm (tensorflow)[native-inputs]: Move GRPC:STATIC ... [inputs]: ... here. Marius Bakke 2020-03-21gnu: gRPC: Update to 1.27.3....* gnu/packages/rpc.scm (grpc): Update to 1.27.3. [arguments]: Add "-DgRPC_ABSL_PROVIDER=package" in #:configure-flags. [inputs]: Add ABSEIL-CPP. (grpc-1.16.1): New public variable. * gnu/packages/hyperledger.scm (hyperledger-iroha)[inputs]: Change from GRPC to GRPC-1.16. * gnu/packages/machine-learning.scm (tensorflow)[native-inputs, inputs]: Likewise. Marius Bakke 2020-03-21gnu: gRPC: Move to (gnu packages rpc)....* gnu/packages/machine-learning.scm (grpc): Move to ... * gnu/packages/rpc.scm: ... here. New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Adjust accordingly. * gnu/packages/hyperledger.scm: Adjust module imports. Marius Bakke 2020-03-18Merge branch 'master' into core-updatesMarius Bakke 2020-03-14Merge branch 'master' into core-updatesMarius Bakke 2020-03-17gnu: shogun: Use HTTPS home page....* gnu/packages/machine-learning.scm (shogun)[home-page]: Use HTTPS. Tobias Geerinckx-Rice 2020-03-15gnu: python2-scikit-learn: Downgrade to 0.20.4....This is a follow-up to commit 546893c2965c8114e4d7cfe1de46c46664ec4b9e. * gnu/packages/machine-learning.scm (python-scikit-learn)[properties]: New field. (python2-scikit-learn)[version, source]: New fields. Marius Bakke 2020-03-12gnu: grpc: Build shared libraries....* gnu/packages/machine-learning.scm (grpc)[outputs]: Add static. [arguments]: Copy configure-flags from cmake-build-system. Add custom phases 'configure-shared, 'install-shared-libraries and 'move-static-libs to build shared libs and move static libs to their own output. (tensorflow)[native-inputs]: Add grpc:static. Efraim Flashner 2020-03-10Merge branch 'master' into core-updatesMarius Bakke 2020-03-08gnu: python-umap-learn: Fix build....* gnu/packages/machine-learning.scm (python-umap-learn): Add python-joblib to run the test suite. Roel Janssen 2020-03-06gnu: Update python-scikit-learn to 0.22.1....* gnu/packages/machine-learning.scm (python-scikit-learn): Update to 0.22.1; Add python-joblib to native-inputs to run the test suite. Roel Janssen 2020-03-04Merge branch 'master' into core-updatesMarius Bakke 2020-02-23gnu: libsvm: Use HTTPS home page....* gnu/packages/machine-learning.scm (libsvm)[home-page]: Use HTTPS. Tobias Geerinckx-Rice 2020-02-03Merge branch 'staging' into core-updatesMarius Bakke 2020-01-26gnu: ghmm: Fix missing module import....This is a follow-up to commit 9c2563a80b6f1d8fb8677f5314e6180ea9916aa5. * gnu/packages/machine-learning.scm (ghmm)[arguments]: Add #:modules. Marius Bakke