diff options
| author | Arslaan Pathan <[email protected]> | 2026-06-10 19:28:49 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-06-10 19:28:49 +1200 |
| commit | 068e16881ac47040e31b65d1ba5d4ed64067166d (patch) | |
| tree | d9adbcd85b12fd3d358d54bf5d7f503ea21ac94f | |
| parent | e0cfbaa7e901b4ef91b75bee0046a1999436c39d (diff) | |
| download | yerbalinux-068e16881ac47040e31b65d1ba5d4ed64067166d.tar.xz yerbalinux-068e16881ac47040e31b65d1ba5d4ed64067166d.zip | |
tcc
| -rw-r--r-- | flake.nix | 8 | ||||
| -rw-r--r-- | nix/rootfs.nix | 37 | ||||
| -rw-r--r-- | nix/tcc.nix | 29 |
3 files changed, 67 insertions, 7 deletions
@@ -7,6 +7,7 @@ system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; pkgsStatic = nixpkgs.legacyPackages.${system}.pkgsStatic; + pkgsMusl = nixpkgs.legacyPackages.${system}.pkgsMusl; in { devShells.${system}.default = pkgs.mkShell { buildInputs = with pkgs; [ gcc clang gnumake xorriso cpio ]; @@ -17,12 +18,17 @@ busybox = pkgs.callPackage ./nix/busybox.nix { inherit (pkgs) pkgsStatic; }; + tcc = pkgs.callPackage ./nix/tcc.nix { + inherit (pkgsMusl) musl; + inherit (pkgs) linuxHeaders; + }; limine = pkgs.callPackage ./nix/limine.nix {}; initramfs = pkgs.callPackage ./nix/initramfs.nix { inherit (self.packages.${system}) kernel busybox; }; rootfs = pkgs.callPackage ./nix/rootfs.nix { - inherit (self.packages.${system}) busybox; + inherit (self.packages.${system}) busybox tcc; + inherit (pkgsMusl) musl; }; iso = pkgs.callPackage ./nix/iso.nix { inherit (self.packages.${system}) kernel limine initramfs rootfs; 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" diff --git a/nix/tcc.nix b/nix/tcc.nix new file mode 100644 index 0000000..cd4cf27 --- /dev/null +++ b/nix/tcc.nix @@ -0,0 +1,29 @@ +{ stdenv, fetchgit, musl, linuxHeaders }: + +stdenv.mkDerivation { + name = "tcc-yerba"; + src = fetchgit { + url = "https://repo.or.cz/tinycc.git"; + rev = "34eed88a"; + hash = "nix will yell at me but then i fix it"; + }; + + configureFlags = [ + "--cc=gcc" + "--ar=ar" + "--config-musl" + "--crtprefix=${musl}/lib" + "--sysincludepaths=${linuxHeaders}/include:{B}/include" + "--libpaths=${musl}/lib" + ]; + + buildPhase = '' + make -j$NIX_BUILD_CORES + ''; + + installPhase = '' + mkdir -p $out/bin $out/lib + cp tcc $out/bin/ + cp libtcc.a $out/lib/ 2>/dev/null || true + ''; +} |
