So I did! It's probably better to give a clear, in-line example anyways.
I take it you know *what* I'm doing, just not *why*; but I'm going to
include a full example anyway for the benefit of future readers.
Note that this is a compile-time error, so profiles containing such
code fail to build entirely but produce cached object files which may
continue to function correctly after eg. a roll-back. I was briefly
bit by one after pulling an upstream profile to confirm the behavior
shown :p
``` scheme
#!/usr/bin/env -S guix repl -L ./modules
!#
(define-module (example)
#:use-module (gnu packages)
#:use-module (gnu packages base)
#:use-module (guix packages))
(define-public my-hello
(package
(inherit hello)
(name "my-hello")))
;; Suppose we're an average user and keep our configuration in a
;; channel in our home-dir:
(format (current-output-port) "~s~%"
(module-filename (current-module)))
;; => "/home/user/src/example/./example.scm"
;; Whether or not it's best practice, we may be inclined to use
;; `specification->package' to populate our `operating-system',
;; `home-environment', and even (*gasp*) `service' records.
(format (current-output-port) "~s~%"
(specification->package "hello"))
;; => #<package hello@2.12.1 gnu/packages/base.scm:92 7f958d8c09a0>
;; But this procedure fails when we attempt to reference a
;; package-variant defined within our configuration channel (even
;; when it's in another module, eg. `(example packages base)'):
(format (current-output-port) "~s~%"
(specification->package "my-hello"))
;; => guix repl: error: my-hello: unknown package
;; (Note that this is a non-continuable exception, and would commented out
;; to execute the remaining stanza of this script.)
;; A clever user might parameterize `%package-search-path' to get
;; around this limitation:
(parameterize ((%package-module-path
(cons `(,(dirname (module-filename (current-module))) . "")
(%package-module-path))))
(format (current-output-port) "~s~%"
(specification->package "my-hello")))
;; => guix repl: error: my-hello: unknown package
;; But only with the patch do we enable this functionality:
;; => #<package my-hello@2.12.1 /home/user/src/example/./example.scm:10 7fc6a6678a50>
```
Regarding my specific use-case, I have a channel featuring the following
at least the following four snippets.
antlers/home/files/emacs/init.el[1]:
``` elisp
(use-package all-the-icons
:guix (emacs-all-the-icons)
:defer t)
(use-package magit
:guix emacs-magit git
:custom (magit-diff-refine-hunk t))
(use-package embark
:guix (emacs-embark ; This refers to my fork with a page-able which-key pop-up on `embark-collect'
--with-git-url=emacs-embark=file:///home/antlers/[...]
--with-branch=emacs-embark=fix/issue-647)
:custom (prefix-help-command 'embark-prefix-help-command))
(use-package devil-mode
:guix emacs-devil-mode
:custom (devil-key "'"))
```
antlers/home/extract-emacs-packages.scm[2]:
``` scheme
(define extact-emacs-packages (file-path)
[...]) ; this is not polished code, you don't wanna see it: just imagine
;; => (list #<package [...]> ...)
```
antlers/packages/emacs-xyz:
``` elisp
(define-public emacs-devil-mode
(package
(name "emacs-devil-mode")
(version "0.6.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(commit version)))
(sha256
(base32 "1pr9yf6f37sz5qy1snn8ag5bvg6lza7q635jh8jhaqqfp37jvv1y"))
(file-name (git-file-name name version))))
(build-system emacs-build-system)
(synopsis "Modifier-free editing in Emacs")
(description
"Devil mode trades your comma key in exchange for a modifier-free
editing experience in Emacs.")
(license license:expat)))
```
antlers/home.scm:
``` scheme
(simple-service 'emacs-packages home-profile-service-type
;; Add `(antlers packages)' to `specification->package' PATH
(parameterize ((%package-module-path
(cons `(,(dirname (dirname (module-filename (current-module))))
. "antlers/packages")
(%package-module-path))))
(append (extract-emacs-packages "./home/files/emacs/init.el")
(extract-emacs-packages "./home/files/emacs/early-init.el"))))
```
If there's a better way to do this (barring the obvious of upstreaming
assorted bits) let me know, I'm sure there are many ways, but this
one's mine. I don't like to keep the manifest seperate from my configuration,
but also don't want to keep them in an org file and have to invoke
emacs to build my channel.
I don't know if a.) there's any cause to be concerned about the
performance of this tweak, or b.) that you care to support the
behavior at all, but I hope I've made my own use-case clear and the
patch is there if you see fit c:
Thx for your time!