diff --git a/flake.nix b/flake.nix index 2282734..4f004d2 100644 --- a/flake.nix +++ b/flake.nix @@ -15,11 +15,49 @@ flake-utils.lib.eachDefaultSystem ( system: let - pkgs = import nixpkgs { inherit system; }; + pkgs = import nixpkgs { + inherit system; + }; in { packages = { default = self.packages.${system}.image; + + glibc = pkgs.stdenv.mkDerivation { + src = pkgs.fetchurl { + url = "mirror://gnu/glibc/glibc-2.40.tar.xz"; + sha256 = "sha256-GaiQF16SY9dI9ieZPeb0sa+c0h4D8IDkv7Oh+sECBaI="; + }; + name = "glibcStandalone"; + enableParallelBuilding = true; + configureFlags = [ + "--prefix=/" + "--libdir=/lib" + "--bindir=/bin" + "--sysconfdir=/etc" + ]; + preConfigure = + '' + export PWD_P=$(type -tP pwd) + for i in configure io/ftwtest-sh; do + sed -i "$i" -e "s^/bin/pwd^$PWD_P^g" + done + + mkdir ../build + cd ../build + + configureScript="`pwd`/../$sourceRoot/configure" + ''; + nativeBuildInputs = [ pkgs.bison pkgs.python3Minimal]; + + outputs = [ + "out" + ]; + preInstall = '' + export DESTDIR=${placeholder "out"} + ''; + }; + image = pkgs.writeShellScriptBin "image" '' echo "make UKI..." echo ${self.packages.${system}.kernel.kernel}/bzImage @@ -115,9 +153,11 @@ find . -type f -executable | xargs ldd | awk '{print $3}' | grep -v systemd | sort -u | xargs cp -t usr/lib find . -type f -executable | xargs chmod 755 - # hacky patch elf - find . -type f -executable -print | xargs -I {} ${pkgs.lib.getExe pkgs.patchelf} --set-rpath /lib:/lib64 {} 2> /dev/null + # FIXME: hacky patch elf patching. Is there a better way???????? + find . -type f -executable -print | xargs -I {} ${pkgs.lib.getExe pkgs.patchelf} --set-rpath /lib {} 2> /dev/null find . -type f -executable -print | xargs -I {} ${pkgs.lib.getExe pkgs.patchelf} --set-interpreter /lib/ld-linux-x86-64.so.2 {} 2> /dev/null + cp ${self.packages.${system}.glibc.out}/lib/ld-linux-x86-64.so.2 lib/ + ${pkgs.lib.getExe pkgs.patchelf} --remove-rpath lib/ld-linux-x86-64.so.2 # gen initrd find . -print0 | ${pkgs.lib.getExe pkgs.cpio} --null --owner=root:root -o --format=newc | ${pkgs.lib.getExe pkgs.gzip} -9 > ../initrd.gz