Re: [PATCH 1/6] guix system: Export accessors.

2016-01-14 Thread Alex Kost
Ludovic Courtès (2016-01-14 01:33 +0300) wrote:

> Alex Kost  skribis:
>
>> Ludovic Courtès (2016-01-12 23:25 +0300) wrote:
>>
>>> Alex Kost  skribis:
>>>
 * guix/scripts/system.scm (read-boot-parameters, boot-parameters)
 (boot-parameters?, boot-parameters-label, boot-parameters-root-device)
 (boot-parameters-kernel, boot-parameters-kernel-arguments): Export.
>>>
>>> LGTM.
>>>
>>> Eventually (as a replacement of this patch or as a subsequent patch, as
>>> you prefer) we should move these to (gnu system) since this is where we
>>> create the ‘boot-parameters’ sexp.
>>
>> Great, I would like to make a replacement.  OK for the attached patch?
>>
>> (I exported  because it is used by (guix scripts system))
>
> I usually avoid exporting record type descriptors (RTDs) like
>  because then, if you change the layout of fields, you
> have to update every ‘match’ clause out there, and it can be tedious and
> error-prone.  Also, if the RTD is exported, then it’s trivial for other
> modules to forge records of that type.
>
> Could you instead rewrite the two occurrences in (guix system scripts)
> so they use the ‘boot-parameters-XYZ’ accessors instead of ‘match’?  A
> bit more verbose, but safer.
>
> Sorry that I didn’t clarify this before!

Sure, I should have guessed to do it without clarifying.  The updated
patch is attached.

>From df626fd61b5611b2174a792fd5736d696bd307c1 Mon Sep 17 00:00:00 2001
From: Alex Kost 
Date: Fri, 8 Jan 2016 02:48:17 +0300
Subject: [PATCH] Move  to (gnu system).

* guix/scripts/system.scm (previous-grub-entries)
  (display-system-generation): Use accessors instead of matching
  .
  (boot-parameters, boot-parameters?, boot-parameters-label)
  (boot-parameters-root-device, boot-parameters-kernel)
  (boot-parameters-kernel-arguments, read-boot-parameters): Move to...
* gnu/system.scm: ... here. Export them.
---
 gnu/system.scm  | 41 
 guix/scripts/system.scm | 85 -
 2 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 4aedb7e..ee0280c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -88,6 +88,14 @@
 operating-system-locale-directory
 operating-system-boot-script
 
+boot-parameters
+boot-parameters?
+boot-parameters-label
+boot-parameters-root-device
+boot-parameters-kernel
+boot-parameters-kernel-arguments
+read-boot-parameters
+
 local-host-aliases
 %setuid-programs
 %base-packages
@@ -709,4 +717,37 @@ this file is the reconstruction of GRUB menu entries for old configurations."
 #$(operating-system-kernel-arguments os))
(initrd #$initrd)
 
+
+;;;
+;;; Boot parameters
+;;;
+
+(define-record-type* 
+  boot-parameters make-boot-parameters boot-parameters?
+  (labelboot-parameters-label)
+  (root-device  boot-parameters-root-device)
+  (kernel   boot-parameters-kernel)
+  (kernel-arguments boot-parameters-kernel-arguments))
+
+(define (read-boot-parameters port)
+  "Read boot parameters from PORT and return the corresponding
+ object or #f if the format is unrecognized."
+  (match (read port)
+(('boot-parameters ('version 0)
+   ('label label) ('root-device root)
+   ('kernel linux)
+   rest ...)
+ (boot-parameters
+  (label label)
+  (root-device root)
+  (kernel linux)
+  (kernel-arguments
+   (match (assq 'kernel-arguments rest)
+ ((_ args) args)
+ (#f   '())   ;the old format
+(x;unsupported format
+ (warning (_ "unrecognized boot parameters for '~a'~%")
+  system)
+ #f)))
+
 ;;; system.scm ends here
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 1407dc7..564ed02 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015 Ludovic Courtès 
+;;; Copyright © 2016 Alex Kost 
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -191,39 +192,6 @@ the ownership of '~a' may be incorrect!~%")
 

 ;;;
-;;; Boot parameters
-;;;
-
-(define-record-type* 
-  boot-parameters make-boot-parameters boot-parameters?
-  (labelboot-parameters-label)
-  (root-device  boot-parameters-root-device)
-  (kernel   boot-parameters-kernel)
-  (kernel-arguments boot-parameters-kernel-arguments))
-
-(define (read-boot-parameters port)
-  "Read boot parameters from PORT and return the corresponding
- object or #f if the format is unrecognized."
-  (match (read port)
-(('boot-parameters ('version 0)
-

Re: [PATCH 1/6] guix system: Export accessors.

2016-01-14 Thread Ludovic Courtès
Alex Kost  skribis:

> From df626fd61b5611b2174a792fd5736d696bd307c1 Mon Sep 17 00:00:00 2001
> From: Alex Kost 
> Date: Fri, 8 Jan 2016 02:48:17 +0300
> Subject: [PATCH] Move  to (gnu system).
>
> * guix/scripts/system.scm (previous-grub-entries)
>   (display-system-generation): Use accessors instead of matching
>   .
>   (boot-parameters, boot-parameters?, boot-parameters-label)
>   (boot-parameters-root-device, boot-parameters-kernel)
>   (boot-parameters-kernel-arguments, read-boot-parameters): Move to...
> * gnu/system.scm: ... here. Export them.

Perfect, thank you!

Ludo’.



Re: [PATCH 1/6] guix system: Export accessors.

2016-01-13 Thread Alex Kost
Ludovic Courtès (2016-01-12 23:25 +0300) wrote:

> Alex Kost  skribis:
>
>> * guix/scripts/system.scm (read-boot-parameters, boot-parameters)
>> (boot-parameters?, boot-parameters-label, boot-parameters-root-device)
>> (boot-parameters-kernel, boot-parameters-kernel-arguments): Export.
>
> LGTM.
>
> Eventually (as a replacement of this patch or as a subsequent patch, as
> you prefer) we should move these to (gnu system) since this is where we
> create the ‘boot-parameters’ sexp.

Great, I would like to make a replacement.  OK for the attached patch?

(I exported  because it is used by (guix scripts system))

>From ac344e3f17741c439aa15a642f1872fd2c7bfd9f Mon Sep 17 00:00:00 2001
From: Alex Kost 
Date: Fri, 8 Jan 2016 02:48:17 +0300
Subject: [PATCH] Move  to (gnu system).

* guix/scripts/system.scm (, boot-parameters)
  (boot-parameters?, boot-parameters-label, boot-parameters-root-device)
  (boot-parameters-kernel, boot-parameters-kernel-arguments):
  (read-boot-parameters) Move to...
* gnu/system.scm: ... here. Export them.
---
 gnu/system.scm  | 42 ++
 guix/scripts/system.scm | 33 -
 2 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index 4aedb7e..2600224 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -88,6 +88,15 @@
 operating-system-locale-directory
 operating-system-boot-script
 
+
+boot-parameters
+boot-parameters?
+boot-parameters-label
+boot-parameters-root-device
+boot-parameters-kernel
+boot-parameters-kernel-arguments
+read-boot-parameters
+
 local-host-aliases
 %setuid-programs
 %base-packages
@@ -709,4 +718,37 @@ this file is the reconstruction of GRUB menu entries for old configurations."
 #$(operating-system-kernel-arguments os))
(initrd #$initrd)
 
+
+;;;
+;;; Boot parameters
+;;;
+
+(define-record-type* 
+  boot-parameters make-boot-parameters boot-parameters?
+  (labelboot-parameters-label)
+  (root-device  boot-parameters-root-device)
+  (kernel   boot-parameters-kernel)
+  (kernel-arguments boot-parameters-kernel-arguments))
+
+(define (read-boot-parameters port)
+  "Read boot parameters from PORT and return the corresponding
+ object or #f if the format is unrecognized."
+  (match (read port)
+(('boot-parameters ('version 0)
+   ('label label) ('root-device root)
+   ('kernel linux)
+   rest ...)
+ (boot-parameters
+  (label label)
+  (root-device root)
+  (kernel linux)
+  (kernel-arguments
+   (match (assq 'kernel-arguments rest)
+ ((_ args) args)
+ (#f   '())   ;the old format
+(x;unsupported format
+ (warning (_ "unrecognized boot parameters for '~a'~%")
+  system)
+ #f)))
+
 ;;; system.scm ends here
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 1407dc7..a45f07e 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -191,39 +191,6 @@ the ownership of '~a' may be incorrect!~%")
 
 
 ;;;
-;;; Boot parameters
-;;;
-
-(define-record-type* 
-  boot-parameters make-boot-parameters boot-parameters?
-  (labelboot-parameters-label)
-  (root-device  boot-parameters-root-device)
-  (kernel   boot-parameters-kernel)
-  (kernel-arguments boot-parameters-kernel-arguments))
-
-(define (read-boot-parameters port)
-  "Read boot parameters from PORT and return the corresponding
- object or #f if the format is unrecognized."
-  (match (read port)
-(('boot-parameters ('version 0)
-   ('label label) ('root-device root)
-   ('kernel linux)
-   rest ...)
- (boot-parameters
-  (label label)
-  (root-device root)
-  (kernel linux)
-  (kernel-arguments
-   (match (assq 'kernel-arguments rest)
- ((_ args) args)
- (#f   '())   ;the old format
-(x;unsupported format
- (warning (_ "unrecognized boot parameters for '~a'~%")
-  system)
- #f)))
-
-
-;;;
 ;;; Reconfiguration.
 ;;;
 
-- 
2.6.3



Re: [PATCH 1/6] guix system: Export accessors.

2016-01-12 Thread Ludovic Courtès
Alex Kost  skribis:

> * guix/scripts/system.scm (read-boot-parameters, boot-parameters)
> (boot-parameters?, boot-parameters-label, boot-parameters-root-device)
> (boot-parameters-kernel, boot-parameters-kernel-arguments): Export.

LGTM.

Eventually (as a replacement of this patch or as a subsequent patch, as
you prefer) we should move these to (gnu system) since this is where we
create the ‘boot-parameters’ sexp.

Thanks,
Ludo’.