Development environment for the julia compiler

hey everyone! i am extremely new to nixos. i am trying to make a dev environment shell for compiling the julia compiler. Julia uses Makefiles to fetch external dependencies and then build them locally (this is doable but causes a lot of rebuilds everytime). You can avoid it by settings a flag which will download binaries for those dependencies instead of source but thats obviously wont work on nixos. Julia’s Makefile also provides flags to use system depencies instead of building/downloading its own. I am trying to setup that.

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
  };

  outputs =
    { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      fhs = pkgs.buildFHSEnv {
        name = "julia-fhs-env";

        strictdeps = true;

        targetPkgs =
          pkgs: with pkgs; [
            gnumake
            llvmPackages.libunwind
            libnghttp2
            openlibm
            # .....
          ];

        runScript = "bash";
      };
    in
    {
      devShells.${system}.default = fhs.env;
    };
}

I created this flake file and also setup the Makefile flag to use system libs. After compiling ( which i am able to do successfully). I run the julia binary and i get this:

ERROR: Unable to load dependent library /home/prashant/Proj/fork/usr/bin/../lib/libopenlibm.so
Message:/home/prashant/Proj/fork/usr/bin/../lib/libopenlibm.so: cannot open shared object file: No such file or directory

The ./usr directory was created by julia during compilation.

$ tree -d -L 2
.
├── bin
├── etc
│   └── julia
├── include
│   ├── julia
│   ├── lld
│   ├── llvm
│   └── llvm-c
├── lib
│   ├── cmake
│   ├── julia
│   └── pkgconfig
├── libexec
├── manifest
│   └── v1.13
├── share
│   ├── julia
│   ├── man
│   └── opt-viewer
└── tools
    └── lit

22 directories
$ ldd -r ./usr/bin/julia
	linux-vdso.so.1 (0x00007ffe90ba2000)
	libdl.so.2 => /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libdl.so.2 (0x00007fefbd26d000)
	libpthread.so.0 => /home/prashant/Proj/fork/./usr/bin/../lib/libpthread.so.0 (0x00007fefbd268000)
	libc.so.6 => /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/libc.so.6 (0x00007fefbd06f000)
	libjulia.so.1.13 => /home/prashant/Proj/fork/./usr/bin/../lib/libjulia.so.1.13 (0x00007fefbd04d000)
	/nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib/ld-linux-x86-64.so.2 => /nix/store/nqb2ns2d1lahnd5ncwmn6k84qfd7vx2k-glibc-2.40-36/lib64/ld-linux-x86-64.so.2 (0x00007fefbd274000)

I created a dev shell with all the required libs (compile time and runtime) but julia is unable to find them? how can i get around this?
I have also tried using nix-ld with all the deps required.

Thank you!