aboutsummaryrefslogtreecommitdiff
path: root/nix/rootfs.nix
blob: fc5d3214a279bf1f62e4d661aea32559cf8f87a9 (plain)
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
{ stdenv, fetchgit, busybox, squashfsTools }:

stdenv.mkDerivation {
	name = "rootfs-yerba";
	src = ./.;
	buildInputs = [ squashfsTools ];
	nativeBuildInputs = [ squashfsTools ];
	buildPhase = ''
		mkdir -p rootfs 
		mkdir -p rootfs/{bin,sbin,etc,proc,sys,dev,home,var,usr,root,mnt,tmp}
		cp -a ${busybox}/_install/. rootfs/
		# this says permission denied, cant be bothered to debug, let's just hope we can chroot to /sbin/init in the initramfs and it works?
		# 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 "::askfirst:/bin/sh" >> rootfs/etc/inittab 
		echo "::ctrlaltdel:/sbin/reboot" >> rootfs/etc/inittab
		mksquashfs rootfs $out -comp zstd -noappend
	'';
	installPhase = ''
		echo "rootfs built"
	'';
}