1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{ stdenv, fetchgit, busybox, squashfsTools, linuxHeaders }:
stdenv.mkDerivation {
name = "rootfs-yerba";
src = ./.;
buildInputs = [ squashfsTools ];
nativeBuildInputs = [ squashfsTools linuxHeaders ];
buildPhase = ''
mkdir -p rootfs
mkdir -p rootfs/{bin,sbin,etc,proc,sys,dev,home,var,usr,root,mnt,tmp}
cp -a ${busybox}/_install/. rootfs/
chmod -R u+w rootfs
ln -sf bin/busybox rootfs/init
ln -sf bin/busybox rootfs/sbin/init
# ln -sf sbin/init rootfs/init
echo "proc /proc proc defaults 0 0" > rootfs/etc/fstab
echo "sysfs /sys sysfs defaults 0 0" >> rootfs/etc/fstab
echo "devtmpfs /dev devtmpfs defaults 0 0" >> rootfs/etc/fstab
echo "::sysinit:/bin/mount -a" > rootfs/etc/inittab
echo "tty0::askfirst:/bin/sh" >> rootfs/etc/inittab
echo "ttyS0::askfirst:/bin/sh" >> rootfs/etc/inittab
echo "::ctrlaltdel:/sbin/reboot" >> rootfs/etc/inittab
echo "yerba-live" > rootfs/etc/hostname
mksquashfs rootfs $out -comp zstd -noappend
'';
installPhase = ''
echo "rootfs built"
'';
}
|