environ.scm 1.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
;;; Guix-kernel -- Guix kernel for Jupyter
;;; Copyright (C) 2018  Pierre-Antoine Rouby <pierre-antoine.rouby@inria.fr>
;;;
;;; This program 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.
;;;
;;; This program 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 this program.  If not, see <https://www.gnu.org/licenses/>.

17
18
19
20
21
22
23
24
25
26
27
28
29
(define-module (guix-kernel environ)
  #:use-module (gnu packages)
  #:use-module (guix licenses)
  #:use-module (guix packages)
  #:use-module (guix records)
  #:use-module (guix store)
  #:use-module (guix utils)
  #:use-module (guix monads)
  #:use-module (guix derivations)
  #:use-module (guix build utils)
  #:use-module (srfi srfi-11)
  #:export (guile->path
            guile-current-version->path
30

31
32
33
            package-name->path))

(define (store) (open-connection))
34

35
36
37
38
39
40
(define (m-package-by-name->package-path name)
  (mlet %store-monad ((drv (package->derivation
                            (specification->package name))))
    (mbegin %store-monad
      (built-derivations (list drv))
      (return (derivation->output-path drv)))))
41

42
43
(define (guile->path guile)
  "Return path to guile executable file. GUILE is package specification."
44
  (string-append
45
   (run-with-store (store) (m-package-by-name->package-path guile))
46
47
   "/bin/guile"))

48
49
50
51
(define (guile-current-version->path)
  "Return path to current guile executable file."
  (guile->path (string-append "guile" "@" (version))))

52
53
(define (package-name->path name)
  "Return store path for package coresponding to NAME."
54
  (run-with-store (store) (m-package-by-name->package-path name)))