Subject: bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags.

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 08 May 2017 08:55:56 -0700

Hello Marius,

Marius Bakke <[email-masked]> writes:

> * gnu/build/vm.scm (<partition>): Change BOOTABLE? to FLAGS.
> (initialize-partition-table): Pass each flag to parted.
> (initialize-hard-disk): Search for root partition by "boot" flag.
> * gnu/system/vm.scm (qemu-image): Adjust partitions accordingly.
> ---
>  gnu/build/vm.scm  | 18 +++++++++++++-----
>  gnu/system/vm.scm |  2 +-
>  2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
> index 440596a40..3286ffb02 100644
> --- a/gnu/build/vm.scm
> +++ b/gnu/build/vm.scm
> @@ -3,6 +3,7 @@
>  ;;; Copyright © 2016 Christopher Allan Webber <[email-masked]>
>  ;;; Copyright © 2016 Leo Famulari <[email-masked]>
>  ;;; Copyright © 2017 Mathieu Othacehe <[email-masked]>
> +;;; Copyright © 2017 Marius Bakke <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -41,7 +42,7 @@
>              partition-size
>              partition-file-system
>              partition-label
> -            partition-bootable?
> +            partition-flags
>              partition-initializer
>  
>              root-partition-initializer
> @@ -141,7 +142,7 @@ the #:references-graphs parameter of 'derivation'."
>    (size        partition-size)
>    (file-system partition-file-system (default "ext4"))
>    (label       partition-label (default #f))
> -  (bootable?   partition-bootable? (default #f))
> +  (flags       partition-flags (default '()))
>    (initializer partition-initializer (default (const #t))))
>  
>  (define (fold2 proc seed1 seed2 lst)              ;TODO: factorize
> @@ -168,9 +169,11 @@ actual /dev name based on DEVICE."
>      (cons* "mkpart" "primary" "ext2"
>             (format #f "~aB" offset)
>             (format #f "~aB" (+ offset (partition-size part)))
> -           (if (partition-bootable? part)
> -               `("set" ,(number->string index) "boot" "on")
> -               '())))
> +           (apply append (map (lambda (flag)

I think you could replace the 'apply, append, map' by `map-append' here.

> +                                (cons* "set" (number->string index)
> +                                       (symbol->string flag)
> +                                       "on" '()))
> +                              (partition-flags part)))))

Maxim