aboutsummaryrefslogtreecommitdiff
path: root/nix/rootfs.nix
blob: 9bea6db948ef147d423edae5becd75c9dfc1f694 (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
26
27
28
29
{ 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 "::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"
	'';
}