move output module imports example -> device
The outputs available are a characteristic of the device, not the example.
This commit is contained in:
44
modules/outputs/ext4fs.nix
Normal file
44
modules/outputs/ext4fs.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf mkOption types;
|
||||
o = config.system.outputs;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./initramfs.nix
|
||||
];
|
||||
config = mkIf (config.rootfsType == "ext4") {
|
||||
kernel.config = {
|
||||
EXT4_FS = "y";
|
||||
EXT4_USE_FOR_EXT2 = "y";
|
||||
FS_ENCRYPTION = "y";
|
||||
};
|
||||
boot.initramfs.enable = true;
|
||||
system.outputs = {
|
||||
systemConfiguration =
|
||||
pkgs.systemconfig config.filesystem.contents;
|
||||
rootfs =
|
||||
let
|
||||
inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs;
|
||||
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)
|
||||
# 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
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user