all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: "Kristoffer Ström" <kristoffer@rymdkoloni.se>,
	help-guix <help-guix@gnu.org>
Subject: Re: Emacs C source
Date: Tue, 19 Dec 2023 16:35:43 +0100	[thread overview]
Message-ID: <87jzpa2oj4.fsf@gmail.com> (raw)
In-Reply-To: <87le9tge6r.fsf@rymdkoloni.se>

Hi,

On Sun, 17 Dec 2023 at 14:18, Kristoffer Ström <kristoffer@rymdkoloni.se> 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))

(specifications->manifest
 (map
  (lambda (spec)
    (begin
      (guix-build "--source" spec)
      spec))
  (list
   "emacs"
   "coreutils"
   )))
--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.)

Cheers,
simon


--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 <zimon.toutoune@gmail.com>
;;;
;;;
;;; This script show URL of packages.
;;;

(use-modules
 (ice-9 match)

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

 ((web uri) #:select (string->uri
                      uri->string))
 ((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))
              (_
               (begin
                 (format #t "Error. Try: ./show-me-url.scm hello")
                 (exit 1))))))
  (for-each
   (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) %mirrors)))))
             (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)))))
   pkgs)
  (exit 0))
--8<---------------cut here---------------end--------------->8---


  reply	other threads:[~2023-12-19 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 14:56 Emacs C source Kristoffer Ström
2023-12-17 11:27 ` Tomas Volf
2023-12-17 13:18   ` Kristoffer Ström
2023-12-19 15:35     ` Simon Tournier [this message]
2023-12-19 16:07       ` Kristoffer Ström
2023-12-17 22:03 ` Ian Eure

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jzpa2oj4.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=kristoffer@rymdkoloni.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.