aboutsummaryrefslogtreecommitdiff
path: root/nix/rootfs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/rootfs.nix')
-rw-r--r--nix/rootfs.nix37
1 files changed, 31 insertions, 6 deletions
diff --git a/nix/rootfs.nix b/nix/rootfs.nix
index b6a8a41..3f64eaa 100644
--- a/nix/rootfs.nix
+++ b/nix/rootfs.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, busybox, squashfsTools, linuxHeaders }:
+{ stdenv, fetchgit, busybox, tcc, squashfsTools, linuxHeaders, musl }:
stdenv.mkDerivation {
name = "rootfs-yerba";
@@ -6,14 +6,35 @@ stdenv.mkDerivation {
buildInputs = [ squashfsTools ];
nativeBuildInputs = [ squashfsTools linuxHeaders ];
buildPhase = ''
+ # Basic setup start
mkdir -p rootfs
- mkdir -p rootfs/{bin,sbin,etc,proc,sys,dev,home,var,usr,root,mnt,tmp}
- cp -a ${busybox}/_install/. rootfs/
+ mkdir -p rootfs/{bin,sbin,etc,proc,sys,dev,home,var,usr,root,mnt,tmp,lib}
+ mkdir -p rootfs/usr/{lib,bin}
chmod -R u+w rootfs
+ # Basic setup end
- ln -sf bin/busybox rootfs/init
- ln -sf bin/busybox rootfs/sbin/init
- # ln -sf sbin/init rootfs/init
+ # Musl start
+ cp -a ${musl}/lib/* rootfs/usr/lib/
+ chmod -R u+w rootfs
+ ln -sf /usr/lib/ld-musl-x86_64.so.1 rootfs/lib/ld-musl-x86_64.so.1
+ chmod -R u+w rootfs
+ ln -sf /usr/lib/libc.so rootfs/lib/libc.so
+ # Musl end
+
+ # Busybox start
+ cp -a ${busybox}/_install/. rootfs/
+ chmod -R u+w rootfs
+ ln -sf /bin/busybox rootfs/init
+ # Busybox end
+
+ # Programs start
+ cp -a ${tcc}/bin/* rootfs/usr/bin/ 2>/dev/null || true
+ cp -a ${tcc}/lib/* rootfs/usr/lib/ 2>/dev/null || true
+ chmod -R u+w rootfs
+ ln -sf /usr/bin/tcc rootfs/usr/bin/cc
+ # Programs end
+
+ # Basic files setup start
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
@@ -22,7 +43,11 @@ stdenv.mkDerivation {
echo "ttyS0::askfirst:/bin/sh" >> rootfs/etc/inittab
echo "::ctrlaltdel:/sbin/reboot" >> rootfs/etc/inittab
echo "yerba-live" > rootfs/etc/hostname
+ # Basic files setup end
+
+ # Squashfs start
mksquashfs rootfs $out -comp zstd -noappend
+ # Squashfs end
'';
installPhase = ''
echo "rootfs built"