Hi! Maxim Cournoyer <maxim.courno...@gmail.com> skribis:
> This version field exposes the (already present) version information of a boot > parameters file. > > * gnu/system.scm (%boot-parameters-version): New variable. > (<boot-parameters>)[version]: New field. > (read-boot-parameters): Use it. > (operating-system-boot-parameters-file): Likewise. > * tests/boot-parameters.scm (test-read-boot-parameters): Use > %boot-parameters-version as the default version value in the template. [...] > (define-record-type* <boot-parameters> > boot-parameters make-boot-parameters boot-parameters? > (label boot-parameters-label) > @@ -322,7 +326,9 @@ (define-record-type* <boot-parameters> > (kernel boot-parameters-kernel) > (kernel-arguments boot-parameters-kernel-arguments) > (initrd boot-parameters-initrd) > - (multiboot-modules boot-parameters-multiboot-modules)) > + (multiboot-modules boot-parameters-multiboot-modules) > + (version boot-parameters-version ;positive integer > + (default %boot-parameters-version))) [...] > (match (read port) > - (('boot-parameters ('version 0) > + (('boot-parameters ('version (? version? version)) > ('label label) ('root-device root) > ('kernel kernel) > rest ...) > (boot-parameters > + (version version) > (label label) > (root-device (device-sexp->device root)) There’s no need to have a ‘version’ field in live <boot-parameters> records: have the ‘version’ field in the serialized format (the sexp) and make sure the deserializer correctly converts to the internal representation. Here, I think you can bump the version number in the serialized form, and have ‘read-boot-parameters’ automatically augment ‘kernel-arguments’ when VERSION is 0 with “--root=XYZ”. (It might be that you can even do that without bumping the version number. Bumping is clearer but the downside is that an older Guix will abort when attempting to read ‘parameters’. This could happen if you roll back to an earlier generation and try to run ‘guix system reconfigure’ or similar from there.) Also, you could write the ‘match’ pattern like this: ('boot-parameters ('version (and version (or 0 1))) ('label label) …) I hope that makes sense! Ludo’.