Subject: [bug#37478] [PATCH] Support canonical guix environment -l guix.scm.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Tue, 10 Dec 2019 21:59:22 +0100

Thompson, David writes:

>     (package
>       (name "chickadee")
>       (version "0.1")
>       (source #f)
[..]

> Initially I thought a package made sense because, in addition to being
> used as the basis of a dev environment, I could build the same file as
> part of a CI system or pre-release make target, but in practice I
> can't really do that, thus the '(source #f)' bit and all the other
> boilerplate like version, synopsis, description, and license fields to
> satisfy the syntax rules.  It's also not a suitable package for
> upstreaming to Guix later because building from git requires
> additional dependencies that aren't needed when building from a
> release tarball.  So, if I were to rewrite this file today, I think I
> would just make a manifest instead.
>
> Of course, Guix could also just eval the file, use package? and
> manifest? predicates to see what it got, and act accordingly.  That
> might be the best choice from a usability standpoint.

Interesting!  I've been flipping here too.  Currently, I am using a
split setup.  The upstream(able) package lives in a subdirectory

--8<---------------cut here---------------start------------->8---
;;; guix/git/mes.scm:
(define-module (git mes)

(define-public mes
  (let ((triplet "i686-unknown-linux-gnu")
        (version "0.21"))
    (package
      (name "mes")
      (version version)
      (source (origin
                (method url-fetch)
                (uri (string-append
                      "https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
                (sha256
                 (base32 "04pajp8v31na34ls4730ig5f6miiplhdvkmsb9ls1b8bbmw2vb4n"))))
      (build-system gnu-build-system)
      ...
      (home-page "https://www.gnu.org/software/mes")
      (license gpl3+))))
--8<---------------cut here---------------end--------------->8---

and my guix.scm then uses that

--8<---------------cut here---------------start------------->8---
;;; guix.scm
(use-modules (guix gexp)
             (guix git-download)
             (guix packages)
             (gnu packages))

(define %source-dir (dirname (current-filename)))
(add-to-load-path (string-append %source-dir "/guix"))
(use-modules (git mes))

(define-public mes.git
  (package
    (inherit mes)
    (source (local-file %source-dir
                        #:recursive? #t
                        #:select? (git-predicate %source-dir)))))

mes.git
--8<---------------cut here---------------end--------------->8---

This way, I can maintain an upstream(able) package literally, build
from git and have my environment set up.

As a bonus, you can then use a .guix-channel file
--8<---------------cut here---------------start------------->8---
(channel
 (version 0)
 (directory "guix"))
--8<---------------cut here---------------end--------------->8---

so that you can guix pull straight from your repo.

Greetings,
janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com