commit d707345891b8b2efe40ba9d3805e10ee73d0ece5
parent 133b64613d4dda8df2f3d3885d66daf599d28324
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 11 Dec 2023 20:49:48 +0000
rename rootfsFiles to rootdir, add bootablerootdir
Diffstat:
4 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/modules/outputs.nix b/modules/outputs.nix
@@ -69,13 +69,22 @@ in
out what's in the image, which is nice if it's unexpectedly huge
'';
};
- rootfsFiles = mkOption {
+ rootdir = mkOption {
type = types.package;
internal = true;
description = ''
directory of files to package into root filesystem
'';
};
+ bootablerootdir = mkOption {
+ type = types.package;
+ internal = true;
+ description = ''
+ directory of files to package into root filesystem, including
+ a kernel and appropriate associated gubbins for the
+ selected bootloader
+ '';
+ };
rootfs = mkOption {
type = types.package;
internal = true;
@@ -108,7 +117,7 @@ in
inherit kernel;
inherit dtb;
};
- rootfsFiles =
+ rootdir =
let
inherit (pkgs.pkgsBuildBuild) runCommand;
in runCommand "mktree" { } ''
@@ -120,6 +129,15 @@ in
(cd $out && cp -a $path .$path)
done
'';
+ bootablerootdir =
+ let inherit (pkgs.pkgsBuildBuild) runCommand;
+ in runCommand "add-slash-boot" { } ''
+ cp -a ${o.rootdir} $out
+ ${if config.boot.loader.extlinux.enable
+ then "(cd $out && chmod -R +w . && rmdir boot && cp -a ${o.extlinux} boot)"
+ else ""
+ }
+ '';
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
};
};
diff --git a/modules/outputs/ext4fs.nix b/modules/outputs/ext4fs.nix
@@ -28,16 +28,12 @@ in
in runCommand "mkfs.ext4" {
depsBuildBuild = [ e2fsprogs ];
} ''
- cp -a ${o.rootfsFiles} tmp
- ${if config.boot.loader.extlinux.enable
- then "(cd tmp && chmod -R +w . && rmdir boot && cp -a ${o.extlinux} boot)"
- else ""
- }
- size=$(du -s --apparent-size --block-size 1024 tmp |cut -f1)
+ tree=${o.bootablerootdir}
+ size=$(du -s --apparent-size --block-size 1024 $tree |cut -f1)
# add 25% for filesystem overhead
size=$(( 5 * $size / 4))
dd if=/dev/zero of=$out bs=1024 count=$size
- mke2fs -t ext4 -j -d tmp $out
+ mke2fs -t ext4 -j -d $tree $out
'';
};
};
diff --git a/modules/outputs/jffs2.nix b/modules/outputs/jffs2.nix
@@ -34,12 +34,8 @@ in
in runCommand "make-jffs2" {
depsBuildBuild = [ mtdutils ];
} ''
- cp -a ${o.rootfsFiles} tmp
- ${if config.boot.loader.extlinux.enable
- then "(cd tmp && ln -s ${o.extlinux} boot)"
- else ""
- }
- (cd tmp && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime )
+ tree=${o.bootablerootdir}
+ (cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime )
'';
};
};
diff --git a/modules/outputs/ubifs.nix b/modules/outputs/ubifs.nix
@@ -36,12 +36,8 @@ in
depsBuildBuild = [ mtdutils ];
} ''
mkdir tmp
- cp -a ${o.rootfsFiles} tmp
- ${if config.boot.loader.extlinux.enable
- then "(cd tmp && ln -s ${o.extlinux} boot)"
- else ""
- }
- mkfs.ubifs -x favor_lzo -c ${cfg.maxLEBcount} -m ${cfg.minIOSize} -e ${cfg.eraseBlockSize} -y -r tmp --output $out --squash-uids -o $out
+ tree=${o.bootablerootdir}
+ mkfs.ubifs -x favor_lzo -c ${cfg.maxLEBcount} -m ${cfg.minIOSize} -e ${cfg.eraseBlockSize} -y -r $tree --output $out --squash-uids -o $out
'';
};
};