diff mbox series

[bug#36404,4/6] Export the (gnu machine) interface.

Message ID 875zoqan2e.fsf_-_@sdf.lonestar.org
State Accepted
Headers show
Series Add 'guix deploy'. | expand

Commit Message

Jakob L. Kreuze June 27, 2019, 6:40 p.m. UTC
This is so machine declarations can have a simple (use-modules (gnu))
rather than having to import the machine module explicitly.

2019-06-26  Jakob L. Kreuze  <zerodaysfordays@sdf.lonestar.org>

* gnu.scm (%public-modules): Add '(gnu machine)'.
* gnu.scm (use-machine-modules): New macro.
---
 gnu.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Christine Lemmer-Webber June 29, 2019, 9:36 p.m. UTC | #1
Jakob L. Kreuze writes:

> This is so machine declarations can have a simple (use-modules (gnu))
> rather than having to import the machine module explicitly.

+1
Ricardo Wurmus June 29, 2019, 10:04 p.m. UTC | #2
Hi Jakob,

> This is so machine declarations can have a simple (use-modules (gnu))
> rather than having to import the machine module explicitly.

Do we need this at all or could “guix deploy” evaluate the machine
declaration in an environment where the machine module is available?  We
do something like that for evaluating manifests – no module relating to
manifest loading needs to be specified by users and yet
“specifications->manifest” is available.

Would it make sense to do something similar here instead of exporting
(gnu machine) in (gnu)?
Jakob L. Kreuze June 30, 2019, 12:41 a.m. UTC | #3
Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

> Do we need this at all or could “guix deploy” evaluate the machine
> declaration in an environment where the machine module is available?
> We do something like that for evaluating manifests – no module
> relating to manifest loading needs to be specified by users and yet
> “specifications->manifest” is available.
>
> Would it make sense to do something similar here instead of exporting
> (gnu machine) in (gnu)?

Thanks for that comment; I'd completely forgotten about not having to
import 'specifications->manifest'. I doubt the machine types will see
much use outside of deployment specifications, so something like that
would definitely make sense here. I'll add it in.

Regards,
Jakob
diff mbox series

Patch

diff --git a/gnu.scm b/gnu.scm
index 2c29b6dc3f..fa643a5b92 100644
--- a/gnu.scm
+++ b/gnu.scm
@@ -27,7 +27,8 @@ 
   #:use-module (guix packages)
   #:use-module (gnu packages)
   #:use-module (gnu services)
-  #:export (use-package-modules
+  #:export (use-machine-modules
+            use-package-modules
             use-service-modules
             use-system-modules))
 
@@ -45,6 +46,7 @@ 
         (gnu system file-systems)
         (gnu bootloader)
         (gnu bootloader grub)
+        (gnu machine)
         (gnu system keyboard)
         (gnu system pam)
         (gnu system shadow)                       ; 'user-account'
@@ -142,6 +144,10 @@  Try adding @code{(use-service-modules ~a)}.")
                        (current-source-location))
                       hint)))
 
+(define-syntax-rule (use-machine-modules module ...)
+  (try-use-modules package-module-hint
+                   (gnu machine module) ...))
+
 (define-syntax-rule (use-package-modules module ...)
   (try-use-modules package-module-hint
                    (gnu packages module) ...))