summary refs log tree commit diff
path: root/nixos/modules/installer
diff options
context:
space:
mode:
authorAndrew Dunham <andrew@du.nham.ca>2018-07-06 20:59:19 -0700
committerTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>2018-07-12 17:02:03 +0300
commitd7bfd04301de8fb893c4ee85bcd9b0ece46836a4 (patch)
treeeac63f1b6cefc173e07c65791cc51362bd18088f /nixos/modules/installer
parent99670bbb9108732e562d802122bccce1953ab858 (diff)
downloadnixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.gz
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.bz2
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.lz
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.xz
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.zst
nixlib-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.zip
sdImage: make partition ID/UUID configurable
Diffstat (limited to 'nixos/modules/installer')
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix24
1 files changed, 22 insertions, 2 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index c091923de60f..311a5ff69670 100644
--- a/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -16,6 +16,8 @@ let
     inherit pkgs;
     inherit (config.sdImage) storePaths;
     volumeLabel = "NIXOS_SD";
+  } // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
+    uuid = config.sdImage.rootPartitionUUID;
   };
 in
 {
@@ -42,6 +44,24 @@ in
       '';
     };
 
+    bootPartitionID = mkOption {
+      type = types.string;
+      default = "0x2178694e";
+      description = ''
+        Volume ID for the /boot partition on the SD card. This value must be a
+        32-bit hexadecimal number.
+      '';
+    };
+
+    rootPartitionUUID = mkOption {
+      type = types.nullOr types.string;
+      default = null;
+      example = "14e19a7b-0ae0-484d-9d54-43bd6fdc20c7";
+      description = ''
+        UUID for the main NixOS partition on the SD card.
+      '';
+    };
+
     bootSize = mkOption {
       type = types.int;
       default = 120;
@@ -95,7 +115,7 @@ in
         # type=b is 'W95 FAT32', type=83 is 'Linux'.
         sfdisk $img <<EOF
             label: dos
-            label-id: 0x2178694e
+            label-id: ${config.sdImage.bootPartitionID}
 
             start=8M, size=$bootSizeBlocks, type=b, bootable
             start=${toString (8 + config.sdImage.bootSize)}M, type=83
@@ -108,7 +128,7 @@ in
         # Create a FAT32 /boot partition of suitable size into bootpart.img
         eval $(partx $img -o START,SECTORS --nr 1 --pairs)
         truncate -s $((SECTORS * 512)) bootpart.img
-        faketime "1970-01-01 00:00:00" mkfs.vfat -i 0x2178694e -n NIXOS_BOOT bootpart.img
+        faketime "1970-01-01 00:00:00" mkfs.vfat -i ${config.sdImage.bootPartitionID} -n NIXOS_BOOT bootpart.img
 
         # Populate the files intended for /boot
         mkdir boot