From: Saku Laesvuori <saku@laesvuori.fi>
To: Felix Lechner <felix.lechner@lease-up.com>
Cc: guix-devel@gnu.org
Subject: Re: Type of 'os' in gnu/system.scm
Date: Tue, 12 Dec 2023 09:44:20 +0200 [thread overview]
Message-ID: <uxz5egyad5kf66k2tgxu4rfvq7x5fd2tix4pvsflchqe3gjuin@6kcxiqtqobv3> (raw)
In-Reply-To: <87h6kob7bk.fsf@lease-up.com>
[-- Attachment #1: Type: text/plain, Size: 3005 bytes --]
> Hi,
>
> Looking at this definition in gnu/system.scm [1] I am trying to figure
> out what 'os' is:
>
> (define* (operating-system-kernel-arguments
> os root-device #:key (version %boot-parameters-version))
> "Return all the kernel arguments, including the ones not specified directly
> by the user. VERSION should match that of the target <boot-parameters> record
> object that will contain the kernel parameters."
> (append (bootable-kernel-arguments os root-device version)
> (operating-system-user-kernel-arguments os)))
>
> The same file also contains a record definition for <operating-system>
> so it seemed reasonable to assume that 'os' referred to such a
> record. In fact, the second procedure inside the 'append' above,
> operating-system-user-kernel-arguments, is one of the accessors [2]
> (even though the name does not match the field).
Yes, it is supposed to be an <operating-system> record (of course,
scheme does not enforce that in any way and it may end up being any
other type during runtime if there is a bug in some other code).
> In the first procedure bootable-kernel-arguments [3] however, 'os'
> (which is called 'system' there) is used like a string, although inside
> a gexp:
>
> (define* (bootable-kernel-arguments system root-device version)
> "Return a list of kernel arguments (gexps) to boot SYSTEM from ROOT-DEVICE.
> VERSION is the target version of the boot-parameters record."
> ;; If the version is newer than 0, we use the new style initrd parameter
> ;; names, otherwise we use the legacy ones. This is to maintain backward
> ;; compatibility when producing bootloader configurations for older
> ;; generations.
> (define version>0? (> version 0))
> (list (string-append (if version>0? "root=" "--root=")
> ;; Note: Always use the DCE format because that's what
> ;; (gnu build linux-boot) expects for the 'root'
> ;; kernel command-line option.
> (file-system-device->string root-device
> #:uuid-type 'dce))
> #~(string-append (if #$version>0? "gnu.system=" "--system=") #$system)
> #~(string-append (if #$version>0? "gnu.load=" "--load=")
> #$system "/boot")))
>
> I know objects in the store become paths when unquoted via '#$'. Does
> that also work for Guix records declared via define-record-type* [4]
> (please note the asterisk)? Thanks!
The <operating-system> record is expanded to a store path because there
is a (define-gexp-compiler ...) form for it in gnu/system.scm[1]. The
gexp expansion mechanism is explained quite well in a "Dissecting Guix"
blog post[2].
[1]: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system.scm#n1623
[2]: https://guix.gnu.org/en/blog/2023/dissecting-guix-part-3-g-expressions/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2023-12-12 7:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 0:19 Type of 'os' in gnu/system.scm Felix Lechner via Development of GNU Guix and the GNU System distribution.
2023-12-12 7:44 ` Saku Laesvuori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uxz5egyad5kf66k2tgxu4rfvq7x5fd2tix4pvsflchqe3gjuin@6kcxiqtqobv3 \
--to=saku@laesvuori.fi \
--cc=felix.lechner@lease-up.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).