at 24.11-pre 2.9 kB view raw
1{ lib, stdenv, callPackage, closureInfo, xorriso, syslinux, libossp_uuid, squashfsTools 2 3, # The file name of the resulting ISO image. 4 isoName ? "cd.iso" 5 6, # The files and directories to be placed in the ISO file system. 7 # This is a list of attribute sets {source, target} where `source' 8 # is the file system object (regular file or directory) to be 9 # grafted in the file system at path `target'. 10 contents 11 12, # In addition to `contents', the closure of the store paths listed 13 # in `storeContents' are also placed in the Nix store of the CD. 14 # This is a list of attribute sets {object, symlink} where `object' 15 # is a store path whose closure will be copied, and `symlink' is a 16 # symlink to `object' that will be added to the CD. 17 storeContents ? [] 18 19, # In addition to `contents', the closure of the store paths listed 20 # in `squashfsContents' is compressed as squashfs and the result is 21 # placed in /nix-store.squashfs on the CD. 22 # FIXME: This is a performance optimization to avoid Hydra copying 23 # the squashfs between builders and should be removed when Hydra 24 # is smarter about scheduling. 25 squashfsContents ? [] 26 27, # Compression settings for squashfs 28 squashfsCompression ? "xz -Xdict-size 100%" 29 30, # Whether this should be an El-Torito bootable CD. 31 bootable ? false 32 33, # Whether this should be an efi-bootable El-Torito CD. 34 efiBootable ? false 35 36, # Whether this should be an hybrid CD (bootable from USB as well as CD). 37 usbBootable ? false 38 39, # The path (in the ISO file system) of the boot image. 40 bootImage ? "" 41 42, # The path (in the ISO file system) of the efi boot image. 43 efiBootImage ? "" 44 45, # The path (outside the ISO file system) of the isohybrid-mbr image. 46 isohybridMbrImage ? "" 47 48, # Whether to compress the resulting ISO image with zstd. 49 compressImage ? false, zstd 50 51, # The volume ID. 52 volumeID ? "" 53}: 54 55assert bootable -> bootImage != ""; 56assert efiBootable -> efiBootImage != ""; 57assert usbBootable -> isohybridMbrImage != ""; 58 59let 60 needSquashfs = squashfsContents != []; 61 makeSquashfsDrv = callPackage ./make-squashfs.nix { 62 storeContents = squashfsContents; 63 comp = squashfsCompression; 64 }; 65in 66stdenv.mkDerivation { 67 name = isoName; 68 __structuredAttrs = true; 69 70 buildCommandPath = ./make-iso9660-image.sh; 71 nativeBuildInputs = [ xorriso syslinux zstd libossp_uuid ] 72 ++ lib.optionals needSquashfs makeSquashfsDrv.nativeBuildInputs; 73 74 inherit isoName bootable bootImage compressImage volumeID efiBootImage efiBootable isohybridMbrImage usbBootable; 75 76 sources = map (x: x.source) contents; 77 targets = map (x: x.target) contents; 78 79 objects = map (x: x.object) storeContents; 80 symlinks = map (x: x.symlink) storeContents; 81 82 squashfsCommand = lib.optionalString needSquashfs makeSquashfsDrv.buildCommand; 83 84 # For obtaining the closure of `storeContents'. 85 closureInfo = closureInfo { rootPaths = map (x: x.object) storeContents; }; 86}