mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-17 13:10:29 +03:00
e008cb416c
In addition, present the sector size as an option. The sector size is required to set a block size in bytes, so giving the option to the end-user is probably for the best. The values here were chosen to keep the builder compatible with the existing tests. In addition, the values are quite optimized for smaller filesystem images, e.g. building a FIRMWARE partition for the Raspberry Pi.
52 lines
1.1 KiB
Nix
52 lines
1.1 KiB
Nix
{ imageBuilder, dosfstools, mtools, libfaketime}:
|
|
|
|
/* */ let scope = { "fileSystem.makeFAT32" =
|
|
|
|
let
|
|
inherit (imageBuilder) makeFilesystem;
|
|
in
|
|
{ partitionID
|
|
# These defaults are assuming small~ish FAT32 filesystems are generated.
|
|
, blockSize ? 512
|
|
, sectorSize ? 512
|
|
, ... } @ args:
|
|
makeFilesystem (args // {
|
|
# FAT32 can be used for ESP. Let's make this obvious.
|
|
filesystemType = if args ? filesystemType then args.filesystemType else "FAT32";
|
|
|
|
inherit blockSize;
|
|
minimumSize = imageBuilder.size.KiB 500;
|
|
|
|
nativeBuildInputs = [
|
|
libfaketime
|
|
dosfstools
|
|
mtools
|
|
];
|
|
|
|
filesystemPhase = ''
|
|
faketime -f "1970-01-01 00:00:00" mkfs.vfat \
|
|
-s ${toString (blockSize / sectorSize)} \
|
|
-S ${toString sectorSize} \
|
|
-F 32 \
|
|
-i $partitionID \
|
|
-n $partName \
|
|
"$img"
|
|
'';
|
|
|
|
copyPhase = ''
|
|
for f in ./* ./.*; do
|
|
if [[ "$f" != "./." && "$f" != "./.." ]]; then
|
|
faketime -f "1970-01-01 00:00:00" \
|
|
mcopy -psv -i "$img" "$f" ::
|
|
fi
|
|
done
|
|
'';
|
|
|
|
checkPhase = ''
|
|
# Always verify FS
|
|
fsck.vfat -vn "$img"
|
|
'';
|
|
})
|
|
|
|
/* */ ;}; in scope."fileSystem.makeFAT32"
|