| 
									
										
										
										
											2006-11-02 17:56:50 +00:00
										 |  |  | source $stdenv/setup | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-23 13:44:41 +00:00
										 |  |  | sources_=($sources) | 
					
						
							|  |  |  | targets_=($targets) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | objects=($objects) | 
					
						
							|  |  |  | symlinks=($symlinks) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Remove the initial slash from a path, since genisofs likes it that way. | 
					
						
							|  |  |  | stripSlash() { | 
					
						
							|  |  |  |     res="$1" | 
					
						
							|  |  |  |     if test "${res:0:1}" = /; then res=${res:1}; fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  | # Escape potential equal signs (=) with backslash (\=) | 
					
						
							|  |  |  | escapeEquals() { | 
					
						
							|  |  |  |     echo "$1" | sed -e 's/\\/\\\\/g' -e 's/=/\\=/g' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Queues an file/directory to be placed on the ISO. | 
					
						
							|  |  |  | # An entry consists of a local source path (2) and | 
					
						
							|  |  |  | # a destination path on the ISO (1). | 
					
						
							|  |  |  | addPath() { | 
					
						
							|  |  |  |     target="$1" | 
					
						
							|  |  |  |     source="$2" | 
					
						
							|  |  |  |     echo "$(escapeEquals "$target")=$(escapeEquals "$source")" >> pathlist | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  | stripSlash "$bootImage"; bootImage="$res" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-11-02 17:56:50 +00:00
										 |  |  | if test -n "$bootable"; then | 
					
						
							| 
									
										
										
										
											2007-02-07 15:23:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # The -boot-info-table option modifies the $bootImage file, so | 
					
						
							|  |  |  |     # find it in `contents' and make a copy of it (since the original | 
					
						
							|  |  |  |     # is read-only in the Nix store...). | 
					
						
							|  |  |  |     for ((i = 0; i < ${#targets_[@]}; i++)); do | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  |         stripSlash "${targets_[$i]}" | 
					
						
							|  |  |  |         if test "$res" = "$bootImage"; then | 
					
						
							| 
									
										
										
										
											2007-02-07 15:23:19 +00:00
										 |  |  |             echo "copying the boot image ${sources_[$i]}" | 
					
						
							|  |  |  |             cp "${sources_[$i]}" boot.img | 
					
						
							|  |  |  |             chmod u+w boot.img | 
					
						
							|  |  |  |             sources_[$i]=boot.img | 
					
						
							|  |  |  |         fi | 
					
						
							|  |  |  |     done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  |     isoBootFlags="-eltorito-boot ${bootImage}
 | 
					
						
							|  |  |  |                   -eltorito-catalog .boot.cat | 
					
						
							| 
									
										
										
										
											2018-12-02 00:34:58 -05:00
										 |  |  |                   -no-emul-boot -boot-load-size 4 -boot-info-table | 
					
						
							|  |  |  |                   --sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
 | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if test -n "$usbBootable"; then | 
					
						
							|  |  |  |     usbBootFlags="-isohybrid-mbr ${isohybridMbrImage}" | 
					
						
							| 
									
										
										
										
											2006-11-02 17:56:50 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-16 05:37:24 +00:00
										 |  |  | if test -n "$efiBootable"; then | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  |     efiBootFlags="-eltorito-alt-boot
 | 
					
						
							|  |  |  |                   -e $efiBootImage | 
					
						
							|  |  |  |                   -no-emul-boot | 
					
						
							|  |  |  |                   -isohybrid-gpt-basdat"
 | 
					
						
							| 
									
										
										
										
											2012-03-16 05:37:24 +00:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-15 15:39:34 +00:00
										 |  |  | touch pathlist | 
					
						
							| 
									
										
										
										
											2007-01-23 13:44:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-23 14:34:44 +00:00
										 |  |  | # Add the individual files. | 
					
						
							| 
									
										
										
										
											2006-11-03 23:41:57 +00:00
										 |  |  | for ((i = 0; i < ${#targets_[@]}; i++)); do | 
					
						
							| 
									
										
										
										
											2009-06-09 12:01:31 +00:00
										 |  |  |     stripSlash "${targets_[$i]}" | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  |     addPath "$res" "${sources_[$i]}" | 
					
						
							| 
									
										
										
										
											2006-11-03 23:41:57 +00:00
										 |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-23 14:34:44 +00:00
										 |  |  | # Add the closures of the top-level store objects. | 
					
						
							| 
									
										
										
										
											2018-02-07 16:50:47 +01:00
										 |  |  | for i in $(< $closureInfo/store-paths); do | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  |     addPath "${i:1}" "$i" | 
					
						
							| 
									
										
										
										
											2007-01-23 14:34:44 +00:00
										 |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-10 13:40:35 +00:00
										 |  |  | # Also include a manifest of the closures in a format suitable for | 
					
						
							|  |  |  | # nix-store --load-db. | 
					
						
							| 
									
										
										
										
											2018-02-07 16:50:47 +01:00
										 |  |  | if [[ ${#objects[*]} != 0 ]]; then | 
					
						
							|  |  |  |     cp $closureInfo/registration nix-path-registration | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  |     addPath "nix-path-registration" "nix-path-registration" | 
					
						
							| 
									
										
										
										
											2010-05-28 06:27:31 +00:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2007-01-23 15:08:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-23 14:34:44 +00:00
										 |  |  | # Add symlinks to the top-level store objects. | 
					
						
							| 
									
										
										
										
											2007-01-23 13:44:41 +00:00
										 |  |  | for ((n = 0; n < ${#objects[*]}; n++)); do | 
					
						
							|  |  |  |     object=${objects[$n]} | 
					
						
							|  |  |  |     symlink=${symlinks[$n]} | 
					
						
							|  |  |  |     if test "$symlink" != "none"; then | 
					
						
							|  |  |  |         mkdir -p $(dirname ./$symlink) | 
					
						
							|  |  |  |         ln -s $object ./$symlink | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  |         addPath "$symlink" "./$symlink" | 
					
						
							| 
									
										
										
										
											2007-01-23 13:44:41 +00:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2006-11-03 23:41:57 +00:00
										 |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-30 14:56:10 +02:00
										 |  |  | mkdir -p $out/iso | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-25 18:33:33 +01:00
										 |  |  | # daed2280-b91e-42c0-aed6-82c825ca41f3 is an arbitrary namespace, to prevent | 
					
						
							|  |  |  | # independent applications from generating the same UUID for the same value. | 
					
						
							|  |  |  | # (the chance of that being problematic seem pretty slim here, but that's how | 
					
						
							|  |  |  | # version-5 UUID's work) | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  | xorriso="xorriso
 | 
					
						
							| 
									
										
										
										
											2019-11-25 18:33:33 +01:00
										 |  |  |  -boot_image any gpt_disk_guid=$(uuid -v 5 daed2280-b91e-42c0-aed6-82c825ca41f3 $out | tr -d -) | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  |  -as mkisofs | 
					
						
							|  |  |  |  -iso-level 3 | 
					
						
							|  |  |  |  -volid ${volumeID} | 
					
						
							|  |  |  |  -appid nixos | 
					
						
							|  |  |  |  -publisher nixos | 
					
						
							|  |  |  |  -graft-points | 
					
						
							|  |  |  |  -full-iso9660-filenames | 
					
						
							| 
									
										
										
										
											2020-04-09 20:06:32 -04:00
										 |  |  |  -joliet | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  |  ${isoBootFlags} | 
					
						
							|  |  |  |  ${usbBootFlags} | 
					
						
							|  |  |  |  ${efiBootFlags} | 
					
						
							|  |  |  |  -r | 
					
						
							| 
									
										
										
										
											2014-10-26 22:47:15 +01:00
										 |  |  |  -path-list pathlist | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  |  --sort-weight 0 / | 
					
						
							| 
									
										
										
										
											2018-12-02 00:34:58 -05:00
										 |  |  | "
 | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | $xorriso -output $out/iso/$isoName | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if test -n "$compressImage"; then | 
					
						
							|  |  |  |     echo "Compressing image..." | 
					
						
							| 
									
										
										
										
											2020-06-14 00:19:11 +02:00
										 |  |  |     zstd -T$NIX_BUILD_CORES --rm $out/iso/$isoName | 
					
						
							| 
									
										
										
										
											2014-10-26 21:29:04 +01:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2006-11-04 12:00:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-30 14:56:10 +02:00
										 |  |  | mkdir -p $out/nix-support | 
					
						
							| 
									
										
										
										
											2006-11-04 12:00:05 +00:00
										 |  |  | echo $system > $out/nix-support/system | 
					
						
							| 
									
										
										
										
											2020-04-24 18:12:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if test -n "$compressImage"; then | 
					
						
							|  |  |  |     echo "file iso $out/iso/$isoName.zst" >> $out/nix-support/hydra-build-products | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |     echo "file iso $out/iso/$isoName" >> $out/nix-support/hydra-build-products | 
					
						
							|  |  |  | fi |