[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs C source

From: Simon Tournier
Subject: Re: Emacs C source
Date: Tue, 19 Dec 2023 16:35:43 +0100


On Sun, 17 Dec 2023 at 14:18, Kristoffer Ström <> wrote:

> That's nice to know! However i would greatly prefer if there was some
> way to make it be available as part of a manifest,

Well, I am not aware of such out-of-box feature.

>                                                    i'm building multiple
> environments using guix shell containers, and doing this as an extra
> step in each one is not very pleasant.

Hum, I am missing context but I do not see what would be the workflow.

> something along the lines of `guix shell -D emacs` but for sources

Somehow Guix will manipulate read-only items in the store; thus the
source is not directly useful.  Something like that ugly,

--8<---------------cut here---------------start------------->8---
(use-modules (guix scripts build))

  (lambda (spec)
      (guix-build "--source" spec)
--8<---------------cut here---------------end--------------->8---

allows to fetch the corresponding source of each package.  However, the
source (tarball) are not part of the ’manifest’ and thus not visible
inside the container.

It is possible to do it using some plumbing Guix procedures, I
guess. :-)

Aside, I initially wrote a Guix script (see below) for mainly demoing
and now, I am using more or more. :-) I think something in this area is
missing.  I would like such workflow

   guix <something> emacs custom/path/to/emacs
   cd custom/path/to/emacs
   guix shell -C -D emacs
   … hack …

And the script just shows how to download the source of a package.

    (Please note that “guix build --source” returns the source after the
applying snippets, and the tiny script manipulated the URL of source,
i.e., before the applications of snippets.)


--8<---------------cut here---------------start------------->8---
$ cat examples/scripts/show-me-fetch.scm 
#!/usr/bin/env -S guix repl -q --
;; -*- mode: scheme -*-
;;; Copyright © 2023 Simon Tournier <>
;;; This script show URL of packages.

 (ice-9 match)

 ((gnu packages) #:select (specification->package))
 (guix packages)

 ((web uri) #:select (string->uri
 ((guix build download) #:select (maybe-expand-mirrors))
 ((guix download) #:select (%mirrors))
 (guix git-download))

(let ((pkgs (match (command-line)
              ((prog-name pkgs ...)
               (map specification->package pkgs))
                 (format #t "Error. Try: ./show-me-url.scm hello")
                 (exit 1))))))
   (lambda (pkg)
     (match (package-source pkg)
       ;; See 'origin->json' from file build-package-metadata.scm in repository
       ;; maintenance.git for an exhaustive case handling.
       ((? origin? o)
        (match (origin-uri o)
          ((? string? s)
           ;; Pick only the first (car) of the potenial long list
           (let ((url (car (map uri->string
                                (maybe-expand-mirrors (string->uri s) 
             (format #t "wget      ~a~%" url)))
          ((? git-reference? g)
           (let* ((url (git-reference-url g))
                 (revision (git-reference-commit g))
                 (tmpdir (string-append "/tmp/" (package-name pkg)))
                 (git (string-append "git -C " tmpdir)))
             (format #t "mkdir -p ~a ~%" tmpdir)
             (format #t "&& ~a init --initial-branch=main ~%" git)
             (format #t "&& ~a remote add origin ~a ~%" git url)
             (format #t "&& ~a fetch --depth 1 origin ~a ~%" git revision)
             (format #t "&& ~a checkout FETCH_HEAD ~%" git)))
          ;; All the other cases
          (_ #f)))))
  (exit 0))
--8<---------------cut here---------------end--------------->8---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]