1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix search-paths)
20 #:use-module (guix records)
21 #:use-module (ice-9 match)
22 #:export (<search-path-specification>
23 search-path-specification
24 search-path-specification?
25 search-path-specification-variable
26 search-path-specification-files
27 search-path-specification-separator
28 search-path-specification-file-type
29 search-path-specification-file-pattern
31 search-path-specification->sexp
32 sexp->search-path-specification))
36 ;;; This module defines "search path specifications", which allow packages to
37 ;;; declare environment variables that they use to define search paths. For
38 ;;; instance, GCC has the 'CPATH' variable, Guile has the 'GUILE_LOAD_PATH'
43 ;; The specification of a search path.
44 (define-record-type* <search-path-specification>
45 search-path-specification make-search-path-specification
46 search-path-specification?
47 (variable search-path-specification-variable) ;string
48 (files search-path-specification-files) ;list of strings
49 (separator search-path-specification-separator ;string
51 (file-type search-path-specification-file-type ;symbol
53 (file-pattern search-path-specification-file-pattern ;#f | string
56 (define (search-path-specification->sexp spec)
57 "Return an sexp representing SPEC, a <search-path-specification>. The sexp
58 corresponds to the arguments expected by `set-path-environment-variable'."
59 ;; Note that this sexp format is used both by build systems and in
60 ;; (guix profiles), so think twice before you change it.
62 (($ <search-path-specification> variable files separator type pattern)
63 `(,variable ,files ,separator ,type ,pattern))))
65 (define (sexp->search-path-specification sexp)
66 "Convert SEXP, which is as returned by 'search-path-specification->sexp', to
67 a <search-path-specification> object."
69 ((variable files separator type pattern)
70 (search-path-specification
75 (file-pattern pattern)))))
77 ;;; search-paths.scm ends here