forked from DGNum/liminix
add ext4 as rootfsType
This commit is contained in:
parent
6bbff2f5b3
commit
a9d847e2c0
6 changed files with 102 additions and 2 deletions
|
@ -39,7 +39,12 @@ in {
|
||||||
};
|
};
|
||||||
rootfsType = mkOption {
|
rootfsType = mkOption {
|
||||||
default = "squashfs";
|
default = "squashfs";
|
||||||
type = types.enum ["squashfs" "jffs2" "ubifs"];
|
type = types.enum [
|
||||||
|
"ext4"
|
||||||
|
"jffs2"
|
||||||
|
"squashfs"
|
||||||
|
"ubifs"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
boot = {
|
boot = {
|
||||||
commandLine = mkOption {
|
commandLine = mkOption {
|
||||||
|
|
45
modules/ext4fs.nix
Normal file
45
modules/ext4fs.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
config
|
||||||
|
, pkgs
|
||||||
|
, lib
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf mkOption types;
|
||||||
|
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 = rec {
|
||||||
|
systemConfiguration =
|
||||||
|
pkgs.systemconfig config.filesystem.contents;
|
||||||
|
rootfs =
|
||||||
|
let
|
||||||
|
inherit (pkgs.pkgsBuildBuild) runCommand e2fsprogs;
|
||||||
|
in runCommand "mkfs.ext4" {
|
||||||
|
depsBuildBuild = [ e2fsprogs ];
|
||||||
|
} ''
|
||||||
|
mkdir -p $TMPDIR/empty/nix/store/ $TMPDIR/empty/secrets
|
||||||
|
cp ${systemConfiguration}/bin/activate $TMPDIR/empty/activate
|
||||||
|
ln -s ${pkgs.s6-init-bin}/bin/init $TMPDIR/empty/init
|
||||||
|
mkdir -p $TMPDIR/empty/nix/store
|
||||||
|
for path in $(cat ${systemConfiguration}/etc/nix-store-paths) ; do
|
||||||
|
(cd $TMPDIR/empty && cp -a $path .$path)
|
||||||
|
done
|
||||||
|
size=$(du -s --apparent-size --block-size 1024 $TMPDIR/empty |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 $TMPDIR/empty $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
wlan = import ./wlan/test.nix;
|
wlan = import ./wlan/test.nix;
|
||||||
pppoe = import ./pppoe/test.nix;
|
pppoe = import ./pppoe/test.nix;
|
||||||
jffs2 = import ./jffs2/test.nix;
|
jffs2 = import ./jffs2/test.nix;
|
||||||
|
ext4 = import ./ext4/test.nix;
|
||||||
min-copy-closure = import ./min-copy-closure/test.nix;
|
min-copy-closure = import ./min-copy-closure/test.nix;
|
||||||
fennel = import ./fennel/test.nix;
|
fennel = import ./fennel/test.nix;
|
||||||
}
|
}
|
||||||
|
|
19
tests/ext4/configuration.nix
Normal file
19
tests/ext4/configuration.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ config, pkgs, lib, ... } :
|
||||||
|
let
|
||||||
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
|
in {
|
||||||
|
imports = [
|
||||||
|
../../vanilla-configuration.nix
|
||||||
|
../../modules/squashfs.nix
|
||||||
|
../../modules/ext4fs.nix
|
||||||
|
];
|
||||||
|
config.rootfsType = "ext4";
|
||||||
|
config.filesystem = dir {
|
||||||
|
hello = {
|
||||||
|
type = "f";
|
||||||
|
uid = 7;
|
||||||
|
gid = 24;
|
||||||
|
file = "hello world";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
11
tests/ext4/script.expect
Normal file
11
tests/ext4/script.expect
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
set timeout 10
|
||||||
|
|
||||||
|
spawn socat unix-connect:vm/console -
|
||||||
|
send "\r\n"
|
||||||
|
expect "login:" { send "root\r\n" }
|
||||||
|
expect "#"
|
||||||
|
send "echo HELLO WORLD > /hello\r\n"
|
||||||
|
expect "#"
|
||||||
|
send "cat /hello\r\n"
|
||||||
|
expect 'HELLO WORLD'
|
||||||
|
close
|
19
tests/ext4/test.nix
Normal file
19
tests/ext4/test.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
liminix
|
||||||
|
, nixpkgs
|
||||||
|
}:
|
||||||
|
let img = (import liminix {
|
||||||
|
device = import "${liminix}/devices/qemu/";
|
||||||
|
liminix-config = ./configuration.nix;
|
||||||
|
}).outputs.vmroot;
|
||||||
|
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
||||||
|
in pkgs.runCommand "check" {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
expect
|
||||||
|
socat
|
||||||
|
] ;
|
||||||
|
} ''
|
||||||
|
mkdir vm
|
||||||
|
${img}/run.sh --background ./vm
|
||||||
|
expect ${./script.expect} >$out
|
||||||
|
''
|
Loading…
Reference in a new issue