Alex Kost <alez...@gmail.com> writes:

> Feng Shu (2017-07-26 20:44 +0800) wrote:
>
>> l...@gnu.org (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)))

------------



-- 


Reply via email to