[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to install a package in guile
From: |
Feng Shu |
Subject: |
Re: How to install a package in guile |
Date: |
Thu, 27 Jul 2017 20:43:28 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Alex Kost <address@hidden> writes:
> Feng Shu (2017-07-26 20:44 +0800) wrote:
>
>> address@hidden (Ludovic Courtès) writes:
> [...]
>>> The rest (setting up the symlink) is a little less convenient though.
>>> See (guix scripts package) or the equivalent Emacs-Guix code for how
>>> this works.
>>
>> (build-and-use-profile store "~/.guix-profile" $2)
>>
>> How can I get the "store"?
>
> For example, like this:
>
> (with-store store
> (build-and-use-profile ...))
guix's code seem to hard for me, I use a emacs command to solve my
problem:
-----------------
(defvar guix-export-directory "~/myguix/")
(defun guix-export-package ()
(interactive)
(let* ((directory (file-name-as-directory guix-export-directory))
(current-module (guix-guile-current-module))
(define-public-string
(save-excursion
(end-of-defun)
(let ((end (point)))
(beginning-of-defun)
(buffer-substring (point) end))))
(package-name
(progn (string-match "\\(define-public +\\)\\([a-z-]+\\)\n+"
define-public-string)
(match-string 2 define-public-string)))
(define-module-string
(replace-regexp-in-string
" *(define-module.*\n"
(format (concat "(define-module (%s)\n"
" #:use-module %s\n")
package-name current-module)
(save-excursion
(goto-char (point-min))
(search-forward "(define-module")
(end-of-defun)
(let ((end (point)))
(beginning-of-defun)
(buffer-substring (point) end)))))
(command (format "guix package --load-path='%s' -i %s "
directory package-name)))
(unless (file-directory-p directory)
(make-directory directory t))
(with-temp-buffer
(insert define-module-string)
(insert "\n")
(insert define-public-string)
(write-file (concat directory package-name ".scm"))
(kill-new command)
(message command)))
------------
--