summary refs log tree commit diff
path: root/nixos
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
parent99670bbb9108732e562d802122bccce1953ab858 (diff)
downloadnixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.gz
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.bz2
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.lz
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.xz
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.tar.zst
nixpkgs-d7bfd04301de8fb893c4ee85bcd9b0ece46836a4.zip
sdImage: make partition ID/UUID configurable
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/make-ext4-fs.nix3
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image.nix24
2 files changed, 24 insertions, 3 deletions
diff --git a/nixos/lib/make-ext4-fs.nix b/nixos/lib/make-ext4-fs.nix
index 4095d9c6d00..35a8afae4a7 100644
--- a/nixos/lib/make-ext4-fs.nix
+++ b/nixos/lib/make-ext4-fs.nix
@@ -5,6 +5,7 @@
 { pkgs
 , storePaths
 , volumeLabel
+, uuid ? "44444444-4444-4444-8888-888888888888"
 }:
 
 let
@@ -32,7 +33,7 @@ pkgs.stdenv.mkDerivation {
       echo "Creating an EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)"
 
       truncate -s $bytes $out
-      faketime -f "1970-01-01 00:00:01" mkfs.ext4 -L ${volumeLabel} -U 44444444-4444-4444-8888-888888888888 $out
+      faketime -f "1970-01-01 00:00:01" mkfs.ext4 -L ${volumeLabel} -U ${uuid} $out
 
       # Populate the image contents by piping a bunch of commands to the `debugfs` tool from e2fsprogs.
       # For example, to copy /nix/store/abcd...efg-coreutils-8.23/bin/sleep:
diff --git a/nixos/modules/installer/cd-dvd/sd-image.nix b/nixos/modules/installer/cd-dvd/sd-image.nix
index c091923de60..311a5ff6967 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