about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers')
-rw-r--r--nixpkgs/pkgs/development/compilers/atasm/default.nix25
-rw-r--r--nixpkgs/pkgs/development/compilers/crystal/build-package.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/crystal/default.nix19
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/default.nix317
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/lib/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/lib.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/lib/fetchElmDeps.nix (renamed from nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/lib/makeDotElm.nix36
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix35
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/bimap.nix15
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/elm-json/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-json.nix)5
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/elm-json/use-system-ssl.patch (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-json.patch)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/elm-test/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-test.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/default.nix79
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elm-instrument/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-instrument.nix)22
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elmi-to-json/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elmi-to-json.nix)11
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/indents/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/indents.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/default.nix53
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/avh4-lib.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/avh4-lib.nix)2
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-lib.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-format-lib.nix)1
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-markdown.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-format-markdown.nix)1
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-test-lib.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-format-test-lib.nix)1
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix)12
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/ansi-wl-pprint/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/default.nix42
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/elm/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm.nix)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/lamdera/default.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/lamdera.nix)3
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/default.nix139
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/default.nix28
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-init-read-only.patch (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-init-read-only.patch)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-read-only.patch (renamed from nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-read-only.patch)0
-rwxr-xr-xnixpkgs/pkgs/development/compilers/elm/packages/node/generate-node-packages.sh (renamed from nixpkgs/pkgs/development/compilers/elm/packages/generate-node-packages.sh)5
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/node-composition.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/node-composition.nix)2
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.json (renamed from nixpkgs/pkgs/development/compilers/elm/packages/node-packages.json)0
-rw-r--r--nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.nix (renamed from nixpkgs/pkgs/development/compilers/elm/packages/node-packages.nix)0
-rwxr-xr-xnixpkgs/pkgs/development/compilers/elm/update.sh12
-rw-r--r--nixpkgs/pkgs/development/compilers/erg/default.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/flutter/flutter.nix4
-rw-r--r--nixpkgs/pkgs/development/compilers/flutter/versions/3_19/patches/gradle-flutter-tools-wrapper.patch44
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix18
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/community-edition/default.nix29
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/17/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/clang/default.nix139
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch71
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/clang/purity.patch25
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/X86-support-extension.patch21
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/darwin-targetconditionals.patch71
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/default.nix157
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/normalize-var.patch16
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/default.nix329
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/libcxx/0001-darwin-10.12-mbstate_t-fix.patch31
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/libcxx/default.nix130
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/libunwind/default.nix54
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/lld/default.nix57
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch15
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/lldb/cpu_subtype_arm64e_replacement.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/lldb/procfs.patch46
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/default.nix439
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs-polly.patch13
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch137
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/lit-shell-script-runner-set-dyld-library-path.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch80
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch24
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/openmp/default.nix73
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/openmp/fix-find-tool.patch17
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/18/openmp/run-lit-directly.patch0
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix3
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch29
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch20
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/default.nix11
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix22
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/lld/default.nix6
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch31
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix5
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch12
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch10
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch17
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix1
-rw-r--r--nixpkgs/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch22
-rwxr-xr-xnixpkgs/pkgs/development/compilers/llvm/update-git.py10
-rw-r--r--nixpkgs/pkgs/development/compilers/ocaml/5.2.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/openjdk/22.nix260
-rw-r--r--nixpkgs/pkgs/development/compilers/openjdk/openjfx/22.nix126
-rw-r--r--nixpkgs/pkgs/development/compilers/zulu/22.nix42
86 files changed, 2996 insertions, 595 deletions
diff --git a/nixpkgs/pkgs/development/compilers/atasm/default.nix b/nixpkgs/pkgs/development/compilers/atasm/default.nix
index 74f54d8d03cf..d79fc686b269 100644
--- a/nixpkgs/pkgs/development/compilers/atasm/default.nix
+++ b/nixpkgs/pkgs/development/compilers/atasm/default.nix
@@ -1,19 +1,22 @@
 { lib
 , stdenv
-, fetchurl
-, unzip
+, fetchFromGitHub
 , zlib
 }:
 
 stdenv.mkDerivation rec {
   pname = "atasm";
-  version = "1.09";
+  version = "1.23";
 
-  src = fetchurl {
-    url = "https://atari.miribilist.com/${pname}/${pname}${builtins.replaceStrings ["."] [""] version}.zip";
-    hash = "sha256-26shhw2r30GZIPz6S1rf6dOLKRpgpLwrqCRZX3+8PvA=";
+  src = fetchFromGitHub {
+    owner = "CycoPH";
+    repo = "atasm";
+    rev = "V${version}";
+    hash = "sha256-U1HNYTiXO6WZEQJl2icY0ZEVy82CsL1mKR7Xgj9OZ14=";
   };
 
+  makefile = "Makefile";
+
   patches = [
     # make install fails because atasm.txt was moved; report to upstream
     ./0000-file-not-found.diff
@@ -23,10 +26,6 @@ stdenv.mkDerivation rec {
 
   dontConfigure = true;
 
-  nativeBuildInputs = [
-    unzip
-  ];
-
   buildInputs = [
     zlib
   ];
@@ -42,9 +41,10 @@ stdenv.mkDerivation rec {
   '';
 
   preInstall = ''
+    mkdir -p $out/bin/
     install -d $out/share/doc/${pname} $out/man/man1
     installFlagsArray+=(
-      DESTDIR=$out
+      DESTDIR=$out/bin/
       DOCDIR=$out/share/doc/${pname}
       MANDIR=$out/man/man1
     )
@@ -55,9 +55,10 @@ stdenv.mkDerivation rec {
   '';
 
   meta = with lib; {
-    homepage = "https://atari.miribilist.com/atasm/";
+    homepage = "https://github.com/CycoPH/atasm";
     description = "A commandline 6502 assembler compatible with Mac/65";
     license = licenses.gpl2Plus;
+    changelog = "https://github.com/CycoPH/atasm/releases/tag/V${version}";
     maintainers = with maintainers; [ AndersonTorres ];
     platforms = with platforms; unix;
   };
diff --git a/nixpkgs/pkgs/development/compilers/crystal/build-package.nix b/nixpkgs/pkgs/development/compilers/crystal/build-package.nix
index e1ff7d08fb54..cb5869392b6b 100644
--- a/nixpkgs/pkgs/development/compilers/crystal/build-package.nix
+++ b/nixpkgs/pkgs/development/compilers/crystal/build-package.nix
@@ -71,8 +71,7 @@ let
 in
 stdenv.mkDerivation (mkDerivationArgs // {
 
-  configurePhase = args.configurePhase or lib.concatStringsSep "\n"
-    (
+  configurePhase = args.configurePhase or (lib.concatStringsSep "\n" (
       [
         "runHook preConfigure"
       ]
@@ -83,7 +82,7 @@ stdenv.mkDerivation (mkDerivationArgs // {
         "cp shard.lock lib/.shards.info"
       ]
       ++ [ "runHook postConfigure" ]
-    );
+    ));
 
   CRFLAGS = lib.concatStringsSep " " defaultOptions;
 
diff --git a/nixpkgs/pkgs/development/compilers/crystal/default.nix b/nixpkgs/pkgs/development/compilers/crystal/default.nix
index fb031eba18cb..f36ce4c25853 100644
--- a/nixpkgs/pkgs/development/compilers/crystal/default.nix
+++ b/nixpkgs/pkgs/development/compilers/crystal/default.nix
@@ -268,6 +268,16 @@ rec {
     };
   };
 
+  binaryCrystal_1_10 = genericBinary {
+    version = "1.10.1";
+    sha256s = {
+      x86_64-linux = "sha256-F0LjdV02U9G6B8ApHxClF/o5KvhxMNukSX7Z2CwSNIs=";
+      aarch64-darwin = "sha256-5kkObQl0VIO6zqQ8TYl0JzYyUmwfmPE9targpfwseSQ=";
+      x86_64-darwin = "sha256-5kkObQl0VIO6zqQ8TYl0JzYyUmwfmPE9targpfwseSQ=";
+      aarch64-linux = "sha256-AzFz+nrU/HJmCL1hbCKXf5ej/uypqV1GJPVLQ4J3778=";
+    };
+  };
+
   crystal_1_2 = generic {
     version = "1.2.2";
     sha256 = "sha256-nyOXhsutVBRdtJlJHe2dALl//BUXD1JeeQPgHU4SwiU=";
@@ -297,5 +307,12 @@ rec {
     llvmPackages = llvmPackages_15;
   };
 
-  crystal = crystal_1_9;
+  crystal_1_11 = generic {
+    version = "1.11.2";
+    sha256 = "sha256-BBEDWqFtmFUNj0kuGBzv71YHO3KjxV4d2ySTCD4HhLc=";
+    binary = binaryCrystal_1_10;
+    llvmPackages = llvmPackages_15;
+  };
+
+  crystal = crystal_1_11;
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/default.nix b/nixpkgs/pkgs/development/compilers/elm/default.nix
index 44e1459af84d..ca9f37ff5367 100644
--- a/nixpkgs/pkgs/development/compilers/elm/default.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/default.nix
@@ -5,307 +5,52 @@
 }:
 
 let
-  fetchElmDeps = pkgs.callPackage ./fetchElmDeps.nix { };
+  fetchElmDeps = pkgs.callPackage ./lib/fetchElmDeps.nix { };
 
   # Haskell packages that require ghc 9.6
-  hs96Pkgs = self: pkgs.haskell.packages.ghc96.override {
-    overrides = self: super: with pkgs.haskell.lib.compose; with lib;
-    let elmPkgs = rec {
-      elm = overrideCabal (drv: {
-        # sadly with parallelism most of the time breaks compilation
-        enableParallelBuilding = false;
-        preConfigure = fetchElmDeps {
-          elmPackages = (import ./packages/elm-srcs.nix);
-          elmVersion = drv.version;
-          registryDat = ./registry.dat;
-        };
-        buildTools = drv.buildTools or [] ++ [ makeWrapper ];
-        postInstall = ''
-          wrapProgram $out/bin/elm \
-            --prefix PATH ':' ${lib.makeBinPath [ nodejs ]}
-        '';
-
-        description = "A delightful language for reliable webapps";
-        homepage = "https://elm-lang.org/";
-        license = licenses.bsd3;
-        maintainers = with maintainers; [ domenkozar turbomack ];
-      }) (self.callPackage ./packages/elm.nix { });
-
-      inherit fetchElmDeps;
-      elmVersion = elmPkgs.elm.version;
-    };
-    in elmPkgs // {
-      inherit elmPkgs;
-
-      ansi-wl-pprint = overrideCabal (drv: {
-        jailbreak = true;
-      }) (self.callPackage ./packages/ansi-wl-pprint.nix {});
-    };
-  };
+  hs96Pkgs = import ./packages/ghc9_6 { inherit pkgs lib makeWrapper nodejs fetchElmDeps; };
 
   # Haskell packages that require ghc 8.10
-  hs810Pkgs = self: pkgs.haskell.packages.ghc810.override {
-    overrides = self: super: with pkgs.haskell.lib.compose; with lib;
-    let elmPkgs = rec {
-      elmi-to-json = justStaticExecutables (overrideCabal (drv: {
-        prePatch = ''
-          substituteInPlace package.yaml --replace "- -Werror" ""
-          hpack
-        '';
-        jailbreak = true;
-
-        description = "Tool that reads .elmi files (Elm interface file) generated by the elm compiler";
-        homepage = "https://github.com/stoeffel/elmi-to-json";
-        license = licenses.bsd3;
-        maintainers = [ maintainers.turbomack ];
-      }) (self.callPackage ./packages/elmi-to-json.nix {}));
-
-      elm-instrument = justStaticExecutables (overrideCabal (drv: {
-        prePatch = ''
-          sed "s/desc <-.*/let desc = \"${drv.version}\"/g" Setup.hs --in-place
-        '';
-        jailbreak = true;
-        # Tests are failing because of missing instances for Eq and Show type classes
-        doCheck = false;
-
-        description = "Instrument Elm code as a preprocessing step for elm-coverage";
-        homepage = "https://github.com/zwilias/elm-instrument";
-        license = licenses.bsd3;
-        maintainers = [ maintainers.turbomack ];
-      }) (self.callPackage ./packages/elm-instrument.nix {}));
-    };
-    in elmPkgs // {
-      inherit elmPkgs;
-
-      # We need attoparsec < 0.14 to build elm for now
-      attoparsec = self.attoparsec_0_13_2_5;
-
-      # aeson 2.0.3.0 does not build with attoparsec_0_13_2_5
-      aeson = doJailbreak self.aeson_1_5_6_0;
-
-      # elm-instrument needs this
-      indents = self.callPackage ./packages/indents.nix {};
-
-      # elm-instrument's tests depend on an old version of elm-format, but we set doCheck to false for other reasons above
-      elm-format = null;
-    };
-  };
+  hs810Pkgs = import ./packages/ghc8_10 { inherit pkgs lib; };
 
   # Haskell packages that require ghc 9.2
-  hs92Pkgs = self: pkgs.haskell.packages.ghc92.override {
-    overrides = self: super: with pkgs.haskell.lib.compose; with lib;
-    let elmPkgs = rec {
-      /*
-      The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo:
-      `package/nix/build.sh`
-      */
-      elm-format = justStaticExecutables (overrideCabal (drv: {
-        jailbreak = true;
-
-        description = "Formats Elm source code according to a standard set of rules based on the official Elm Style Guide";
-        homepage = "https://github.com/avh4/elm-format";
-        license = licenses.bsd3;
-        maintainers = with maintainers; [ avh4 turbomack ];
-      }) (self.callPackage ./packages/elm-format.nix {}));
-    };
-    in elmPkgs // {
-      inherit elmPkgs;
-
-      # Needed for elm-format
-      avh4-lib = doJailbreak (self.callPackage ./packages/avh4-lib.nix {});
-      elm-format-lib = doJailbreak (self.callPackage ./packages/elm-format-lib.nix {});
-      elm-format-test-lib = self.callPackage ./packages/elm-format-test-lib.nix {};
-      elm-format-markdown = self.callPackage ./packages/elm-format-markdown.nix {};
-
-      # elm-format requires text >= 2.0
-      text = self.text_2_0_2;
-      # unorderd-container's tests indirectly depend on text < 2.0
-      unordered-containers = overrideCabal (drv: { doCheck = false; }) super.unordered-containers;
-      # relude-1.1.0.0's tests depend on hedgehog < 1.2, which indirectly depends on text < 2.0
-      relude = overrideCabal (drv: { doCheck = false; }) super.relude;
-    };
-  };
-
-  nodePkgs = pkgs.callPackage ./packages/node-composition.nix {
-    inherit pkgs nodejs;
-    inherit (pkgs.stdenv.hostPlatform) system;
-  };
-
-in lib.makeScope pkgs.newScope (self: with self; {
-  inherit fetchElmDeps nodejs;
-
-  /* Node/NPM based dependencies can be upgraded using script `packages/generate-node-packages.sh`.
-
-      * Packages which rely on `bin-wrap` will fail by default
-        and can be patched using `patchBinwrap` function defined in `packages/lib.nix`.
-
-      * Packages which depend on npm installation of elm can be patched using
-        `patchNpmElm` function also defined in `packages/lib.nix`.
-  */
-  elmLib = let
-    hsElmPkgs = (hs810Pkgs self) // (hs96Pkgs self);
-  in import ./packages/lib.nix {
-    inherit lib;
-    inherit (pkgs) writeScriptBin stdenv;
-    inherit (hsElmPkgs.elmPkgs) elm;
-  };
+  hs92Pkgs = import ./packages/ghc9_2 { inherit pkgs lib; };
 
-  elm-json = callPackage ./packages/elm-json.nix { };
+  # Patched, originally npm-downloaded, packages
+  patchedNodePkgs = import ./packages/node { inherit pkgs lib nodejs makeWrapper; };
 
-  elm-test-rs = callPackage ./packages/elm-test-rs.nix { };
+  assembleScope = self: basics:
+    (hs96Pkgs self).elmPkgs // (hs92Pkgs self).elmPkgs // (hs810Pkgs self).elmPkgs // (patchedNodePkgs self) // basics;
+in
+lib.makeScope pkgs.newScope
+  (self: assembleScope self
+    (with self; {
+      inherit fetchElmDeps nodejs;
 
-  elm-test = callPackage ./packages/elm-test.nix { };
-} // (hs96Pkgs self).elmPkgs // (hs92Pkgs self).elmPkgs // (hs810Pkgs self).elmPkgs // (with elmLib; with (hs96Pkgs self).elmPkgs; {
-  elm-verify-examples = let
-    patched = patchBinwrap [elmi-to-json] nodePkgs.elm-verify-examples // {
-    meta = with lib; nodePkgs.elm-verify-examples.meta // {
-      description = "Verify examples in your docs";
-      homepage = "https://github.com/stoeffel/elm-verify-examples";
-      license = licenses.bsd3;
-      maintainers = [ maintainers.turbomack ];
-    };
-  };
-  in patched.override (old: {
-    preRebuild = (old.preRebuild or "") + ''
-      # This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
-      # in case of just this package
-      # TODO: investigate, same as for elm-coverage below
-      sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
-    '';
-  });
+      /* Node/NPM based dependencies can be upgraded using script `packages/generate-node-packages.sh`.
 
-  elm-coverage = let
-      patched = patchNpmElm (patchBinwrap [elmi-to-json] nodePkgs.elm-coverage);
-    in patched.override (old: {
-      # Symlink Elm instrument binary
-      preRebuild = (old.preRebuild or "") + ''
-        # Noop custom installation script
-        sed 's/\"install\".*/\"install\":\"echo no-op\"/g' --in-place package.json
+        * Packages which rely on `bin-wrap` will fail by default
+          and can be patched using `patchBinwrap` function defined in `packages/lib.nix`.
 
-        # This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
-        # in case of just this package
-        # TODO: investigate
-        sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
-      '';
-      postInstall = (old.postInstall or "") + ''
-        mkdir -p unpacked_bin
-        ln -sf ${elm-instrument}/bin/elm-instrument unpacked_bin/elm-instrument
-      '';
-      meta = with lib; nodePkgs.elm-coverage.meta // {
-        description = "Work in progress - Code coverage tooling for Elm";
-        homepage = "https://github.com/zwilias/elm-coverage";
-        license = licenses.bsd3;
-        maintainers = [ maintainers.turbomack ];
-      };
-    });
-
-    create-elm-app = patchNpmElm
-    nodePkgs.create-elm-app // {
-      meta = with lib; nodePkgs.create-elm-app.meta // {
-        description = "Create Elm apps with no build configuration";
-        homepage = "https://github.com/halfzebra/create-elm-app";
-        license = licenses.mit;
-        maintainers = [ maintainers.turbomack ];
-      };
-    };
-
-    elm-graphql =
-      nodePkgs."@dillonkearns/elm-graphql" // {
-        meta = with lib; nodePkgs."@dillonkearns/elm-graphql".meta // {
-          description = " Autogenerate type-safe GraphQL queries in Elm.";
-          license = licenses.bsd3;
-          maintainers = [ maintainers.pedrohlc ];
-        };
-      };
-
-    elm-review =
-      nodePkgs.elm-review // {
-        meta = with lib; nodePkgs.elm-review.meta // {
-          description = "Analyzes Elm projects, to help find mistakes before your users find them";
-          homepage = "https://package.elm-lang.org/packages/jfmengels/elm-review/${nodePkgs.elm-review.version}";
-          license = licenses.bsd3;
-          maintainers = [ maintainers.turbomack ];
-        };
-      };
-
-      elm-language-server = nodePkgs."@elm-tooling/elm-language-server" // {
-        meta = with lib; nodePkgs."@elm-tooling/elm-language-server".meta // {
-          description = "Language server implementation for Elm";
-          homepage = "https://github.com/elm-tooling/elm-language-server";
-          license = licenses.mit;
-          maintainers = [ maintainers.turbomack ];
-        };
-      };
-
-      elm-spa = nodePkgs."elm-spa".overrideAttrs  (
-        old: {
-          nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
-
-          meta = with lib; nodePkgs."elm-spa".meta // {
-            description = "A tool for building single page apps in Elm";
-            homepage = "https://www.elm-spa.dev/";
-            license = licenses.bsd3;
-            maintainers = [ maintainers.ilyakooo0 ];
-          };
-        }
-      );
-
-      elm-optimize-level-2 = nodePkgs."elm-optimize-level-2" // {
-        meta = with lib; nodePkgs."elm-optimize-level-2".meta // {
-          description = "A second level of optimization for the Javascript that the Elm Compiler produces";
-          homepage = "https://github.com/mdgriffith/elm-optimize-level-2";
-          license = licenses.bsd3;
-          maintainers = [ maintainers.turbomack ];
-        };
-      };
-
-      elm-pages = nodePkgs."elm-pages".overrideAttrs (
-        old: {
-          nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
-
-          # can't use `patches = [ <patch_file> ]` with a nodePkgs derivation;
-          # need to patch in one of the build phases instead.
-          # see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
-          preFixup = ''
-            patch $out/lib/node_modules/elm-pages/generator/src/codegen.js ${./packages/elm-pages-fix-read-only.patch}
-            patch $out/lib/node_modules/elm-pages/generator/src/init.js ${./packages/elm-pages-fix-init-read-only.patch}
-          '';
-
-          postFixup = ''
-            wrapProgram $out/bin/elm-pages --prefix PATH : ${
-              with pkgs.elmPackages; lib.makeBinPath [ elm elm-review elm-optimize-level-2 ]
-            }
-          '';
-
-          meta = with lib; nodePkgs."elm-pages".meta // {
-            description = "A statically typed site generator for Elm.";
-            homepage = "https://github.com/dillonkearns/elm-pages";
-            license = licenses.bsd3;
-            maintainers = [ maintainers.turbomack maintainers.jali-clarke ];
-          };
-        }
-      );
-
-      elm-land =
+        * Packages which depend on npm installation of elm can be patched using
+          `patchNpmElm` function also defined in `packages/lib.nix`.
+      */
+      elmLib =
         let
-          patched = patchNpmElm nodePkgs.elm-land;
+          hsElmPkgs = (hs810Pkgs self) // (hs96Pkgs self);
         in
-        patched.override (old: {
-          meta = with lib; nodePkgs."elm-land".meta // {
-            description = "A production-ready framework for building Elm applications.";
-            homepage = "https://elm.land/";
-            license = licenses.bsd3;
-            maintainers = [ maintainers.zupo ];
-          };
-        }
-      );
+        import ./lib {
+          inherit lib;
+          inherit (pkgs) writeScriptBin stdenv;
+          inherit (self) elm;
+        };
+
+      elm-json = callPackage ./packages/elm-json { };
 
-      lamdera = callPackage ./packages/lamdera.nix {};
+      elm-test-rs = callPackage ./packages/elm-test-rs { };
 
-      elm-doc-preview = nodePkgs."elm-doc-preview".overrideAttrs (old: {
-        nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ old.nodejs.pkgs.node-gyp-build ];
-      });
+      elm-test = callPackage ./packages/elm-test { };
 
-      inherit (nodePkgs) elm-live elm-upgrade elm-xref elm-analyse elm-git-install;
+      lamdera = callPackage ./packages/lamdera { };
     })
   )
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/lib.nix b/nixpkgs/pkgs/development/compilers/elm/lib/default.nix
index 12e0600dc231..12e0600dc231 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/lib.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/lib/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix b/nixpkgs/pkgs/development/compilers/elm/lib/fetchElmDeps.nix
index 9715bfbe037d..9715bfbe037d 100644
--- a/nixpkgs/pkgs/development/compilers/elm/fetchElmDeps.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/lib/fetchElmDeps.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/lib/makeDotElm.nix b/nixpkgs/pkgs/development/compilers/elm/lib/makeDotElm.nix
new file mode 100644
index 000000000000..ab62eb88e220
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/lib/makeDotElm.nix
@@ -0,0 +1,36 @@
+{ stdenv, lib, fetchurl, registryDat }:
+
+ver: deps:
+let
+  cmds = lib.mapAttrsToList
+    (name: info:
+      let
+        pkg = stdenv.mkDerivation {
+          name = lib.replaceStrings [ "/" ] [ "-" ] name + "-${info.version}";
+
+          src = fetchurl {
+            url = "https://github.com/${name}/archive/${info.version}.tar.gz";
+            meta.homepage = "https://github.com/${name}/";
+            inherit (info) sha256;
+          };
+
+          dontConfigure = true;
+          dontBuild = true;
+
+          installPhase = ''
+            mkdir -p $out
+            cp -r * $out
+          '';
+        };
+      in
+      ''
+        mkdir -p .elm/${ver}/packages/${name}
+        cp -R ${pkg} .elm/${ver}/packages/${name}/${info.version}
+      '')
+    deps;
+in
+(lib.concatStrings cmds) + ''
+  mkdir -p .elm/${ver}/packages;
+  cp ${registryDat} .elm/${ver}/packages/registry.dat;
+  chmod -R +w .elm
+''
diff --git a/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix b/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix
deleted file mode 100644
index 43252747c3a3..000000000000
--- a/nixpkgs/pkgs/development/compilers/elm/makeDotElm.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{stdenv, lib, fetchurl, registryDat}:
-
-ver: deps:
-  let cmds = lib.mapAttrsToList (name: info: let
-               pkg = stdenv.mkDerivation {
-                 name = lib.replaceStrings ["/"] ["-"] name + "-${info.version}";
-
-                 src = fetchurl {
-                   url = "https://github.com/${name}/archive/${info.version}.tar.gz";
-                   meta.homepage = "https://github.com/${name}/";
-                   inherit (info) sha256;
-                 };
-
-                 configurePhase = ''
-                   true
-                 '';
-
-                 buildPhase = ''
-                   true
-                 '';
-
-                 installPhase = ''
-                   mkdir -p $out
-                   cp -r * $out
-                 '';
-               };
-             in ''
-               mkdir -p .elm/${ver}/packages/${name}
-               cp -R ${pkg} .elm/${ver}/packages/${name}/${info.version}
-             '') deps;
-  in (lib.concatStrings cmds) + ''
-    mkdir -p .elm/${ver}/packages;
-    cp ${registryDat} .elm/${ver}/packages/registry.dat;
-    chmod -R +w .elm
-  ''
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/bimap.nix b/nixpkgs/pkgs/development/compilers/elm/packages/bimap.nix
deleted file mode 100644
index 41412d1639c7..000000000000
--- a/nixpkgs/pkgs/development/compilers/elm/packages/bimap.nix
+++ /dev/null
@@ -1,15 +0,0 @@
-{ mkDerivation, base, containers, exceptions, lib, QuickCheck
-, template-haskell
-}:
-mkDerivation {
-  pname = "bimap";
-  version = "0.3.3";
-  sha256 = "73829355c7bcbd3eedba22a382a04a3ab641702b00828790ec082ec2db3a8ad1";
-  libraryHaskellDepends = [ base containers exceptions ];
-  testHaskellDepends = [
-    base containers exceptions QuickCheck template-haskell
-  ];
-  homepage = "https://github.com/joelwilliamson/bimap";
-  description = "Bidirectional mapping between two key types";
-  license = lib.licenses.bsd3;
-}
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-json.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm-json/default.nix
index 5b988244cc97..16cd7f972ce4 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-json.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-json/default.nix
@@ -17,12 +17,13 @@ rustPlatform.buildRustPackage rec {
     sha256 = "sha256:nlpxlPzWk3wwDgczuMI9T6DFY1YtQpQ1R4BhdPbzZBs=";
   };
 
-  cargoPatches = [ ./elm-json.patch ];
+  cargoPatches = [ ./use-system-ssl.patch ];
 
   nativeBuildInputs = [ pkg-config ];
 
   buildInputs = [
-    curl openssl
+    curl
+    openssl
   ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
 
   cargoSha256 = "sha256:8SOpL8nfhYen9vza0LYpB/5fgVmBwG7vGMmFOaJskIc=";
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-json.patch b/nixpkgs/pkgs/development/compilers/elm/packages/elm-json/use-system-ssl.patch
index 54df03019231..54df03019231 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-json.patch
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-json/use-system-ssl.patch
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs/default.nix
index 02f69c2d2f03..02f69c2d2f03 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-test-rs/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-test.nix b/nixpkgs/pkgs/development/compilers/elm/packages/elm-test/default.nix
index eca45395c3df..eca45395c3df 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-test.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/elm-test/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/default.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/default.nix
new file mode 100644
index 000000000000..f68e582b3d0b
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/default.nix
@@ -0,0 +1,79 @@
+{ pkgs, lib }:
+
+self: pkgs.haskell.packages.ghc810.override {
+  overrides = self: super: with pkgs.haskell.lib.compose; with lib;
+    let
+      elmPkgs = rec {
+        elmi-to-json = justStaticExecutables (overrideCabal
+          (drv: {
+            version = "unstable-2021-07-19";
+            src = pkgs.fetchgit {
+              url = "https://github.com/stoeffel/elmi-to-json";
+              sha256 = "0vy678k15rzpsn0aly90fb01pxsbqkgf86pa86w0gd94lka8acwl";
+              rev = "6a42376ef4b6877e130971faf964578cc096e29b";
+              fetchSubmodules = true;
+            };
+
+            prePatch = ''
+              substituteInPlace package.yaml --replace "- -Werror" ""
+              hpack
+            '';
+            jailbreak = true;
+
+            description = "Tool that reads .elmi files (Elm interface file) generated by the elm compiler";
+            homepage = "https://github.com/stoeffel/elmi-to-json";
+            license = licenses.bsd3;
+            maintainers = [ maintainers.turbomack ];
+          })
+          (self.callPackage ./elmi-to-json { }));
+
+        elm-instrument = justStaticExecutables (overrideCabal
+          (drv: {
+            version = "unstable-2020-03-16";
+            src = pkgs.fetchgit {
+              url = "https://github.com/zwilias/elm-instrument";
+              sha256 = "167d7l2547zxdj7i60r6vazznd9ichwc0bqckh3vrh46glkz06jv";
+              rev = "63e15bb5ec5f812e248e61b6944189fa4a0aee4e";
+              fetchSubmodules = true;
+            };
+            patches = [
+              # Update code after breaking change in optparse-applicative
+              # https://github.com/zwilias/elm-instrument/pull/5
+              (pkgs.fetchpatch {
+                name = "update-optparse-applicative.patch";
+                url = "https://github.com/mdevlamynck/elm-instrument/commit/c548709d4818aeef315528e842eaf4c5b34b59b4.patch";
+                sha256 = "0ln7ik09n3r3hk7jmwwm46kz660mvxfa71120rkbbaib2falfhsc";
+              })
+            ];
+
+            prePatch = ''
+              sed "s/desc <-.*/let desc = \"${drv.version}\"/g" Setup.hs --in-place
+            '';
+            jailbreak = true;
+            # Tests are failing because of missing instances for Eq and Show type classes
+            doCheck = false;
+
+            description = "Instrument Elm code as a preprocessing step for elm-coverage";
+            homepage = "https://github.com/zwilias/elm-instrument";
+            license = licenses.bsd3;
+            maintainers = [ maintainers.turbomack ];
+          })
+          (self.callPackage ./elm-instrument { }));
+      };
+    in
+    elmPkgs // {
+      inherit elmPkgs;
+
+      # We need attoparsec < 0.14 to build elm for now
+      attoparsec = self.attoparsec_0_13_2_5;
+
+      # aeson 2.0.3.0 does not build with attoparsec_0_13_2_5
+      aeson = doJailbreak self.aeson_1_5_6_0;
+
+      # elm-instrument needs this
+      indents = self.callPackage ./indents { };
+
+      # elm-instrument's tests depend on an old version of elm-format, but we set doCheck to false for other reasons above
+      elm-format = null;
+    };
+}
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-instrument.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elm-instrument/default.nix
index 02593b855077..7f6a25905e36 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-instrument.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elm-instrument/default.nix
@@ -1,28 +1,18 @@
-{ mkDerivation, fetchpatch, ansi-terminal, ansi-wl-pprint, base, binary
+{ mkDerivation, ansi-terminal, ansi-wl-pprint, base, binary
 , bytestring, Cabal, cmark, containers, directory, elm-format
-, fetchgit, filepath, free, HUnit, indents, json, mtl
+, fetchgit, filepath, free, HUnit, indents, json, lib, mtl
 , optparse-applicative, parsec, process, QuickCheck, quickcheck-io
-, split, lib, tasty, tasty-golden, tasty-hunit, tasty-quickcheck
-, text
+, split, tasty, tasty-golden, tasty-hunit, tasty-quickcheck, text
 }:
 mkDerivation {
   pname = "elm-instrument";
   version = "0.0.7";
   src = fetchgit {
     url = "https://github.com/zwilias/elm-instrument";
-    sha256 = "167d7l2547zxdj7i60r6vazznd9ichwc0bqckh3vrh46glkz06jv";
-    rev = "63e15bb5ec5f812e248e61b6944189fa4a0aee4e";
+    sha256 = "14yfzwsyvgc6rzn19sdmwk2mc1vma9hcljnmjnmlig8mp0271v56";
+    rev = "31b527e405a6afdb25bb87ad7bd14f979e65cff7";
     fetchSubmodules = true;
   };
-  patches = [
-    # Update code after breaking change in optparse-applicative
-    # https://github.com/zwilias/elm-instrument/pull/5
-    (fetchpatch {
-      name = "update-optparse-applicative.patch";
-      url = "https://github.com/mdevlamynck/elm-instrument/commit/c548709d4818aeef315528e842eaf4c5b34b59b4.patch";
-      sha256 = "0ln7ik09n3r3hk7jmwwm46kz660mvxfa71120rkbbaib2falfhsc";
-    })
-  ];
   isLibrary = true;
   isExecutable = true;
   setupHaskellDepends = [ base Cabal directory filepath process ];
@@ -37,7 +27,7 @@ mkDerivation {
     quickcheck-io split tasty tasty-golden tasty-hunit tasty-quickcheck
     text
   ];
-  homepage = "https://elm-lang.org";
+  homepage = "http://elm-lang.org";
   description = "Instrumentation library for Elm";
   license = lib.licenses.bsd3;
   mainProgram = "elm-instrument";
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elmi-to-json.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elmi-to-json/default.nix
index f82f3e5179ac..fc2c76149a1a 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elmi-to-json.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/elmi-to-json/default.nix
@@ -1,15 +1,15 @@
 { mkDerivation, aeson, base, binary, bytestring, containers
-, directory, fetchgit, filepath, ghc-prim, hpack
-, optparse-applicative, lib, text, unliftio
-, unordered-containers
+, directory, fetchgit, filepath, ghc-prim, hpack, lib
+, optparse-applicative, text, unliftio, unordered-containers
 }:
 mkDerivation {
   pname = "elmi-to-json";
   version = "1.3.0";
   src = fetchgit {
     url = "https://github.com/stoeffel/elmi-to-json";
-    rev = "bd18efb59d247439b362272b480e67a16a4e424e";
-    sha256 = "sha256-9fScXRSyTkqzeXwh/Jjza6mnENCThlU6KI366CLFcgY=";
+    sha256 = "0vy678k15rzpsn0aly90fb01pxsbqkgf86pa86w0gd94lka8acwl";
+    rev = "6a42376ef4b6877e130971faf964578cc096e29b";
+    fetchSubmodules = true;
   };
   isLibrary = true;
   isExecutable = true;
@@ -23,4 +23,5 @@ mkDerivation {
   prePatch = "hpack";
   homepage = "https://github.com/stoeffel/elmi-to-json#readme";
   license = lib.licenses.bsd3;
+  mainProgram = "elmi-to-json";
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/indents.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/indents/default.nix
index 85e765db3e50..85e765db3e50 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/indents.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc8_10/indents/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/default.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/default.nix
new file mode 100644
index 000000000000..5ef5eff3bef1
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/default.nix
@@ -0,0 +1,53 @@
+{ pkgs, lib }:
+
+self: pkgs.haskell.packages.ghc92.override {
+  overrides = self: super: with pkgs.haskell.lib.compose; with lib;
+    let
+      elmPkgs = rec {
+        /*
+          The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo:
+          `package/nix/build.sh`
+        */
+        elm-format = justStaticExecutables (overrideCabal
+          (drv: {
+            jailbreak = true;
+            doHaddock = false;
+            postPatch = ''
+              mkdir -p ./generated
+              cat <<EOHS > ./generated/Build_elm_format.hs
+              module Build_elm_format where
+              gitDescribe :: String
+              gitDescribe = "${drv.version}"
+              EOHS
+            '';
+
+            description = "Formats Elm source code according to a standard set of rules based on the official Elm Style Guide";
+            homepage = "https://github.com/avh4/elm-format";
+            license = licenses.bsd3;
+            maintainers = with maintainers; [ avh4 turbomack ];
+          })
+          (self.callPackage ./elm-format/elm-format.nix { }));
+      };
+
+      fixHaddock = overrideCabal (_: {
+        configureFlags = [ "--ghc-option=-Wno-error=unused-packages" ];
+        doHaddock = false;
+      });
+    in
+    elmPkgs // {
+      inherit elmPkgs;
+
+      # Needed for elm-format
+      avh4-lib = fixHaddock (doJailbreak (self.callPackage ./elm-format/avh4-lib.nix { }));
+      elm-format-lib =  fixHaddock (doJailbreak (self.callPackage ./elm-format/elm-format-lib.nix { }));
+      elm-format-test-lib = fixHaddock (self.callPackage ./elm-format/elm-format-test-lib.nix { });
+      elm-format-markdown = fixHaddock (self.callPackage ./elm-format/elm-format-markdown.nix { });
+
+      # elm-format requires text >= 2.0
+      text = self.text_2_0_2;
+      # unorderd-container's tests indirectly depend on text < 2.0
+      unordered-containers = overrideCabal (drv: { doCheck = false; }) super.unordered-containers;
+      # relude-1.1.0.0's tests depend on hedgehog < 1.2, which indirectly depends on text < 2.0
+      relude = overrideCabal (drv: { doCheck = false; }) super.relude;
+    };
+}
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/avh4-lib.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/avh4-lib.nix
index f7f9381703c6..e320edfd1162 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/avh4-lib.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/avh4-lib.nix
@@ -12,7 +12,6 @@ mkDerivation {
     fetchSubmodules = true;
   };
   postUnpack = "sourceRoot+=/avh4-lib; echo source root reset to $sourceRoot";
-  configureFlags = [ "--ghc-option=-Wno-error=unused-packages" ];
   libraryHaskellDepends = [
     array base bytestring directory filepath mtl pooled-io process
     relude text
@@ -22,7 +21,6 @@ mkDerivation {
     relude tasty tasty-hspec tasty-hunit text
   ];
   testToolDepends = [ tasty-discover ];
-  doHaddock = false;
   description = "Common code for haskell projects";
   license = lib.licenses.bsd3;
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-lib.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-lib.nix
index a6b70414143f..290534bbea9a 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-lib.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-lib.nix
@@ -24,7 +24,6 @@ mkDerivation {
     text
   ];
   testToolDepends = [ tasty-discover ];
-  doHaddock = false;
   description = "Common code used by elm-format and elm-refactor";
   license = lib.licenses.bsd3;
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-markdown.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-markdown.nix
index fdeb2e88d384..e57d2127822e 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-markdown.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-markdown.nix
@@ -10,7 +10,6 @@ mkDerivation {
   };
   postUnpack = "sourceRoot+=/elm-format-markdown; echo source root reset to $sourceRoot";
   libraryHaskellDepends = [ base containers mtl text ];
-  doHaddock = false;
   description = "Markdown parsing for Elm documentation comments";
   license = lib.licenses.bsd3;
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-test-lib.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-test-lib.nix
index ccd6264d6c16..43090abbeae4 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format-test-lib.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format-test-lib.nix
@@ -21,7 +21,6 @@ mkDerivation {
     split tasty tasty-hspec tasty-hunit text
   ];
   testToolDepends = [ tasty-discover ];
-  doHaddock = false;
   description = "Test helpers used by elm-format-tests and elm-refactor-tests";
   license = lib.licenses.bsd3;
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format.nix
index c4448f246425..82ec995e1ecc 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-format.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_2/elm-format/elm-format.nix
@@ -3,7 +3,7 @@
 , optparse-applicative, QuickCheck, quickcheck-io, relude, tasty
 , tasty-hspec, tasty-hunit, tasty-quickcheck, text
 }:
-mkDerivation rec {
+mkDerivation {
   pname = "elm-format";
   version = "0.8.7";
   src = fetchgit {
@@ -24,18 +24,8 @@ mkDerivation rec {
     quickcheck-io relude tasty tasty-hspec tasty-hunit tasty-quickcheck
     text
   ];
-  doHaddock = false;
   homepage = "https://elm-lang.org";
   description = "A source code formatter for Elm";
   license = lib.licenses.bsd3;
   mainProgram = "elm-format";
-  postPatch = ''
-    mkdir -p ./generated
-    cat <<EOHS > ./generated/Build_elm_format.hs
-    module Build_elm_format where
-
-    gitDescribe :: String
-    gitDescribe = "${version}"
-    EOHS
-  '';
 }
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/ansi-wl-pprint/default.nix
index 392ca5ab31b1..392ca5ab31b1 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/ansi-wl-pprint.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/ansi-wl-pprint/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/default.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/default.nix
new file mode 100644
index 000000000000..13ba7faa0308
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/default.nix
@@ -0,0 +1,42 @@
+{ pkgs, lib, makeWrapper, nodejs, fetchElmDeps }:
+
+self: pkgs.haskell.packages.ghc96.override {
+  overrides = self: super: with pkgs.haskell.lib.compose; with lib;
+    let
+      elmPkgs = rec {
+        elm = overrideCabal
+          (drv: {
+            # sadly with parallelism most of the time breaks compilation
+            enableParallelBuilding = false;
+            preConfigure = fetchElmDeps {
+              elmPackages = (import ../elm-srcs.nix);
+              elmVersion = drv.version;
+              registryDat = ../../registry.dat;
+            };
+            buildTools = drv.buildTools or [ ] ++ [ makeWrapper ];
+            postInstall = ''
+              wrapProgram $out/bin/elm \
+                --prefix PATH ':' ${lib.makeBinPath [ nodejs ]}
+            '';
+
+            description = "A delightful language for reliable webapps";
+            homepage = "https://elm-lang.org/";
+            license = licenses.bsd3;
+            maintainers = with maintainers; [ domenkozar turbomack ];
+          })
+          (self.callPackage ./elm { });
+
+        inherit fetchElmDeps;
+        elmVersion = elmPkgs.elm.version;
+      };
+    in
+    elmPkgs // {
+      inherit elmPkgs;
+
+      ansi-wl-pprint = overrideCabal
+        (drv: {
+          jailbreak = true;
+        })
+        (self.callPackage ./ansi-wl-pprint { });
+    };
+}
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm.nix b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/elm/default.nix
index 1071d50a84c9..1071d50a84c9 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/ghc9_6/elm/default.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/lamdera.nix b/nixpkgs/pkgs/development/compilers/elm/packages/lamdera/default.nix
index e3dda4c31a52..c92d2d144d4b 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/lamdera.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/lamdera/default.nix
@@ -1,4 +1,5 @@
-{ stdenv, lib
+{ stdenv
+, lib
 , fetchurl
 }:
 
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/node/default.nix b/nixpkgs/pkgs/development/compilers/elm/packages/node/default.nix
new file mode 100644
index 000000000000..6d4d38a6d199
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/default.nix
@@ -0,0 +1,139 @@
+{ pkgs, lib, nodejs, makeWrapper }: self:
+
+let
+  # Untouched npm-downloaded packages
+  nodePkgs = pkgs.callPackage ./node-composition.nix {
+    inherit pkgs nodejs;
+    inherit (pkgs.stdenv.hostPlatform) system;
+  };
+in
+with self; with elmLib; {
+  inherit (nodePkgs) elm-live elm-upgrade elm-xref elm-analyse elm-git-install;
+
+  elm-verify-examples =
+    let
+      patched = patchBinwrap [ elmi-to-json ] nodePkgs.elm-verify-examples // {
+        meta = with lib; nodePkgs.elm-verify-examples.meta // {
+          description = "Verify examples in your docs";
+          homepage = "https://github.com/stoeffel/elm-verify-examples";
+          license = licenses.bsd3;
+          maintainers = [ maintainers.turbomack ];
+        };
+      };
+    in
+    patched.override (old: {
+      preRebuild = (old.preRebuild or "") + ''
+        # This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
+        # in case of just this package
+        # TODO: investigate, same as for elm-coverage below
+        sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
+      '';
+    });
+
+  elm-coverage =
+    let
+      patched = patchNpmElm (patchBinwrap [ elmi-to-json ] nodePkgs.elm-coverage);
+    in
+    patched.override (old: {
+      # Symlink Elm instrument binary
+      preRebuild = (old.preRebuild or "") + ''
+        # Noop custom installation script
+        sed 's/\"install\".*/\"install\":\"echo no-op\"/g' --in-place package.json
+
+        # This should not be needed (thanks to binwrap* being nooped) but for some reason it still needs to be done
+        # in case of just this package
+        # TODO: investigate
+        sed 's/\"install\".*/\"install\":\"echo no-op\",/g' --in-place node_modules/elmi-to-json/package.json
+      '';
+      postInstall = (old.postInstall or "") + ''
+        mkdir -p unpacked_bin
+        ln -sf ${elm-instrument}/bin/elm-instrument unpacked_bin/elm-instrument
+      '';
+      meta = with lib; nodePkgs.elm-coverage.meta // {
+        description = "Work in progress - Code coverage tooling for Elm";
+        homepage = "https://github.com/zwilias/elm-coverage";
+        license = licenses.bsd3;
+        maintainers = [ maintainers.turbomack ];
+      };
+    });
+
+  create-elm-app = patchNpmElm
+    nodePkgs.create-elm-app // {
+    meta = with lib; nodePkgs.create-elm-app.meta // {
+      description = "Create Elm apps with no build configuration";
+      homepage = "https://github.com/halfzebra/create-elm-app";
+      license = licenses.mit;
+      maintainers = [ maintainers.turbomack ];
+    };
+  };
+
+  elm-graphql =
+    nodePkgs."@dillonkearns/elm-graphql" // {
+      meta = with lib; nodePkgs."@dillonkearns/elm-graphql".meta // {
+        description = " Autogenerate type-safe GraphQL queries in Elm.";
+        license = licenses.bsd3;
+        maintainers = [ maintainers.pedrohlc ];
+      };
+    };
+
+  elm-review =
+    nodePkgs.elm-review // {
+      meta = with lib; nodePkgs.elm-review.meta // {
+        description = "Analyzes Elm projects, to help find mistakes before your users find them";
+        homepage = "https://package.elm-lang.org/packages/jfmengels/elm-review/${nodePkgs.elm-review.version}";
+        license = licenses.bsd3;
+        maintainers = [ maintainers.turbomack ];
+      };
+    };
+
+  elm-language-server = nodePkgs."@elm-tooling/elm-language-server" // {
+    meta = with lib; nodePkgs."@elm-tooling/elm-language-server".meta // {
+      description = "Language server implementation for Elm";
+      homepage = "https://github.com/elm-tooling/elm-language-server";
+      license = licenses.mit;
+      maintainers = [ maintainers.turbomack ];
+    };
+  };
+
+  elm-spa = nodePkgs."elm-spa".overrideAttrs (
+    old: {
+      nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
+
+      meta = with lib; nodePkgs."elm-spa".meta // {
+        description = "A tool for building single page apps in Elm";
+        homepage = "https://www.elm-spa.dev/";
+        license = licenses.bsd3;
+        maintainers = [ maintainers.ilyakooo0 ];
+      };
+    }
+  );
+
+  elm-optimize-level-2 = nodePkgs."elm-optimize-level-2" // {
+    meta = with lib; nodePkgs."elm-optimize-level-2".meta // {
+      description = "A second level of optimization for the Javascript that the Elm Compiler produces";
+      homepage = "https://github.com/mdgriffith/elm-optimize-level-2";
+      license = licenses.bsd3;
+      maintainers = [ maintainers.turbomack ];
+    };
+  };
+
+  elm-pages = import ./elm-pages { inherit nodePkgs pkgs lib makeWrapper; };
+
+  elm-land =
+    let
+      patched = patchNpmElm nodePkgs.elm-land;
+    in
+    patched.override (old: {
+      meta = with lib; nodePkgs."elm-land".meta // {
+        description = "A production-ready framework for building Elm applications.";
+        homepage = "https://elm.land/";
+        license = licenses.bsd3;
+        maintainers = [ maintainers.zupo ];
+      };
+    }
+    );
+
+  elm-doc-preview = nodePkgs."elm-doc-preview".overrideAttrs (old: {
+    nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ old.nodejs.pkgs.node-gyp-build ];
+  });
+}
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/default.nix b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/default.nix
new file mode 100644
index 000000000000..5502e26b415d
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/default.nix
@@ -0,0 +1,28 @@
+{ nodePkgs, pkgs, lib, makeWrapper }:
+
+nodePkgs."elm-pages".overrideAttrs (
+  old: {
+    nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ makeWrapper old.nodejs.pkgs.node-gyp-build ];
+
+    # can't use `patches = [ <patch_file> ]` with a nodePkgs derivation;
+    # need to patch in one of the build phases instead.
+    # see upstream issue https://github.com/dillonkearns/elm-pages/issues/305 for dealing with the read-only problem
+    preFixup = ''
+      patch $out/lib/node_modules/elm-pages/generator/src/codegen.js ${./fix-read-only.patch}
+      patch $out/lib/node_modules/elm-pages/generator/src/init.js ${./fix-init-read-only.patch}
+    '';
+
+    postFixup = ''
+      wrapProgram $out/bin/elm-pages --prefix PATH : ${
+        with pkgs.elmPackages; lib.makeBinPath [ elm elm-review elm-optimize-level-2 ]
+      }
+    '';
+
+    meta = with lib; nodePkgs."elm-pages".meta // {
+      description = "A statically typed site generator for Elm.";
+      homepage = "https://github.com/dillonkearns/elm-pages";
+      license = licenses.bsd3;
+      maintainers = [ maintainers.turbomack maintainers.jali-clarke ];
+    };
+  }
+)
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-init-read-only.patch b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-init-read-only.patch
index 9704ef9f7c08..9704ef9f7c08 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-init-read-only.patch
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-init-read-only.patch
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-read-only.patch b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-read-only.patch
index 547f89f86f69..547f89f86f69 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/elm-pages-fix-read-only.patch
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/elm-pages/fix-read-only.patch
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/generate-node-packages.sh b/nixpkgs/pkgs/development/compilers/elm/packages/node/generate-node-packages.sh
index 49e697e43e88..66cc71ca32bb 100755
--- a/nixpkgs/pkgs/development/compilers/elm/packages/generate-node-packages.sh
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/generate-node-packages.sh
@@ -1,11 +1,12 @@
 #!/usr/bin/env bash
 
-ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../../..)"
+ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../../../..)"
 
 set -eu -o pipefail
 
 $(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
+    --nodejs-18 \
     -i node-packages.json \
     -o node-packages.nix \
     -c node-composition.nix \
-    --no-copy-node-env -e ../../../node-packages/node-env.nix
+    --no-copy-node-env -e ../../../../node-packages/node-env.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/node-composition.nix b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-composition.nix
index c825c6c66349..1f86de75e357 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/node-composition.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-composition.nix
@@ -5,7 +5,7 @@
   }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_18"}:
 
 let
-  nodeEnv = import ../../../node-packages/node-env.nix {
+  nodeEnv = import ../../../../node-packages/node-env.nix {
     inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
     inherit pkgs nodejs;
     libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/node-packages.json b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.json
index 8112b01bc9e8..8112b01bc9e8 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/node-packages.json
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.json
diff --git a/nixpkgs/pkgs/development/compilers/elm/packages/node-packages.nix b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.nix
index 0efccbb5ff90..0efccbb5ff90 100644
--- a/nixpkgs/pkgs/development/compilers/elm/packages/node-packages.nix
+++ b/nixpkgs/pkgs/development/compilers/elm/packages/node/node-packages.nix
diff --git a/nixpkgs/pkgs/development/compilers/elm/update.sh b/nixpkgs/pkgs/development/compilers/elm/update.sh
index 4de11bd8ff5d..d718bd0fbb08 100755
--- a/nixpkgs/pkgs/development/compilers/elm/update.sh
+++ b/nixpkgs/pkgs/development/compilers/elm/update.sh
@@ -1,13 +1,21 @@
 #!/usr/bin/env nix-shell
 #!nix-shell -p cabal2nix elm2nix -i bash ../../..
 
-cabal2nix https://github.com/ekmett/ansi-wl-pprint --revision d16e2f6896d76b87b72af7220c2e93ba15c53280 > packages/ansi-wl-pprint.nix
+# Update all cabal packages.
+cabal2nix 'https://github.com/zwilias/elm-instrument' --revision '0.0.7' > packages/ghc8_10/elm-instrument/default.nix
+for subpath in 'avh4-lib' 'elm-format-lib' 'elm-format-markdown' 'elm-format-test-lib'; do
+  cabal2nix 'https://github.com/avh4/elm-format' --revision '0.8.7' \
+    --subpath $subpath > packages/ghc9_2/elm-format/${subpath}.nix
+done
+cabal2nix 'https://github.com/avh4/elm-format' --revision '0.8.7' > packages/ghc9_2/elm-format/elm-format.nix
+cabal2nix 'https://github.com/stoeffel/elmi-to-json' --revision '1.3.0' > packages/ghc8_10/elmi-to-json/default.nix
+cabal2nix 'https://github.com/ekmett/ansi-wl-pprint' --revision 'v0.6.8.1' > packages/ghc9_6/ansi-wl-pprint/default.nix
 
 # We're building binaries from commit that npm installer is using since
 # November 1st release called 0.19.1-6 in npm registry.
 # These binaries are built with newer ghc version and also support Aarch64 for Linux and Darwin.
 # Upstream git tag for 0.19.1 is still pointing to original commit from 2019.
-cabal2nix https://github.com/elm/compiler --revision 2f6dd29258e880dbb7effd57a829a0470d8da48b > packages/elm.nix
+cabal2nix https://github.com/elm/compiler --revision 2f6dd29258e880dbb7effd57a829a0470d8da48b > packages/ghc9_6/elm/default.nix
 
 echo "need to manually copy registry.dat from an existing elm project"
 #elm2nix snapshot > registry.dat
diff --git a/nixpkgs/pkgs/development/compilers/erg/default.nix b/nixpkgs/pkgs/development/compilers/erg/default.nix
index 0ad4320c046a..aafaf93b814c 100644
--- a/nixpkgs/pkgs/development/compilers/erg/default.nix
+++ b/nixpkgs/pkgs/development/compilers/erg/default.nix
@@ -9,16 +9,16 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "erg";
-  version = "0.6.32";
+  version = "0.6.33";
 
   src = fetchFromGitHub {
     owner = "erg-lang";
     repo = "erg";
     rev = "v${version}";
-    hash = "sha256-l+I6ue824dvZ1AmSS/y+Sh43OstJ5c+8xIXvoVpMFws=";
+    hash = "sha256-L154Ci2/Kw1NZcc7Sn2ROhrXBxIjZXr3DHHj4dvPHTI=";
   };
 
-  cargoHash = "sha256-SRltpqTviC+Dq9pPBuLjctOXOKTYw+zVlvA9wi0iFWg=";
+  cargoHash = "sha256-LL+9tu9CnevqOqoYORJ/WxerwPrEEpw/OKhC+0xchIs=";
 
   nativeBuildInputs = [
     makeWrapper
diff --git a/nixpkgs/pkgs/development/compilers/flutter/flutter.nix b/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
index 03c2968f4ab9..bce45f200c2d 100644
--- a/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
+++ b/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
@@ -82,6 +82,10 @@ let
           "dartSdkVersion": "${dart.version}"
         }
         EOF
+
+        # Suppress a small error now that `.gradle`'s location changed.
+        # Location changed because of the patch "gradle-flutter-tools-wrapper.patch".
+        mkdir -p "$out/packages/flutter_tools/gradle/.gradle"
       '';
 
       installPhase = ''
diff --git a/nixpkgs/pkgs/development/compilers/flutter/versions/3_19/patches/gradle-flutter-tools-wrapper.patch b/nixpkgs/pkgs/development/compilers/flutter/versions/3_19/patches/gradle-flutter-tools-wrapper.patch
new file mode 100644
index 000000000000..de6080efbba8
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/flutter/versions/3_19/patches/gradle-flutter-tools-wrapper.patch
@@ -0,0 +1,44 @@
+This patch introduces an intermediate Gradle build step to alter the behavior
+of flutter_tools' Gradle project, specifically moving the creation of `build`
+and `.gradle` directories from within the Nix Store to somewhere in `$HOME/.cache/flutter/nix-flutter-tools-gradle/$engineShortRev`.
+
+Without this patch, flutter_tools' Gradle project tries to generate `build` and `.gradle`
+directories within the Nix Store. Resulting in read-only errors when trying to build a
+Flutter Android app at runtime.
+
+This patch takes advantage of the fact settings.gradle takes priority over settings.gradle.kts to build the intermediate Gradle project
+when a Flutter app runs `includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")`
+
+`rootProject.buildFileName = "/dev/null"` so that the intermediate project doesn't use `build.gradle.kts` that's in the same directory.
+
+The intermediate project makes a `settings.gradle` file in `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/` and `includeBuild`s it.
+This Gradle project will build the actual `packages/flutter_tools/gradle` project by setting
+`rootProject.projectDir = new File("$settingsDir")` and `apply from: new File("$settingsDir/settings.gradle.kts")`.
+
+Now the `.gradle` will be built in `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/`, but `build` doesn't.
+To move `build` to `$HOME/.cache/flutter/nix-flutter-tools-gradle/<short engine rev>/` as well, we need to set `buildDirectory`.
+diff --git a/packages/flutter_tools/gradle/settings.gradle b/packages/flutter_tools/gradle/settings.gradle
+new file mode 100644
+index 0000000000..b2485c94b4
+--- /dev/null
++++ b/packages/flutter_tools/gradle/settings.gradle
+@@ -0,0 +1,19 @@
++rootProject.buildFileName = "/dev/null"
++
++def engineShortRev = (new File("$settingsDir/../../../bin/internal/engine.version")).text.take(10)
++def dir = new File("$System.env.HOME/.cache/flutter/nix-flutter-tools-gradle/$engineShortRev")
++dir.mkdirs()
++def file = new File(dir, "settings.gradle")
++
++file.text = """
++rootProject.projectDir = new File("$settingsDir")
++apply from: new File("$settingsDir/settings.gradle.kts")
++
++gradle.allprojects { project ->
++  project.beforeEvaluate {
++    project.layout.buildDirectory = new File("$dir/build")
++  }
++}
++"""
++
++includeBuild(dir)
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix b/nixpkgs/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix
index 858d7443ff62..34ed06e1de12 100644
--- a/nixpkgs/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix
+++ b/nixpkgs/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix
@@ -107,7 +107,7 @@ let
       ++ lib.optional stdenv.isLinux autoPatchelfHook;
 
     propagatedBuildInputs = [ setJavaClassPath zlib ]
-      ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Foundation;
+      ++ lib.optional stdenv.isDarwin darwin.apple_sdk_11_0.frameworks.Foundation;
 
     buildInputs = lib.optionals stdenv.isLinux [
       alsa-lib # libasound.so wanted by lib/libjsound.so
@@ -165,33 +165,27 @@ let
       echo "Testing GraalVM"
       $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
 
-      # Workaround GraalVM issue where the builder does not have access to the
-      # environment variables since 21.0.0
-      # Only needed for native-image tests
-      # https://github.com/oracle/graal/pull/6095
-      # https://github.com/oracle/graal/pull/6095
-      # https://github.com/oracle/graal/issues/7502
-      export NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION="true";
+      extraNativeImageArgs="$(export -p | sed -n 's/^declare -x \([^=]\+\)=.*$/ -E\1/p' | tr -d \\n)"
 
       echo "Ahead-Of-Time compilation"
-      $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld
+      $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces -march=compatibility $extraNativeImageArgs HelloWorld
       ./helloworld | fgrep 'Hello World'
 
       ${# --static is only available in Linux
       lib.optionalString (stdenv.isLinux && !useMusl) ''
         echo "Ahead-Of-Time compilation with -H:+StaticExecutableWithDynamicLibC"
-        $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:+StaticExecutableWithDynamicLibC HelloWorld
+        $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:+StaticExecutableWithDynamicLibC -march=compatibility $extraNativeImageArgs HelloWorld
         ./helloworld | fgrep 'Hello World'
 
         echo "Ahead-Of-Time compilation with --static"
-        $out/bin/native-image --static HelloWorld
+        $out/bin/native-image $extraNativeImageArgs -march=compatibility --static HelloWorld
         ./helloworld | fgrep 'Hello World'
       ''}
 
       ${# --static is only available in Linux
       lib.optionalString (stdenv.isLinux && useMusl) ''
         echo "Ahead-Of-Time compilation with --static and --libc=musl"
-        $out/bin/native-image --static HelloWorld --libc=musl
+        $out/bin/native-image $extraNativeImageArgs -march=compatibility --libc=musl --static HelloWorld
         ./helloworld | fgrep 'Hello World'
       ''}
 
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/community-edition/default.nix b/nixpkgs/pkgs/development/compilers/graalvm/community-edition/default.nix
index a29a81783c9c..bfc9c729689c 100644
--- a/nixpkgs/pkgs/development/compilers/graalvm/community-edition/default.nix
+++ b/nixpkgs/pkgs/development/compilers/graalvm/community-edition/default.nix
@@ -1,23 +1,28 @@
 { lib
-, stdenv
-, callPackage
-, fetchurl
+, pkgs
 }:
 
+lib.makeScope pkgs.newScope (self:
 {
-  buildGraalvm = callPackage ./buildGraalvm.nix;
+  stdenv =
+    if pkgs.stdenv.isDarwin then
+      pkgs.darwin.apple_sdk_11_0.stdenv
+    else
+      pkgs.stdenv;
 
-  buildGraalvmProduct = callPackage ./buildGraalvmProduct.nix;
+  buildGraalvm = self.callPackage ./buildGraalvm.nix;
 
-  graalvm-ce = callPackage ./graalvm-ce { };
+  buildGraalvmProduct = self.callPackage ./buildGraalvmProduct.nix;
 
-  graalvm-ce-musl = callPackage ./graalvm-ce { useMusl = true; };
+  graalvm-ce = self.callPackage ./graalvm-ce { };
 
-  graaljs = callPackage ./graaljs { };
+  graalvm-ce-musl = self.callPackage ./graalvm-ce { useMusl = true; };
 
-  graalnodejs = callPackage ./graalnodejs { };
+  graaljs = self.callPackage ./graaljs { };
 
-  graalpy = callPackage ./graalpy { };
+  graalnodejs = self.callPackage ./graalnodejs { };
 
-  truffleruby = callPackage ./truffleruby { };
-}
+  graalpy = self.callPackage ./graalpy { };
+
+  truffleruby = self.callPackage ./truffleruby { };
+})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/17/default.nix b/nixpkgs/pkgs/development/compilers/llvm/17/default.nix
index a9138e3c79b6..c8d956925345 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/17/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/17/default.nix
@@ -213,6 +213,7 @@ in let
           (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
           "-lunwind"
         ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+      nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
     };
 
     clangNoLibcxx = wrapCCWith rec {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/clang/default.nix
new file mode 100644
index 000000000000..1e777c6132e4
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/clang/default.nix
@@ -0,0 +1,139 @@
+{ lib, stdenv, llvm_meta
+, monorepoSrc, runCommand
+, substituteAll, cmake, ninja, libxml2, libllvm, version, python3
+, buildLlvmTools
+, fixDarwinDylibNames
+, enableManpages ? false
+}:
+
+let
+  self = stdenv.mkDerivation (finalAttrs: rec {
+    pname = "clang";
+    inherit version;
+
+    src = runCommand "${pname}-src-${version}" {} ''
+      mkdir -p "$out"
+      cp -r ${monorepoSrc}/cmake "$out"
+      cp -r ${monorepoSrc}/${pname} "$out"
+      cp -r ${monorepoSrc}/clang-tools-extra "$out"
+    '';
+
+    sourceRoot = "${src.name}/${pname}";
+
+    nativeBuildInputs = [ cmake ninja python3 ]
+      ++ lib.optional (lib.versionAtLeast version "18" && enableManpages) python3.pkgs.myst-parser
+      ++ lib.optional enableManpages python3.pkgs.sphinx
+      ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+
+    buildInputs = [ libxml2 libllvm ];
+
+    cmakeFlags = [
+      "-DCLANG_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/clang"
+      "-DCLANGD_BUILD_XPC=OFF"
+      "-DLLVM_ENABLE_RTTI=ON"
+      "-DLLVM_INCLUDE_TESTS=OFF"
+    ] ++ lib.optionals enableManpages [
+      "-DCLANG_INCLUDE_DOCS=ON"
+      "-DLLVM_ENABLE_SPHINX=ON"
+      "-DSPHINX_OUTPUT_MAN=ON"
+      "-DSPHINX_OUTPUT_HTML=OFF"
+      "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+    ] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
+      "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
+      "-DCLANG_TABLEGEN=${buildLlvmTools.libclang.dev}/bin/clang-tblgen"
+      # Added in LLVM15:
+      # `clang-tidy-confusable-chars-gen`: https://github.com/llvm/llvm-project/commit/c3574ef739fbfcc59d405985a3a4fa6f4619ecdb
+      # `clang-pseudo-gen`: https://github.com/llvm/llvm-project/commit/cd2292ef824591cc34cc299910a3098545c840c7
+      "-DCLANG_TIDY_CONFUSABLE_CHARS_GEN=${buildLlvmTools.libclang.dev}/bin/clang-tidy-confusable-chars-gen"
+      "-DCLANG_PSEUDO_GEN=${buildLlvmTools.libclang.dev}/bin/clang-pseudo-gen"
+    ];
+
+    patches = [
+      ./purity.patch
+      # https://reviews.llvm.org/D51899
+      ./gnu-install-dirs.patch
+      ../../common/clang/add-nostdlibinc-flag.patch
+      (substituteAll {
+        src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch;
+       libllvmLibdir = "${libllvm.lib}/lib";
+      })
+    ];
+
+    postPatch = ''
+      (cd tools && ln -s ../../clang-tools-extra extra)
+    '' + lib.optionalString stdenv.hostPlatform.isMusl ''
+      sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
+    '';
+
+    outputs = [ "out" "lib" "dev" "python" ];
+
+    postInstall = ''
+      ln -sv $out/bin/clang $out/bin/cpp
+
+      # Move libclang to 'lib' output
+      moveToOutput "lib/libclang.*" "$lib"
+      moveToOutput "lib/libclang-cpp.*" "$lib"
+      substituteInPlace $dev/lib/cmake/clang/ClangTargets-release.cmake \
+          --replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang." \
+          --replace "\''${_IMPORT_PREFIX}/lib/libclang-cpp." "$lib/lib/libclang-cpp."
+
+      mkdir -p $python/bin $python/share/clang/
+      mv $out/bin/{git-clang-format,scan-view} $python/bin
+      if [ -e $out/bin/set-xcode-analyzer ]; then
+        mv $out/bin/set-xcode-analyzer $python/bin
+      fi
+      mv $out/share/clang/*.py $python/share/clang
+      rm $out/bin/c-index-test
+      patchShebangs $python/bin
+
+      mkdir -p $dev/bin
+      cp bin/{clang-tblgen,clang-tidy-confusable-chars-gen,clang-pseudo-gen} $dev/bin
+    '';
+
+    passthru = {
+      inherit libllvm;
+      isClang = true;
+      hardeningUnsupportedFlags = [
+        "fortify3"
+      ];
+      hardeningUnsupportedFlagsByTargetPlatform = targetPlatform:
+        lib.optional (!(targetPlatform.isx86_64 || targetPlatform.isAarch64)) "zerocallusedregs"
+        ++ (finalAttrs.passthru.hardeningUnsupportedFlags or []);
+    };
+
+    meta = llvm_meta // {
+      homepage = "https://clang.llvm.org/";
+      description = "A C language family frontend for LLVM";
+      longDescription = ''
+        The Clang project provides a language front-end and tooling
+        infrastructure for languages in the C language family (C, C++, Objective
+        C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.
+        It aims to deliver amazingly fast compiles, extremely useful error and
+        warning messages and to provide a platform for building great source
+        level tools. The Clang Static Analyzer and clang-tidy are tools that
+        automatically find bugs in your code, and are great examples of the sort
+        of tools that can be built using the Clang frontend as a library to
+        parse C/C++ code.
+      '';
+      mainProgram = "clang";
+    };
+  } // lib.optionalAttrs enableManpages {
+    pname = "clang-manpages";
+
+    ninjaFlags = [ "docs-clang-man" ];
+
+    installPhase = ''
+      mkdir -p $out/share/man/man1
+      # Manually install clang manpage
+      cp docs/man/*.1 $out/share/man/man1/
+    '';
+
+    outputs = [ "out" ];
+
+    doCheck = false;
+
+    meta = llvm_meta // {
+      description = "man page for Clang ${version}";
+    };
+  });
+in self
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch
new file mode 100644
index 000000000000..9517df973ad0
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/clang/gnu-install-dirs.patch
@@ -0,0 +1,71 @@
+diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
+index 75b0080f6715..c895b884cd27 100644
+--- a/cmake/modules/AddClang.cmake
++++ b/cmake/modules/AddClang.cmake
+@@ -119,8 +119,8 @@ macro(add_clang_library name)
+         install(TARGETS ${lib}
+           COMPONENT ${lib}
+           ${export_to_clangtargets}
+-          LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+-          ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
++          LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
++          ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
+           RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ 
+         if (NOT LLVM_ENABLE_IDE)
+diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
+index f2b0c5cddcbb..52f37fc368ce 100644
+--- a/lib/Headers/CMakeLists.txt
++++ b/lib/Headers/CMakeLists.txt
+@@ -473,6 +473,7 @@ add_header_target("windows-resource-headers" ${windows_only_files})
+ add_header_target("utility-resource-headers" ${utility_files})
+ 
+ get_clang_resource_dir(header_install_dir SUBDIR include)
++set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include)
+ 
+ #############################################################
+ # Install rules for the catch-all clang-resource-headers target
+diff --git a/tools/libclang/CMakeLists.txt b/tools/libclang/CMakeLists.txt
+index 4f23065a2472..6a0f55991e24 100644
+--- a/tools/libclang/CMakeLists.txt
++++ b/tools/libclang/CMakeLists.txt
+@@ -234,7 +234,7 @@ foreach(PythonVersion ${CLANG_PYTHON_BINDINGS_VERSIONS})
+           COMPONENT
+             libclang-python-bindings
+           DESTINATION
+-            "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
++            "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
+ endforeach()
+ if(NOT LLVM_ENABLE_IDE)
+   add_custom_target(libclang-python-bindings)
+diff --git a/tools/scan-build-py/CMakeLists.txt b/tools/scan-build-py/CMakeLists.txt
+index 3aca22c0b0a8..3115353e3fe3 100644
+--- a/tools/scan-build-py/CMakeLists.txt
++++ b/tools/scan-build-py/CMakeLists.txt
+@@ -88,7 +88,7 @@ foreach(lib ${LibScanbuild})
+                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/${lib})
+   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/${lib})
+   install(FILES lib/libscanbuild/${lib}
+-          DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild
++          DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild"
+           COMPONENT scan-build-py)
+ endforeach()
+ 
+@@ -106,7 +106,7 @@ foreach(resource ${LibScanbuildResources})
+                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libscanbuild/resources/${resource})
+   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libscanbuild/resources/${resource})
+   install(FILES lib/libscanbuild/resources/${resource}
+-          DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libscanbuild/resources
++          DESTINATION "${CMAKE_INSTALL_LIBDIR}/libscanbuild/resources"
+           COMPONENT scan-build-py)
+ endforeach()
+ 
+@@ -122,7 +122,7 @@ foreach(lib ${LibEar})
+                      DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/libear/${lib})
+   list(APPEND Depends ${CMAKE_BINARY_DIR}/lib/libear/${lib})
+   install(FILES lib/libear/${lib}
+-          DESTINATION lib${CLANG_LIBDIR_SUFFIX}/libear
++          DESTINATION "${CMAKE_INSTALL_LIBDIR}/libear"
+           COMPONENT scan-build-py)
+ endforeach()
+ 
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/clang/purity.patch b/nixpkgs/pkgs/development/compilers/llvm/18/clang/purity.patch
new file mode 100644
index 000000000000..5ce14a3479a0
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/clang/purity.patch
@@ -0,0 +1,25 @@
+From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
+From: Will Dietz <w@wdtz.org>
+Date: Thu, 18 May 2017 11:56:12 -0500
+Subject: [PATCH] "purity" patch for 5.0
+
+---
+ lib/Driver/ToolChains/Gnu.cpp | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index fe3c0191bb..c6a482bece 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -446,9 +446,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+                            ToolChain.isPIEDefault(Args));
+       if (IsPIE)
+         CmdArgs.push_back("-pie");
+-      CmdArgs.push_back("-dynamic-linker");
+-      CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
+-                                           ToolChain.getDynamicLinker(Args)));
+     }
+   }
+ 
+-- 
+2.11.0
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/X86-support-extension.patch b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/X86-support-extension.patch
new file mode 100644
index 000000000000..07013e5a6825
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/X86-support-extension.patch
@@ -0,0 +1,21 @@
+diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt
+index 3a66dd9c3fb..7efc85d9f9f 100644
+--- a/lib/builtins/CMakeLists.txt
++++ b/lib/builtins/CMakeLists.txt
+@@ -348,4 +348,8 @@ if (NOT MSVC)
+ 
++  set(i486_SOURCES ${i386_SOURCES})
++  set(i586_SOURCES ${i386_SOURCES})
++  set(i686_SOURCES ${i386_SOURCES})
++
+   if (WIN32)
+     set(i386_SOURCES
+       ${i386_SOURCES}
+@@ -723,6 +723,7 @@ else ()
+   endif()
+ 
+   foreach (arch ${BUILTIN_SUPPORTED_ARCH})
++      message("arch: ${arch}")
+     if (CAN_TARGET_${arch})
+       # For ARM archs, exclude any VFP builtins if VFP is not supported
+       if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em)$")
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/darwin-targetconditionals.patch b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/darwin-targetconditionals.patch
new file mode 100644
index 000000000000..425dc2af01e7
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/darwin-targetconditionals.patch
@@ -0,0 +1,71 @@
+diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp
+--- a/lib/sanitizer_common/sanitizer_mac.cpp
++++ b/lib/sanitizer_common/sanitizer_mac.cpp
+@@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) {
+ // Offset example:
+ // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4
+ constexpr u16 GetOSMajorKernelOffset() {
+-  if (TARGET_OS_OSX) return 4;
+-  if (TARGET_OS_IOS || TARGET_OS_TV) return 6;
+-  if (TARGET_OS_WATCH) return 13;
++#if TARGET_OS_OSX
++  return 4;
++#endif
++#if TARGET_OS_IOS || TARGET_OS_TV
++  return 6;
++#endif
++#if TARGET_OS_WATCH
++  return 13;
++#endif
+ }
+ 
+ using VersStr = char[64];
+@@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) {
+   u16 os_major = kernel_major - offset;
+ 
+   const char *format = "%d.0";
+-  if (TARGET_OS_OSX) {
+-    if (os_major >= 16) {  // macOS 11+
+-      os_major -= 5;
+-    } else {  // macOS 10.15 and below
+-      format = "10.%d";
+-    }
++#if TARGET_OS_OSX
++  if (os_major >= 16) {  // macOS 11+
++    os_major -= 5;
++  } else {  // macOS 10.15 and below
++    format = "10.%d";
+   }
++#endif
+   return internal_snprintf(vers, sizeof(VersStr), format, os_major);
+ }
+ 
+@@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) {
+ // Aligned versions example:
+ // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6
+ static void MapToMacos(u16 *major, u16 *minor) {
+-  if (TARGET_OS_OSX)
+-    return;
+-
+-  if (TARGET_OS_IOS || TARGET_OS_TV)
++#if !TARGET_OS_OSX
++#if TARGET_OS_IOS || TARGET_OS_TV
+     *major += 2;
+-  else if (TARGET_OS_WATCH)
++#elif TARGET_OS_WATCH
+     *major += 9;
+-  else
++#else
+     UNREACHABLE("unsupported platform");
++#endif
+ 
+   if (*major >= 16) {  // macOS 11+
+     *major -= 5;
+@@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) {
+     *minor = *major;
+     *major = 10;
+   }
++#endif
+ }
+ 
+ static MacosVersion GetMacosAlignedVersionInternal() {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/default.nix
new file mode 100644
index 000000000000..f51316beb570
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/default.nix
@@ -0,0 +1,157 @@
+{ lib, stdenv, llvm_meta, version
+, monorepoSrc, runCommand
+, cmake, ninja, python3, xcbuild, libllvm, linuxHeaders, libxcrypt
+, doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD
+}:
+
+let
+
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+  bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
+  haveLibc = stdenv.cc.libc != null;
+  isDarwinStatic = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic;
+  inherit (stdenv.hostPlatform) isMusl;
+
+  baseName = "compiler-rt";
+
+  src = runCommand "${baseName}-src-${version}" {} ''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${baseName} "$out"
+  '';
+in
+
+stdenv.mkDerivation {
+  pname = baseName + lib.optionalString (haveLibc) "-libc";
+  inherit version;
+
+  inherit src;
+  sourceRoot = "${src.name}/${baseName}";
+
+  nativeBuildInputs = [ cmake ninja python3 libllvm.dev ]
+    ++ lib.optional stdenv.isDarwin xcbuild.xcrun;
+  buildInputs =
+    lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders;
+
+  env.NIX_CFLAGS_COMPILE = toString ([
+    "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
+  ] ++ lib.optionals (!haveLibc) [
+    # The compiler got stricter about this, and there is a usellvm patch below
+    # which patches out the assert include causing an implicit definition of
+    # assert. It would be nicer to understand why compiler-rt thinks it should
+    # be able to #include <assert.h> in the first place; perhaps it's in the
+    # wrong, or perhaps there is a way to provide an assert.h.
+    "-Wno-error=implicit-function-declaration"
+  ]);
+
+  cmakeFlags = [
+    "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
+    "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
+    "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
+  ] ++ lib.optionals (haveLibc && stdenv.hostPlatform.libc == "glibc") [
+    "-DSANITIZER_COMMON_CFLAGS=-I${libxcrypt}/include"
+  ] ++ lib.optionals (useLLVM || bareMetal || isMusl || isDarwinStatic) [
+    "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
+    "-DCOMPILER_RT_BUILD_XRAY=OFF"
+    "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
+    "-DCOMPILER_RT_BUILD_MEMPROF=OFF"
+    "-DCOMPILER_RT_BUILD_ORC=OFF" # may be possible to build with musl if necessary
+  ] ++ lib.optionals (useLLVM || bareMetal) [
+     "-DCOMPILER_RT_BUILD_PROFILE=OFF"
+  ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal || isDarwinStatic ) [
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+  ] ++ lib.optionals ((useLLVM && !haveLibc) || bareMetal) [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
+    "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
+  ] ++ lib.optionals (useLLVM && !haveLibc) [
+    "-DCMAKE_C_FLAGS=-nodefaultlibs"
+  ] ++ lib.optionals (useLLVM) [
+    "-DCOMPILER_RT_BUILD_BUILTINS=ON"
+    #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
+    "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
+  ] ++ lib.optionals (bareMetal) [
+    "-DCOMPILER_RT_OS_DIR=baremetal"
+  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
+    "-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo"
+    "-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
+    "-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
+    "-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
+
+    # `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin:
+    # https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153
+    "-DCOMPILER_RT_ENABLE_IOS=OFF"
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  patches = [
+    ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
+    # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
+    # extra `/`.
+    ./normalize-var.patch
+    # See: https://github.com/NixOS/nixpkgs/pull/186575
+    ../../common/compiler-rt/darwin-plistbuddy-workaround.patch
+    # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
+    # ../../common/compiler-rt/armv7l-15.patch
+  ];
+
+  # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+  # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
+  # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
+  # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
+  # a flag and turn the flag off during the stdenv build.
+  postPatch = lib.optionalString (!stdenv.isDarwin) ''
+    substituteInPlace cmake/builtin-config-ix.cmake \
+      --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
+  '' + lib.optionalString stdenv.isDarwin ''
+    substituteInPlace cmake/config-ix.cmake \
+      --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
+  '' + lib.optionalString (useLLVM && !haveLibc) ''
+    substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \
+      --replace "<stdlib.h>" "<stddef.h>"
+    substituteInPlace lib/builtins/int_util.c \
+      --replace "#include <stdlib.h>" ""
+    substituteInPlace lib/builtins/clear_cache.c \
+      --replace "#include <assert.h>" ""
+    substituteInPlace lib/builtins/cpu_model${lib.optionalString (lib.versionAtLeast version "18") "/x86"}.c \
+      --replace "#include <assert.h>" ""
+  '';
+
+  # Hack around weird upsream RPATH bug
+  postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin) ''
+    ln -s "$out/lib"/*/* "$out/lib"
+  '' + lib.optionalString (useLLVM && stdenv.hostPlatform.isLinux) ''
+    ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
+    ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
+    # Note the history of crt{begin,end}S in previous versions of llvm in nixpkg:
+    # The presence of crtbegin_shared has been added and removed; it's possible
+    # people have added/removed it to get it working on their platforms.
+    # Try each in turn for now.
+    ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbeginS.o
+    ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtendS.o
+    ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
+    ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
+  '' + lib.optionalString doFakeLibgcc ''
+     ln -s $out/lib/freebsd/libclang_rt.builtins-*.a $out/lib/libgcc.a
+  '';
+
+  meta = llvm_meta // {
+    homepage = "https://compiler-rt.llvm.org/";
+    description = "Compiler runtime libraries";
+    longDescription = ''
+      The compiler-rt project provides highly tuned implementations of the
+      low-level code generator support routines like "__fixunsdfdi" and other
+      calls generated when a target doesn't have a short sequence of native
+      instructions to implement a core IR operation. It also provides
+      implementations of run-time libraries for dynamic testing tools such as
+      AddressSanitizer, ThreadSanitizer, MemorySanitizer, and DataFlowSanitizer.
+    '';
+    # "All of the code in the compiler-rt project is dual licensed under the MIT
+    # license and the UIUC License (a BSD-like license)":
+    license = with lib.licenses; [ mit ncsa ];
+    # compiler-rt requires a Clang stdenv on 32-bit RISC-V:
+    # https://reviews.llvm.org/D43106#1019077
+    broken = stdenv.hostPlatform.isRiscV32 && !stdenv.cc.isClang;
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/normalize-var.patch b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/normalize-var.patch
new file mode 100644
index 000000000000..2b25fd4a0744
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/compiler-rt/normalize-var.patch
@@ -0,0 +1,16 @@
+diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
+index 4c85551d7766..297d7a47c54b 100644
+--- a/cmake/Modules/CompilerRTUtils.cmake
++++ b/cmake/Modules/CompilerRTUtils.cmake
+@@ -328,8 +328,9 @@ macro(load_llvm_config)
+     endif()
+   endif()
+ 
+-  set(LLVM_LIBRARY_OUTPUT_INTDIR
+-    ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
++  get_filename_component(LLVM_LIBRARY_OUTPUT_INTDIR
++    ${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}
++    REALPATH)
+ 
+   set(LLVM_MAIN_SRC_DIR "${LLVM_MAIN_SRC_DIR_DEFAULT}" CACHE PATH "Path to LLVM source tree")
+   message(STATUS "LLVM_MAIN_SRC_DIR: \"${LLVM_MAIN_SRC_DIR}\"")
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/default.nix
new file mode 100644
index 000000000000..dd3000c04259
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/default.nix
@@ -0,0 +1,329 @@
+{ lowPrio, newScope, pkgs, lib, stdenv, cmake, ninja
+, preLibcCrossHeaders
+, libxml2, python3, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith
+, buildLlvmTools # tools, but from the previous stage, for cross
+, targetLlvmLibraries # libraries, but from the next stage, for cross
+, targetLlvm
+# This is the default binutils, but with *this* version of LLD rather
+# than the default LLVM verion's, if LLD is the choice. We use these for
+# the `useLLVM` bootstrapping below.
+, bootBintoolsNoLibc ?
+    if stdenv.targetPlatform.linker == "lld"
+    then null
+    else pkgs.bintoolsNoLibc
+, bootBintools ?
+    if stdenv.targetPlatform.linker == "lld"
+    then null
+    else pkgs.bintools
+, darwin
+# LLVM release information; specify one of these but not both:
+, gitRelease ? null
+  # i.e.:
+  # {
+  #   version = /* i.e. "15.0.0" */;
+  #   rev = /* commit SHA */;
+  #   rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
+  #   sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
+  # }
+, officialRelease ? { version = "18.1.1"; sha256 = "sha256-qAPNvEpztJjPz+kr5KcZz4iUTErsD8iXLURKl3yZoC8="; }
+  # i.e.:
+  # {
+  #   version = /* i.e. "15.0.0" */;
+  #   candidate = /* optional; if specified, should be: "rcN" */
+  #   sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
+  # }
+# By default, we'll try to fetch a release from `github:llvm/llvm-project`
+# corresponding to the `gitRelease` or `officialRelease` specified.
+#
+# You can provide your own LLVM source by specifying this arg but then it's up
+# to you to make sure that the LLVM repo given matches the release configuration
+# specified.
+, monorepoSrc ? null
+}:
+
+assert let
+  int = a: if a then 1 else 0;
+  xor = a: b: ((builtins.bitXor (int a) (int b)) == 1);
+in
+  lib.assertMsg
+    (xor
+      (gitRelease != null)
+      (officialRelease != null))
+    ("must specify `gitRelease` or `officialRelease`" +
+      (lib.optionalString (gitRelease != null) " — not both"));
+let
+  monorepoSrc' = monorepoSrc;
+in let
+  inherit (import ../common/common-let.nix { inherit lib gitRelease officialRelease; }) releaseInfo;
+
+  inherit (releaseInfo) release_version version;
+
+  inherit (import ../common/common-let.nix { inherit lib fetchFromGitHub release_version gitRelease officialRelease monorepoSrc'; }) llvm_meta monorepoSrc;
+
+  tools = lib.makeExtensible (tools: let
+    callPackage = newScope (tools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc buildLlvmTools; });
+    major = lib.versions.major release_version;
+    mkExtraBuildCommands0 = cc: ''
+      rsrc="$out/resource-root"
+      mkdir "$rsrc"
+      ln -s "${cc.lib}/lib/clang/${major}/include" "$rsrc"
+      echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
+    '';
+    mkExtraBuildCommands = cc: mkExtraBuildCommands0 cc + ''
+      ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
+      ln -s "${targetLlvmLibraries.compiler-rt.out}/share" "$rsrc/share"
+    '';
+
+  bintoolsNoLibc' =
+    if bootBintoolsNoLibc == null
+    then tools.bintoolsNoLibc
+    else bootBintoolsNoLibc;
+  bintools' =
+    if bootBintools == null
+    then tools.bintools
+    else bootBintools;
+
+  in {
+
+    libllvm = callPackage ./llvm {
+      inherit llvm_meta;
+    };
+
+    # `llvm` historically had the binaries.  When choosing an output explicitly,
+    # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get*
+    llvm = tools.libllvm;
+
+    libclang = callPackage ./clang {
+      inherit llvm_meta;
+    };
+
+    clang-unwrapped = tools.libclang;
+
+    llvm-manpages = lowPrio (tools.libllvm.override {
+      enableManpages = true;
+      python3 = pkgs.python3;  # don't use python-boot
+    });
+
+    clang-manpages = lowPrio (tools.libclang.override {
+      enableManpages = true;
+      python3 = pkgs.python3;  # don't use python-boot
+    });
+
+    lldb-manpages = lowPrio (tools.lldb.override {
+      enableManpages = true;
+      python3 = pkgs.python3;  # don't use python-boot
+    });
+
+    # pick clang appropriate for package set we are targeting
+    clang =
+      /**/ if stdenv.targetPlatform.useLLVM or false then tools.clangUseLLVM
+      else if (pkgs.targetPackages.stdenv or stdenv).cc.isGNU then tools.libstdcxxClang
+      else tools.libcxxClang;
+
+    libstdcxxClang = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      # libstdcxx is taken from gcc in an ad-hoc way in cc-wrapper.
+      libcxx = null;
+      extraPackages = [
+        targetLlvmLibraries.compiler-rt
+      ];
+      extraBuildCommands = mkExtraBuildCommands cc;
+    };
+
+    libcxxClang = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      libcxx = targetLlvmLibraries.libcxx;
+      extraPackages = [
+        targetLlvmLibraries.compiler-rt
+      ];
+      extraBuildCommands = mkExtraBuildCommands cc;
+    };
+
+    lld = callPackage ./lld {
+      inherit llvm_meta;
+    };
+
+    mlir = callPackage ../common/mlir {
+      inherit llvm_meta;
+    };
+
+    lldb = callPackage ../common/lldb.nix {
+      src = callPackage ({ runCommand }: runCommand "lldb-src-${version}" {} ''
+        mkdir -p "$out"
+        cp -r ${monorepoSrc}/cmake "$out"
+        cp -r ${monorepoSrc}/lldb "$out"
+      '') { };
+      patches =
+        [
+          # FIXME: do we need this? ./procfs.patch
+          ../common/lldb/gnu-install-dirs.patch
+        ]
+        # This is a stopgap solution if/until the macOS SDK used for x86_64 is
+        # updated.
+        #
+        # The older 10.12 SDK used on x86_64 as of this writing has a `mach/machine.h`
+        # header that does not define `CPU_SUBTYPE_ARM64E` so we replace the one use
+        # of this preprocessor symbol in `lldb` with its expansion.
+        #
+        # See here for some context:
+        # https://github.com/NixOS/nixpkgs/pull/194634#issuecomment-1272129132
+        ++ lib.optional (
+          stdenv.targetPlatform.isDarwin
+            && !stdenv.targetPlatform.isAarch64
+            && (lib.versionOlder darwin.apple_sdk.sdk.version "11.0")
+        ) ./lldb/cpu_subtype_arm64e_replacement.patch;
+      inherit llvm_meta;
+    };
+
+    # Below, is the LLVM bootstrapping logic. It handles building a
+    # fully LLVM toolchain from scratch. No GCC toolchain should be
+    # pulled in. As a consequence, it is very quick to build different
+    # targets provided by LLVM and we can also build for what GCC
+    # doesn’t support like LLVM. Probably we should move to some other
+    # file.
+
+    bintools-unwrapped = callPackage ../common/bintools.nix { };
+
+    bintoolsNoLibc = wrapBintoolsWith {
+      bintools = tools.bintools-unwrapped;
+      libc = preLibcCrossHeaders;
+    };
+
+    bintools = wrapBintoolsWith {
+      bintools = tools.bintools-unwrapped;
+    };
+
+    clangUseLLVM = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      libcxx = targetLlvmLibraries.libcxx;
+      bintools = bintools';
+      extraPackages = [
+        targetLlvmLibraries.compiler-rt
+      ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
+        targetLlvmLibraries.libunwind
+      ];
+      extraBuildCommands = mkExtraBuildCommands cc;
+      nixSupport.cc-cflags =
+        [ "-rtlib=compiler-rt"
+          "-Wno-unused-command-line-argument"
+          "-B${targetLlvmLibraries.compiler-rt}/lib"
+        ]
+        ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
+        ++ lib.optional
+          (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
+          "-lunwind"
+        ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+      nixSupport.cc-ldflags = lib.optionals (!stdenv.targetPlatform.isWasm) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
+    };
+
+    clangNoLibcxx = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      libcxx = null;
+      bintools = bintools';
+      extraPackages = [
+        targetLlvmLibraries.compiler-rt
+      ];
+      extraBuildCommands = mkExtraBuildCommands cc;
+      nixSupport.cc-cflags =
+        [
+          "-rtlib=compiler-rt"
+          "-B${targetLlvmLibraries.compiler-rt}/lib"
+          "-nostdlib++"
+        ]
+        ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+    };
+
+    clangNoLibc = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      libcxx = null;
+      bintools = bintoolsNoLibc';
+      extraPackages = [
+        targetLlvmLibraries.compiler-rt
+      ];
+      extraBuildCommands = mkExtraBuildCommands cc;
+      nixSupport.cc-cflags =
+        [
+          "-rtlib=compiler-rt"
+          "-B${targetLlvmLibraries.compiler-rt}/lib"
+        ]
+        ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+    };
+
+    clangNoCompilerRt = wrapCCWith rec {
+      cc = tools.clang-unwrapped;
+      libcxx = null;
+      bintools = bintoolsNoLibc';
+      extraPackages = [ ];
+      extraBuildCommands = mkExtraBuildCommands0 cc;
+      nixSupport.cc-cflags =
+        [
+          "-nostartfiles"
+        ]
+        ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+    };
+
+    clangNoCompilerRtWithLibc = wrapCCWith (rec {
+      cc = tools.clang-unwrapped;
+      libcxx = null;
+      bintools = bintools';
+      extraPackages = [ ];
+      extraBuildCommands = mkExtraBuildCommands0 cc;
+    } // lib.optionalAttrs stdenv.targetPlatform.isWasm {
+      nixSupport.cc-cflags = [ "-fno-exceptions" ];
+    });
+
+    # Has to be in tools despite mostly being a library,
+    # because we use a native helper executable from a
+    # non-cross build in cross builds.
+    libclc = callPackage ../common/libclc.nix {
+      inherit buildLlvmTools;
+    };
+  });
+
+  libraries = lib.makeExtensible (libraries: let
+    callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc; });
+  in {
+
+    compiler-rt-libc = callPackage ./compiler-rt {
+      inherit llvm_meta;
+      stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic)
+               then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc
+               else stdenv;
+    };
+
+    compiler-rt-no-libc = callPackage ./compiler-rt {
+      inherit llvm_meta;
+      stdenv = if stdenv.hostPlatform.useLLVM or false
+               then overrideCC stdenv buildLlvmTools.clangNoCompilerRt
+               else stdenv;
+    };
+
+    # N.B. condition is safe because without useLLVM both are the same.
+    compiler-rt = if stdenv.hostPlatform.isAndroid || stdenv.hostPlatform.isDarwin
+      then libraries.compiler-rt-libc
+      else libraries.compiler-rt-no-libc;
+
+    stdenv = overrideCC stdenv buildLlvmTools.clang;
+
+    libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
+
+    # `libcxx` requires a fairly modern C++ compiler,
+    # so: we use the clang from this LLVM package set instead of the regular
+    # stdenv's compiler.
+    libcxx = callPackage ./libcxx {
+      inherit llvm_meta;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
+    };
+
+    libunwind = callPackage ./libunwind {
+      inherit llvm_meta;
+      stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
+    };
+
+    openmp = callPackage ./openmp {
+      inherit llvm_meta targetLlvm;
+    };
+  });
+  noExtend = extensible: lib.attrsets.removeAttrs extensible [ "extend" ];
+
+in { inherit tools libraries release_version; } // (noExtend libraries) // (noExtend tools)
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/0001-darwin-10.12-mbstate_t-fix.patch b/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/0001-darwin-10.12-mbstate_t-fix.patch
new file mode 100644
index 000000000000..29942f8ed03d
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/0001-darwin-10.12-mbstate_t-fix.patch
@@ -0,0 +1,31 @@
+From 9c1cb26c1dd3f92d1c1177e548107d2cd3c5e616 Mon Sep 17 00:00:00 2001
+From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>
+Date: Fri, 23 Feb 2024 22:58:58 +0000
+Subject: [PATCH] darwin 10.12 mbstate_t fix
+
+https://github.com/llvm/llvm-project/issues/64226
+
+removes space from
+https://github.com/macports/macports-ports/raw/acd8acb171f1658596ed1cf25da48d5b932e2d19/lang/llvm-17/files/0042-mbstate_t-not-defined.patch
+so it applies cleanly
+---
+ libcxx/include/__mbstate_t.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
+index bfa6d61..5f51112 100644
+--- a/libcxx/include/__mbstate_t.h
++++ b/libcxx/include/__mbstate_t.h
+@@ -42,6 +42,9 @@
+ #elif __has_include(<bits/types/mbstate_t.h>)
+ #  include <bits/types/mbstate_t.h> // works on most Unixes
+ #elif __has_include(<sys/_types/_mbstate_t.h>)
++#  if __has_include(<machine/_types.h>)
++#    include <machine/_types.h>
++#  endif
+ #  include <sys/_types/_mbstate_t.h> // works on Darwin
+ #elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)
+ #  include_next <wchar.h> // fall back to the C standard provider of mbstate_t
+-- 
+2.43.0
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/default.nix
new file mode 100644
index 000000000000..d6c304c0b476
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/libcxx/default.nix
@@ -0,0 +1,130 @@
+{ lib, stdenv, llvm_meta
+, monorepoSrc, runCommand
+, cmake, lndir, ninja, python3, fixDarwinDylibNames, version
+, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
+, libcxxrt, libunwind
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
+
+# external cxxabi is not supported on Darwin as the build will not link libcxx
+# properly and not re-export the cxxabi symbols into libcxx
+# https://github.com/NixOS/nixpkgs/issues/166205
+# https://github.com/NixOS/nixpkgs/issues/269548
+assert cxxabi == null || !stdenv.hostPlatform.isDarwin;
+let
+  basename = "libcxx";
+  cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}";
+  runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi";
+
+  # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
+  useLLVM = stdenv.hostPlatform.useLLVM or false;
+
+  cxxabiCMakeFlags = [
+    "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXXABI_ENABLE_THREADS=OFF"
+    "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXXABI_ENABLE_SHARED=OFF"
+  ];
+
+  cxxCMakeFlags = [
+    "-DLIBCXX_CXX_ABI=${cxxabiName}"
+  ] ++ lib.optionals (cxxabi != null) [
+    "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include"
+  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [
+    "-DLIBCXX_HAS_MUSL_LIBC=1"
+  ] ++ lib.optionals (lib.versionAtLeast version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s"
+  ] ++ lib.optionals useLLVM [
+    "-DLIBCXX_USE_COMPILER_RT=ON"
+    # There's precedent for this in llvm-project/libcxx/cmake/caches.
+    # In a monorepo build you might do the following in the libcxxabi build:
+    #   -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder
+    #   -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On
+    # libcxx appears to require unwind and doesn't pull it in via other means.
+    "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DLIBCXX_ENABLE_THREADS=OFF"
+    "-DLIBCXX_ENABLE_FILESYSTEM=OFF"
+    "-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
+  ] ++ lib.optionals (!enableShared) [
+    "-DLIBCXX_ENABLE_SHARED=OFF"
+  ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}"
+  ] ++ lib.optionals stdenv.hostPlatform.isWasm [
+    "-DCMAKE_C_COMPILER_WORKS=ON"
+    "-DCMAKE_CXX_COMPILER_WORKS=ON"
+    "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker
+  ] ++ cxxCMakeFlags
+    ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags;
+
+in
+
+stdenv.mkDerivation rec {
+  pname = basename;
+  inherit version cmakeFlags;
+
+  src = runCommand "${pname}-src-${version}" {} (''
+    mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/libcxx "$out"
+    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
+    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
+    cp -r ${monorepoSrc}/third-party "$out"
+    cp -r ${monorepoSrc}/runtimes "$out"
+  '' + lib.optionalString (cxxabi == null) ''
+    cp -r ${monorepoSrc}/libcxxabi "$out"
+  '');
+
+  outputs = [ "out" "dev" ];
+
+  patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
+    # https://github.com/llvm/llvm-project/issues/64226
+    ./0001-darwin-10.12-mbstate_t-fix.patch
+  ];
+
+  postPatch = ''
+    cd runtimes
+  '';
+
+  preConfigure = lib.optionalString stdenv.hostPlatform.isMusl ''
+    patchShebangs utils/cat_files.py
+  '';
+
+  nativeBuildInputs = [ cmake ninja python3 ]
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames
+    ++ lib.optional (cxxabi != null) lndir;
+
+  buildInputs = [ cxxabi ]
+    ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ];
+
+  # libc++.so is a linker script which expands to multiple libraries,
+  # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
+  # support linker scripts so the external cxxabi needs to be symlinked in
+  postInstall = lib.optionalString (cxxabi != null) ''
+    lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
+    lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
+  '';
+
+  passthru = {
+    isLLVM = true;
+  };
+
+  meta = llvm_meta // {
+    homepage = "https://libcxx.llvm.org/";
+    description = "C++ standard library";
+    longDescription = ''
+      libc++ is an implementation of the C++ standard library, targeting C++11,
+      C++14 and above.
+    '';
+    # "All of the code in libc++ is dual licensed under the MIT license and the
+    # UIUC License (a BSD-like license)":
+    license = with lib.licenses; [ mit ncsa ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/libunwind/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/libunwind/default.nix
new file mode 100644
index 000000000000..e67823ffb85c
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/libunwind/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv, llvm_meta, version
+, monorepoSrc, runCommand
+, cmake
+, ninja
+, python3
+, enableShared ? !stdenv.hostPlatform.isStatic
+}:
+
+stdenv.mkDerivation rec {
+  pname = "libunwind";
+  inherit version;
+
+  # I am not so comfortable giving libc++ and friends the whole monorepo as
+  # requested, so I filter it to what is needed.
+  src = runCommand "${pname}-src-${version}" {} ''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${pname} "$out"
+    mkdir -p "$out/libcxx"
+    cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
+    cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
+    mkdir -p "$out/llvm"
+    cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
+    cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
+    cp -r ${monorepoSrc}/runtimes "$out"
+  '';
+
+  sourceRoot = "${src.name}/runtimes";
+
+  postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
+    # libcxxabi wants to link to libunwind_shared.so (?).
+    ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
+  '';
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ cmake ninja python3 ];
+
+  cmakeFlags = [
+    "-DLLVM_ENABLE_RUNTIMES=libunwind"
+  ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
+
+  meta = llvm_meta // {
+    # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
+    homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
+    description = "LLVM's unwinder library";
+    longDescription = ''
+      The unwind library provides a family of _Unwind_* functions implementing
+      the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
+      I). It is a dependency of the C++ ABI library, and sometimes is a
+      dependency of other runtimes.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/lld/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/lld/default.nix
new file mode 100644
index 000000000000..24ff0933dd1d
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/lld/default.nix
@@ -0,0 +1,57 @@
+{ lib, stdenv, llvm_meta
+, buildLlvmTools
+, monorepoSrc, runCommand
+, cmake
+, ninja
+, libxml2
+, libllvm
+, version
+}:
+
+stdenv.mkDerivation rec {
+  pname = "lld";
+  inherit version;
+
+  # Blank llvm dir just so relative path works
+  src = runCommand "${pname}-src-${version}" {} ''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${pname} "$out"
+    mkdir -p "$out/libunwind"
+    cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
+    mkdir -p "$out/llvm"
+  '';
+
+  sourceRoot = "${src.name}/${pname}";
+
+  nativeBuildInputs = [ cmake ninja ];
+  buildInputs = [ libllvm libxml2 ];
+
+  patches = [
+    ./gnu-install-dirs.patch
+  ];
+
+  cmakeFlags = [
+    "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
+  ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
+  ];
+
+  # Musl's default stack size is too small for lld to be able to link Firefox.
+  LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152";
+
+  outputs = [ "out" "lib" "dev" ];
+
+  meta = llvm_meta // {
+    homepage = "https://lld.llvm.org/";
+    description = "The LLVM linker (unwrapped)";
+    longDescription = ''
+      LLD is a linker from the LLVM project that is a drop-in replacement for
+      system linkers and runs much faster than them. It also provides features
+      that are useful for toolchain developers.
+      The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
+      WebAssembly in descending order of completeness. Internally, LLD consists
+      of several different linkers.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch
new file mode 100644
index 000000000000..6c73a240ab6d
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/lld/gnu-install-dirs.patch
@@ -0,0 +1,15 @@
+diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
+index d3924f7243d4..42a7cd62281c 100644
+--- a/cmake/modules/AddLLD.cmake
++++ b/cmake/modules/AddLLD.cmake
+@@ -18,8 +18,8 @@ macro(add_lld_library name)
+     install(TARGETS ${name}
+       COMPONENT ${name}
+       ${export_to_lldtargets}
+-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
++      LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
++      ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}"
+       RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ 
+     if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/lldb/cpu_subtype_arm64e_replacement.patch b/nixpkgs/pkgs/development/compilers/llvm/18/lldb/cpu_subtype_arm64e_replacement.patch
new file mode 100644
index 000000000000..20d35c9f3ea9
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/lldb/cpu_subtype_arm64e_replacement.patch
@@ -0,0 +1,12 @@
+diff --git a/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+--- a/source/Host/macosx/objcxx/HostInfoMacOSX.mm
++++ b/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+@@ -233,7 +233,7 @@ void HostInfoMacOSX::ComputeHostArchitectureSupport(ArchSpec &arch_32,
+     len = sizeof(is_64_bit_capable);
+     ::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0);
+ 
+-    if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) {
++    if (cputype == CPU_TYPE_ARM64 && cpusubtype == ((cpu_subtype_t) 2)) { // CPU_SUBTYPE_ARM64E is not available in the macOS 10.12 headers
+       // The arm64e architecture is a preview. Pretend the host architecture
+       // is arm64.
+       cpusubtype = CPU_SUBTYPE_ARM64_ALL;
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/lldb/procfs.patch b/nixpkgs/pkgs/development/compilers/llvm/18/lldb/procfs.patch
new file mode 100644
index 000000000000..7b200e86505c
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/lldb/procfs.patch
@@ -0,0 +1,46 @@
+--- a/source/Plugins/Process/Linux/Procfs.h
++++ b/source/Plugins/Process/Linux/Procfs.h
+@@ -10,6 +10,13 @@
+ // sys/procfs.h on Android/Linux for all supported architectures.
+ 
+ #include <sys/ptrace.h>
++#include <asm/ptrace.h>
++
++// on i686 preprocessor symbols with these register names are defined as
++// numeric constants; these symbols clash with identifier names used in
++// `llvm/Support/VirtualFileSystem.h` and `llvm/ADT/SmallVector.h`
++#undef FS
++#undef CS
+ 
+ #include "lldb/lldb-types.h"
+ 
+@@ -17,23 +24,13 @@
+ 
+ #include <vector>
+ 
+-#ifdef __ANDROID__
+-#if defined(__arm64__) || defined(__aarch64__)
+-typedef unsigned long elf_greg_t;
+-typedef elf_greg_t
+-    elf_gregset_t[(sizeof(struct user_pt_regs) / sizeof(elf_greg_t))];
+-typedef struct user_fpsimd_state elf_fpregset_t;
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#elif defined(__mips__)
+-#ifndef NT_FPREGSET
+-#define NT_FPREGSET NT_PRFPREG
+-#endif // NT_FPREGSET
+-#endif
+-#else // __ANDROID__
++#if !defined(__GLIBC__) && defined(__powerpc__)
++#define pt_regs musl_pt_regs
++#include <sys/procfs.h>
++#undef pt_regs
++#else
+ #include <sys/procfs.h>
+-#endif // __ANDROID__
++#endif
+ 
+ namespace lldb_private {
+ namespace process_linux {
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/default.nix
new file mode 100644
index 000000000000..670171a707f9
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/default.nix
@@ -0,0 +1,439 @@
+{ lib, stdenv, llvm_meta
+, pkgsBuildBuild
+, monorepoSrc
+, runCommand
+, cmake
+, darwin
+, ninja
+, python3
+, python3Packages
+, libffi
+, enableGoldPlugin ? true
+, libbfd
+, libpfm
+, libxml2
+, ncurses
+, version
+, release_version
+, zlib
+, which
+, sysctl
+, buildLlvmTools
+, debugVersion ? false
+, doCheck ? (!stdenv.isx86_32 /* TODO: why */) && (!stdenv.hostPlatform.isMusl)
+  && (stdenv.hostPlatform == stdenv.buildPlatform)
+, enableManpages ? false
+, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
+, enablePFM ? stdenv.isLinux /* PFM only supports Linux */
+  # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
+  # broken for the armv7l builder
+  && !stdenv.hostPlatform.isAarch
+, enablePolly ? true
+}:
+
+let
+  inherit (lib) optional optionals optionalString;
+
+  # Used when creating a version-suffixed symlink of libLLVM.dylib
+  shortVersion = with lib;
+    concatStringsSep "." (take 1 (splitString "." release_version));
+
+  # Ordinarily we would just the `doCheck` and `checkDeps` functionality
+  # `mkDerivation` gives us to manage our test dependencies (instead of breaking
+  # out `doCheck` as a package level attribute).
+  #
+  # Unfortunately `lit` does not forward `$PYTHONPATH` to children processes, in
+  # particular the children it uses to do feature detection.
+  #
+  # This means that python deps we add to `checkDeps` (which the python
+  # interpreter is made aware of via `$PYTHONPATH` – populated by the python
+  # setup hook) are not picked up by `lit` which causes it to skip tests.
+  #
+  # Adding `python3.withPackages (ps: [ ... ])` to `checkDeps` also doesn't work
+  # because this package is shadowed in `$PATH` by the regular `python3`
+  # package.
+  #
+  # So, we "manually" assemble one python derivation for the package to depend
+  # on, taking into account whether checks are enabled or not:
+  python = if doCheck then
+    # Note that we _explicitly_ ask for a python interpreter for our host
+    # platform here; the splicing that would ordinarily take care of this for
+    # us does not seem to work once we use `withPackages`.
+    let
+      checkDeps = ps: with ps; [ psutil ];
+    in pkgsBuildBuild.targetPackages.python3.withPackages checkDeps
+  else python3;
+
+in
+
+stdenv.mkDerivation (rec {
+  pname = "llvm";
+  inherit version;
+
+  src = runCommand "${pname}-src-${version}" {} (''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${pname} "$out"
+    cp -r ${monorepoSrc}/third-party "$out"
+  '' + lib.optionalString enablePolly ''
+    chmod u+w "$out/${pname}/tools"
+    cp -r ${monorepoSrc}/polly "$out/${pname}/tools"
+  '');
+
+  sourceRoot = "${src.name}/${pname}";
+
+  outputs = [ "out" "lib" "dev" "python" ];
+
+  nativeBuildInputs = [ cmake ninja python ]
+    ++ optionals enableManpages [
+    # Note: we intentionally use `python3Packages` instead of `python3.pkgs`;
+    # splicing does *not* work with the latter. (TODO: fix)
+    python3Packages.sphinx
+  ] ++ optionals (lib.versionOlder version "18" && enableManpages) [
+    python3Packages.recommonmark
+  ] ++ optionals (lib.versionAtLeast version "18" && enableManpages) [
+    python3Packages.myst-parser
+  ];
+
+  buildInputs = [ libxml2 libffi ]
+    ++ optional enablePFM libpfm; # exegesis
+
+  propagatedBuildInputs = [ ncurses zlib ];
+
+  nativeCheckInputs = [
+    which
+  ] ++ lib.optional stdenv.isDarwin sysctl;
+
+  patches = [
+    ./gnu-install-dirs.patch
+
+    # Running the tests involves invoking binaries (like `opt`) that depend on
+    # the LLVM dylibs and reference them by absolute install path (i.e. their
+    # nix store path).
+    #
+    # Because we have not yet run the install phase (we're running these tests
+    # as part of `checkPhase` instead of `installCheckPhase`) these absolute
+    # paths do not exist yet; to work around this we point the loader (`ld` on
+    # unix, `dyld` on macOS) at the `lib` directory which will later become this
+    # package's `lib` output.
+    #
+    # Previously we would just set `LD_LIBRARY_PATH` to include the build `lib`
+    # dir but:
+    #   - this doesn't generalize well to other platforms; `lit` doesn't forward
+    #     `DYLD_LIBRARY_PATH` (macOS):
+    #     + https://github.com/llvm/llvm-project/blob/0d89963df354ee309c15f67dc47c8ab3cb5d0fb2/llvm/utils/lit/lit/TestingConfig.py#L26
+    #   - even if `lit` forwarded this env var, we actually cannot set
+    #     `DYLD_LIBRARY_PATH` in the child processes `lit` launches because
+    #     `DYLD_LIBRARY_PATH` (and `DYLD_FALLBACK_LIBRARY_PATH`) is cleared for
+    #     "protected processes" (i.e. the python interpreter that runs `lit`):
+    #     https://stackoverflow.com/a/35570229
+    #   - other LLVM subprojects deal with this issue by having their `lit`
+    #     configuration set these env vars for us; it makes sense to do the same
+    #     for LLVM:
+    #     + https://github.com/llvm/llvm-project/blob/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae/clang-tools-extra/test/Unit/lit.cfg.py#L22-L31
+    #
+    # !!! TODO: look into upstreaming this patch
+    ./llvm-lit-cfg-add-libs-to-dylib-path.patch
+
+    # `lit` has a mode where it executes run lines as a shell script which is
+    # constructs; this is problematic for macOS because it means that there's
+    # another process in between `lit` and the binaries being tested. As noted
+    # above, this means that `DYLD_LIBRARY_PATH` is cleared which means that our
+    # tests fail with dyld errors.
+    #
+    # To get around this we patch `lit` to reintroduce `DYLD_LIBRARY_PATH`, when
+    # present in the test configuration.
+    #
+    # It's not clear to me why this isn't an issue for LLVM developers running
+    # on macOS (nothing about this _seems_ nix specific)..
+    ./lit-shell-script-runner-set-dyld-library-path.patch
+  ] ++ lib.optionals enablePolly [
+    ./gnu-install-dirs-polly.patch
+
+    # Just like the `llvm-lit-cfg` patch, but for `polly`.
+    ./polly-lit-cfg-add-libs-to-dylib-path.patch
+  ];
+
+  postPatch = optionalString stdenv.isDarwin ''
+    substituteInPlace cmake/modules/AddLLVM.cmake \
+      --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
+      --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
+
+    # As of LLVM 15, marked as XFAIL on arm64 macOS but lit doesn't seem to pick
+    # this up: https://github.com/llvm/llvm-project/blob/c344d97a125b18f8fed0a64aace73c49a870e079/llvm/test/MC/ELF/cfi-version.ll#L7
+    rm test/MC/ELF/cfi-version.ll
+
+    # This test tries to call `sw_vers` by absolute path (`/usr/bin/sw_vers`)
+    # and thus fails under the sandbox:
+    substituteInPlace unittests/TargetParser/Host.cpp \
+      --replace '/usr/bin/sw_vers' "${(builtins.toString darwin.DarwinTools) + "/bin/sw_vers" }"
+
+    # This test tries to call the intrinsics `@llvm.roundeven.f32` and
+    # `@llvm.roundeven.f64` which seem to (incorrectly?) lower to `roundevenf`
+    # and `roundeven` on macOS.
+    #
+    # However these functions are glibc specific so the test fails:
+    #   - https://www.gnu.org/software/gnulib/manual/html_node/roundevenf.html
+    #   - https://www.gnu.org/software/gnulib/manual/html_node/roundeven.html
+    #
+    substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \
+      --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \
+      --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" ""
+
+    # fails when run in sandbox
+    substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \
+      --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure"
+  '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) ''
+    # This test fails on darwin x86_64 because `sw_vers` reports a different
+    # macOS version than what LLVM finds by reading
+    # `/System/Library/CoreServices/SystemVersion.plist` (which is passed into
+    # the sandbox on macOS).
+    #
+    # The `sw_vers` provided by nixpkgs reports the macOS version associated
+    # with the `CoreFoundation` framework with which it was built. Because
+    # nixpkgs pins the SDK for `aarch64-darwin` and `x86_64-darwin` what
+    # `sw_vers` reports is not guaranteed to match the macOS version of the host
+    # that's building this derivation.
+    #
+    # Astute readers will note that we only _patch_ this test on aarch64-darwin
+    # (to use the nixpkgs provided `sw_vers`) instead of disabling it outright.
+    # So why does this test pass on aarch64?
+    #
+    # Well, it seems that `sw_vers` on aarch64 actually links against the _host_
+    # CoreFoundation framework instead of the nixpkgs provided one.
+    #
+    # Not entirely sure what the right fix is here. I'm assuming aarch64
+    # `sw_vers` doesn't intentionally link against the host `CoreFoundation`
+    # (still digging into how this ends up happening, will follow up) but that
+    # aside I think the more pertinent question is: should we be patching LLVM's
+    # macOS version detection logic to use `sw_vers` instead of reading host
+    # paths? This *is* a way in which details about builder machines can creep
+    # into the artifacts that are produced, affecting reproducibility, but it's
+    # not clear to me when/where/for what this even gets used in LLVM.
+    #
+    # TODO(@rrbutani): fix/follow-up
+    substituteInPlace unittests/TargetParser/Host.cpp \
+      --replace "getMacOSHostVersion" "DISABLED_getMacOSHostVersion"
+
+    # This test fails with a `dysmutil` crash; have not yet dug into what's
+    # going on here (TODO(@rrbutani)).
+    rm test/tools/dsymutil/ARM/obfuscated.test
+  '' + ''
+    # FileSystem permissions tests fail with various special bits
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "Path.cpp" ""
+    rm unittests/Support/Path.cpp
+    substituteInPlace unittests/IR/CMakeLists.txt \
+      --replace "PassBuilderCallbacksTest.cpp" ""
+    rm unittests/IR/PassBuilderCallbacksTest.cpp
+    rm test/tools/llvm-objcopy/ELF/mirror-permissions-unix.test
+
+    # Fails in the presence of anti-virus software or other intrusion-detection software that
+    # modifies the atime when run. See #284056.
+    rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
+  '' + optionalString stdenv.hostPlatform.isMusl ''
+    patch -p1 -i ${../../common/llvm/TLI-musl.patch}
+    substituteInPlace unittests/Support/CMakeLists.txt \
+      --replace "add_subdirectory(DynamicLibrary)" ""
+    rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+    # valgrind unhappy with musl or glibc, but fails w/musl only
+    rm test/CodeGen/AArch64/wineh4.mir
+  '' + optionalString stdenv.hostPlatform.isAarch32 ''
+    # skip failing X86 test cases on 32-bit ARM
+    rm test/DebugInfo/X86/convert-debugloc.ll
+    rm test/DebugInfo/X86/convert-inlined.ll
+    rm test/DebugInfo/X86/convert-linked.ll
+    rm test/tools/dsymutil/X86/op-convert.test
+    rm test/tools/gold/X86/split-dwarf.ll
+    rm test/tools/llvm-dwarfdump/X86/prettyprint_types.s
+    rm test/tools/llvm-dwarfdump/X86/simplified-template-names.s
+    rm test/CodeGen/RISCV/attributes.ll
+    rm test/CodeGen/RISCV/xtheadmempair.ll
+  '' + optionalString (stdenv.hostPlatform.system == "armv6l-linux") ''
+    # Seems to require certain floating point hardware (NEON?)
+    rm test/ExecutionEngine/frem.ll
+  '' + ''
+    patchShebangs test/BugPoint/compile-custom.ll.py
+  '';
+
+  preConfigure = ''
+    # Workaround for configure flags that need to have spaces
+    cmakeFlagsArray+=(
+      -DLLVM_LIT_ARGS="-svj''${NIX_BUILD_CORES} --no-progress-bar"
+    )
+  '';
+
+  # Defensive check: some paths (that we make symlinks to) depend on the release
+  # version, for example:
+  #  - https://github.com/llvm/llvm-project/blob/406bde9a15136254f2b10d9ef3a42033b3cb1b16/clang/lib/Headers/CMakeLists.txt#L185
+  #
+  # So we want to sure that the version in the source matches the release
+  # version we were given.
+  #
+  # We do this check here, in the LLVM build, because it happens early.
+  postConfigure = let
+    v = lib.versions;
+    major = v.major release_version;
+    minor = v.minor release_version;
+    patch = v.patch release_version;
+  in ''
+    # $1: part, $2: expected
+    check_version() {
+      part="''${1^^}"
+      part="$(cat include/llvm/Config/llvm-config.h  | grep "#define LLVM_VERSION_''${part} " | cut -d' ' -f3)"
+
+      if [[ "$part" != "$2" ]]; then
+        echo >&2 \
+          "mismatch in the $1 version! we have version ${release_version}" \
+          "and expected the $1 version to be '$2'; the source has '$part' instead"
+        exit 3
+      fi
+    }
+
+    check_version major ${major}
+    check_version minor ${minor}
+    check_version patch ${patch}
+  '';
+
+  # E.g. mesa.drivers use the build-id as a cache key (see #93946):
+  LDFLAGS = optionalString (enableSharedLibraries && !stdenv.isDarwin) "-Wl,--build-id=sha1";
+
+  hardeningDisable = [ "trivialautovarinit" ];
+
+  cmakeBuildType = if debugVersion then "Debug" else "Release";
+
+  cmakeFlags = with stdenv; let
+    # These flags influence llvm-config's BuildVariables.inc in addition to the
+    # general build. We need to make sure these are also passed via
+    # CROSS_TOOLCHAIN_FLAGS_NATIVE when cross-compiling or llvm-config-native
+    # will return different results from the cross llvm-config.
+    #
+    # Some flags don't need to be repassed because LLVM already does so (like
+    # CMAKE_BUILD_TYPE), others are irrelevant to the result.
+    flagsForLlvmConfig = [
+      "-DLLVM_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/llvm"
+      "-DLLVM_ENABLE_RTTI=ON"
+    ] ++ optionals enableSharedLibraries [
+      "-DLLVM_LINK_LLVM_DYLIB=ON"
+    ];
+  in flagsForLlvmConfig ++ [
+    "-DLLVM_INSTALL_UTILS=ON"  # Needed by rustc
+    "-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
+    "-DLLVM_ENABLE_FFI=ON"
+    "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
+    "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
+    "-DLLVM_ENABLE_DUMP=ON"
+  ] ++ optionals stdenv.hostPlatform.isStatic [
+    # Disables building of shared libs, -fPIC is still injected by cc-wrapper
+    "-DLLVM_ENABLE_PIC=OFF"
+    "-DLLVM_BUILD_STATIC=ON"
+    "-DLLVM_LINK_LLVM_DYLIB=off"
+    # libxml2 needs to be disabled because the LLVM build system ignores its .la
+    # file and doesn't link zlib as well.
+    # https://github.com/ClangBuiltLinux/tc-build/issues/150#issuecomment-845418812
+    "-DLLVM_ENABLE_LIBXML2=OFF"
+  ] ++ optionals enableManpages [
+    "-DLLVM_BUILD_DOCS=ON"
+    "-DLLVM_ENABLE_SPHINX=ON"
+    "-DSPHINX_OUTPUT_MAN=ON"
+    "-DSPHINX_OUTPUT_HTML=OFF"
+    "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
+  ] ++ optionals enableGoldPlugin [
+    "-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
+  ] ++ optionals isDarwin [
+    "-DLLVM_ENABLE_LIBCXX=ON"
+    "-DCAN_TARGET_i386=false"
+  ] ++ optionals ((stdenv.hostPlatform != stdenv.buildPlatform) && !(stdenv.buildPlatform.canExecute stdenv.hostPlatform)) [
+    "-DCMAKE_CROSSCOMPILING=True"
+    "-DLLVM_TABLEGEN=${buildLlvmTools.llvm}/bin/llvm-tblgen"
+    (
+      let
+        nativeCC = pkgsBuildBuild.targetPackages.stdenv.cc;
+        nativeBintools = nativeCC.bintools.bintools;
+        nativeToolchainFlags = [
+          "-DCMAKE_C_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}cc"
+          "-DCMAKE_CXX_COMPILER=${nativeCC}/bin/${nativeCC.targetPrefix}c++"
+          "-DCMAKE_AR=${nativeBintools}/bin/${nativeBintools.targetPrefix}ar"
+          "-DCMAKE_STRIP=${nativeBintools}/bin/${nativeBintools.targetPrefix}strip"
+          "-DCMAKE_RANLIB=${nativeBintools}/bin/${nativeBintools.targetPrefix}ranlib"
+        ];
+        # We need to repass the custom GNUInstallDirs values, otherwise CMake
+        # will choose them for us, leading to wrong results in llvm-config-native
+        nativeInstallFlags = [
+          "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
+          "-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
+          "-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "dev"}/include"
+          "-DCMAKE_INSTALL_LIBDIR=${placeholder "lib"}/lib"
+          "-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "lib"}/libexec"
+        ];
+      in "-DCROSS_TOOLCHAIN_FLAGS_NATIVE:list="
+      + lib.concatStringsSep ";" (lib.concatLists [
+        flagsForLlvmConfig
+        nativeToolchainFlags
+        nativeInstallFlags
+      ])
+    )
+  ];
+
+  postInstall = ''
+    mkdir -p $python/share
+    mv $out/share/opt-viewer $python/share/opt-viewer
+    moveToOutput "bin/llvm-config*" "$dev"
+    substituteInPlace "$dev/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
+      --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \
+      --replace "$out/bin/llvm-config" "$dev/bin/llvm-config"
+    substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \
+      --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")'
+  ''
+  + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
+    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
+  ''
+  + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
+    cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
+  '';
+
+  inherit doCheck;
+
+  checkTarget = "check-all";
+
+  # For the update script:
+  passthru.monorepoSrc = monorepoSrc;
+
+  requiredSystemFeatures = [ "big-parallel" ];
+  meta = llvm_meta // {
+    homepage = "https://llvm.org/";
+    description = "A collection of modular and reusable compiler and toolchain technologies";
+    longDescription = ''
+      The LLVM Project is a collection of modular and reusable compiler and
+      toolchain technologies. Despite its name, LLVM has little to do with
+      traditional virtual machines. The name "LLVM" itself is not an acronym; it
+      is the full name of the project.
+      LLVM began as a research project at the University of Illinois, with the
+      goal of providing a modern, SSA-based compilation strategy capable of
+      supporting both static and dynamic compilation of arbitrary programming
+      languages. Since then, LLVM has grown to be an umbrella project consisting
+      of a number of subprojects, many of which are being used in production by
+      a wide variety of commercial and open source projects as well as being
+      widely used in academic research. Code in the LLVM project is licensed
+      under the "Apache 2.0 License with LLVM exceptions".
+    '';
+  };
+} // lib.optionalAttrs enableManpages {
+  pname = "llvm-manpages";
+
+  propagatedBuildInputs = [];
+
+  ninjaFlags = [ "docs-llvm-man" ];
+  installTargets = [ "install-docs-llvm-man" ];
+
+  postPatch = null;
+  postInstall = null;
+
+  outputs = [ "out" ];
+
+  doCheck = false;
+
+  meta = llvm_meta // {
+    description = "man pages for LLVM ${version}";
+  };
+})
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs-polly.patch b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs-polly.patch
new file mode 100644
index 000000000000..6a359bdbefde
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs-polly.patch
@@ -0,0 +1,13 @@
+--- a/tools/polly/cmake/polly_macros.cmake	2024-03-15 17:36:20.550893344 -0700
++++ b/tools/polly/cmake/polly_macros.cmake	2024-03-15 17:37:06.277332960 -0700
+@@ -45,8 +45,8 @@
+     install(TARGETS ${name}
+       COMPONENT ${name}
+       EXPORT LLVMExports
+-      LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+-      ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
++      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}
++      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+     add_llvm_install_targets(install-${name}
+       COMPONENT ${name})
+   endif()
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch
new file mode 100644
index 000000000000..8b89839490ba
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/gnu-install-dirs.patch
@@ -0,0 +1,137 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 471817d68286..c51463304159 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1010,7 +1010,7 @@ if (NOT TENSORFLOW_AOT_PATH STREQUAL "")
+   add_subdirectory(${TENSORFLOW_AOT_PATH}/xla_aot_runtime_src
+     ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tf_runtime)
+   install(TARGETS tf_xla_runtime EXPORT LLVMExports
+-    ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
++    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX} COMPONENT tf_xla_runtime)
+   set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime)
+   # Once we add more modules, we should handle this more automatically.
+   if (DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL)
+diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
+index 230620c37027..dd16cab1835e 100644
+--- a/cmake/modules/AddLLVM.cmake
++++ b/cmake/modules/AddLLVM.cmake
+@@ -876,8 +876,8 @@ macro(add_llvm_library name)
+       get_target_export_arg(${name} LLVM export_to_llvmexports ${umbrella})
+       install(TARGETS ${name}
+               ${export_to_llvmexports}
+-              LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
+-              ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT ${name}
++              LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name}
++              ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" COMPONENT ${name}
+               RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name})
+ 
+       if (NOT LLVM_ENABLE_IDE)
+@@ -2069,7 +2069,7 @@ function(llvm_install_library_symlink name dest type)
+     set(LLVM_LINK_OR_COPY copy)
+   endif()
+ 
+-  set(output_dir lib${LLVM_LIBDIR_SUFFIX})
++  set(output_dir ${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX})
+   if(WIN32 AND "${type}" STREQUAL "SHARED")
+     set(output_dir "${CMAKE_INSTALL_BINDIR}")
+   endif()
+@@ -2344,16 +2344,37 @@ function(llvm_setup_rpath name)
+ 
+   if (APPLE)
+     set(_install_name_dir INSTALL_NAME_DIR "@rpath")
+-    set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath ${extra_libdir})
+   elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS)
+     # $ORIGIN is not interpreted at link time by aix ld.
+     # Since BUILD_SHARED_LIBS is only recommended for use by developers,
+     # hardcode the rpath to build/install lib dir first in this mode.
+     # FIXME: update this when there is better solution.
+-    set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+   elseif(UNIX)
+-    set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
+-    set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}")
++    # Note that we add `extra_libdir` (aka `LLVM_LIBRARY_DIR` in our case) back
++    # to `_install_rpath` here.
++    #
++    # In nixpkgs we do not build and install LLVM alongside rdeps of LLVM (i.e.
++    # clang); instead LLVM is its own package and thus lands at its own nix
++    # store path. This makes it so that the default relative rpath (`../lib/`)
++    # does not point at the LLVM shared objects.
++    #
++    # More discussion here:
++    #   - https://github.com/NixOS/nixpkgs/pull/235624#discussion_r1220150329
++    #   - https://reviews.llvm.org/D146918 (16.0.5+)
++    #
++    # Note that we leave `extra_libdir` in `_build_rpath`: without FHS there is
++    # no potential that this will result in us pulling in the "wrong" LLVM.
++    # Adding this to the build rpath means we aren't forced to use
++    # `installCheckPhase` instead of `checkPhase` (i.e. binaries in the build
++    # dir, pre-install, will have the right rpath for LLVM).
++    #
++    # As noted in the differential above, an alternative solution is to have
++    # all rdeps of nixpkgs' LLVM (that use the AddLLVM.cmake machinery) set
++    # `CMAKE_INSTALL_RPATH`.
++    set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath ${extra_libdir})
+     if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
+       set_property(TARGET ${name} APPEND_STRING PROPERTY
+                    LINK_FLAGS " -Wl,-z,origin ")
+diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake
+index 891c9e6d618c..8d963f3b0069 100644
+--- a/cmake/modules/AddOCaml.cmake
++++ b/cmake/modules/AddOCaml.cmake
+@@ -147,9 +147,9 @@ function(add_ocaml_library name)
+   endforeach()
+ 
+   if( APPLE )
+-    set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath ${LLVM_LIBRARY_DIR})
+   elseif( UNIX )
+-    set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath ${LLVM_LIBRARY_DIR})
+   endif()
+   list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
+ 
+diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
+index d99af79aa38e..21e794224b99 100644
+--- a/cmake/modules/CMakeLists.txt
++++ b/cmake/modules/CMakeLists.txt
+@@ -127,7 +127,7 @@ set(LLVM_CONFIG_INCLUDE_DIRS
+   )
+ list(REMOVE_DUPLICATES LLVM_CONFIG_INCLUDE_DIRS)
+ 
+-extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "lib\${LLVM_LIBDIR_SUFFIX}")
++extend_path(LLVM_CONFIG_LIBRARY_DIR "\${LLVM_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}\${LLVM_LIBDIR_SUFFIX}")
+ set(LLVM_CONFIG_LIBRARY_DIRS
+   "${LLVM_CONFIG_LIBRARY_DIR}"
+   # FIXME: Should there be other entries here?
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index 370005cd8d7d..7e790bc52111 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -23,6 +23,7 @@
+ #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
+ #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
+ #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
++#define LLVM_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"
+ #define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
+ #define LLVM_INSTALL_PACKAGE_DIR "@LLVM_INSTALL_PACKAGE_DIR@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index e86eb2b44b10..f63e207e792e 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -366,7 +366,11 @@ int main(int argc, char **argv) {
+       sys::fs::make_absolute(ActivePrefix, Path);
+       ActiveBinDir = std::string(Path.str());
+     }
+-    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
++    {
++      SmallString<256> Path(LLVM_INSTALL_LIBDIR LLVM_LIBDIR_SUFFIX);
++      sys::fs::make_absolute(ActivePrefix, Path);
++      ActiveLibDir = std::string(Path.str());
++    }
+     {
+       SmallString<256> Path(LLVM_INSTALL_PACKAGE_DIR);
+       sys::fs::make_absolute(ActivePrefix, Path);
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/lit-shell-script-runner-set-dyld-library-path.patch b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/lit-shell-script-runner-set-dyld-library-path.patch
new file mode 100644
index 000000000000..e4f049f4b177
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/lit-shell-script-runner-set-dyld-library-path.patch
@@ -0,0 +1,12 @@
+--- a/utils/lit/lit/TestRunner.py	2024-03-15 17:27:53.170780798 -0700
++++ b/utils/lit/lit/TestRunner.py	2024-03-15 17:28:43.277447791 -0700
+@@ -1183,6 +1183,9 @@
+         f.write("@echo on\n")
+         f.write("\n@if %ERRORLEVEL% NEQ 0 EXIT\n".join(commands))
+     else:
++        if "DYLD_LIBRARY_PATH" in test.config.environment:
++            f.write(f'export DYLD_LIBRARY_PATH="{test.config.environment["DYLD_LIBRARY_PATH"]}"\n')
++
+         for i, ln in enumerate(commands):
+             match = re.fullmatch(kPdbgRegex, ln)
+             if match:
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
new file mode 100644
index 000000000000..d4ccb2ae9822
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch
@@ -0,0 +1,80 @@
+diff --git a/test/Unit/lit.cfg.py b/test/Unit/lit.cfg.py
+index 81e8dc04acea..479ff95681e2 100644
+--- a/test/Unit/lit.cfg.py
++++ b/test/Unit/lit.cfg.py
+@@ -3,6 +3,7 @@
+ # Configuration file for the 'lit' test runner.
+ 
+ import os
++import platform
+ import subprocess
+ 
+ import lit.formats
+@@ -55,3 +56,26 @@ if sys.platform in ["win32", "cygwin"] and os.path.isdir(config.shlibdir):
+ # Win32 may use %SYSTEMDRIVE% during file system shell operations, so propogate.
+ if sys.platform == "win32" and "SYSTEMDRIVE" in os.environ:
+     config.environment["SYSTEMDRIVE"] = os.environ["SYSTEMDRIVE"]
++
++# Add the LLVM dynamic libs to the platform-specific loader search path env var:
++#
++# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify..
++def find_shlibpath_var():
++    if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
++        yield "LD_LIBRARY_PATH"
++    elif platform.system() == "Darwin":
++        yield "DYLD_LIBRARY_PATH"
++    elif platform.system() == "Windows":
++        yield "PATH"
++    elif platform.system() == "AIX":
++        yield "LIBPATH"
++
++for shlibpath_var in find_shlibpath_var():
++    shlibpath = os.path.pathsep.join(
++        (config.shlibdir,
++         config.environment.get(shlibpath_var, '')))
++    config.environment[shlibpath_var] = shlibpath
++    break
++else:
++    lit_config.warning("unable to inject shared library path on '{}'"
++                       .format(platform.system()))
+diff --git a/test/lit.cfg.py b/test/lit.cfg.py
+index 75a38b4c5dad..856fc75c9d74 100644
+--- a/test/lit.cfg.py
++++ b/test/lit.cfg.py
+@@ -42,6 +42,26 @@ llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
+ llvm_config.with_system_environment(
+     ["HOME", "INCLUDE", "LIB", "TMP", "TEMP"])
+ 
++# Add the LLVM dynamic libs to the platform-specific loader search path env var:
++#
++# TODO: this is copied from `clang`'s `lit.cfg.py`; should unify..
++def find_shlibpath_var():
++    if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
++        yield "LD_LIBRARY_PATH"
++    elif platform.system() == "Darwin":
++        yield "DYLD_LIBRARY_PATH"
++    elif platform.system() == "Windows":
++        yield "PATH"
++    elif platform.system() == "AIX":
++        yield "LIBPATH"
++
++for shlibpath_var in find_shlibpath_var():
++    shlibpath = config.llvm_shlib_dir
++    llvm_config.with_environment(shlibpath_var, shlibpath, append_path = True)
++    break
++else:
++    lit_config.warning("unable to inject shared library path on '{}'"
++                       .format(platform.system()))
+ 
+ # Set up OCAMLPATH to include newly built OCaml libraries.
+ top_ocaml_lib = os.path.join(config.llvm_lib_dir, "ocaml")
+@@ -318,7 +338,7 @@ def have_cxx_shared_library():
+ 
+     try:
+         readobj_cmd = subprocess.Popen(
+-            [readobj_exe, "--needed-libs", readobj_exe], stdout=subprocess.PIPE
++            [readobj_exe, "--needed-libs", readobj_exe], stdout=subprocess.PIPE, env=config.environment
+         )
+     except OSError:
+         print("could not exec llvm-readobj")
+
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
new file mode 100644
index 000000000000..1354ad267314
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch
@@ -0,0 +1,24 @@
+diff --git a/tools/polly/test/lit.cfg b/tools/polly/test/lit.cfg
+index 41e3a589c61e..09f3b17498b0 100644
+--- a/tools/polly/test/lit.cfg
++++ b/tools/polly/test/lit.cfg
+@@ -36,9 +36,17 @@ base_paths = [config.llvm_tools_dir, config.environment['PATH']]
+ path = os.path.pathsep.join(base_paths + config.extra_paths)
+ config.environment['PATH'] = path
+ 
++# (Copied from polly/test/Unit/lit.cfg)
++if platform.system() == 'Darwin':
++    shlibpath_var = 'DYLD_LIBRARY_PATH'
++elif platform.system() == 'Windows':
++    shlibpath_var = 'PATH'
++else:
++    shlibpath_var = 'LD_LIBRARY_PATH'
++
+ path = os.path.pathsep.join((config.llvm_libs_dir,
+-                              config.environment.get('LD_LIBRARY_PATH','')))
+-config.environment['LD_LIBRARY_PATH'] = path
++                              config.environment.get(shlibpath_var,'')))
++config.environment[shlibpath_var] = path
+ 
+ llvm_config.use_default_substitutions()
+ 
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/openmp/default.nix b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/default.nix
new file mode 100644
index 000000000000..e1c3c2379af2
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/default.nix
@@ -0,0 +1,73 @@
+{ lib
+, stdenv
+, llvm_meta
+, monorepoSrc
+, runCommand
+, cmake
+, ninja
+, llvm
+, targetLlvm
+, lit
+, clang-unwrapped
+, perl
+, pkg-config
+, xcbuild
+, version
+}:
+
+stdenv.mkDerivation rec {
+  pname = "openmp";
+  inherit version;
+
+  src = runCommand "${pname}-src-${version}" {} ''
+    mkdir -p "$out"
+    cp -r ${monorepoSrc}/cmake "$out"
+    cp -r ${monorepoSrc}/${pname} "$out"
+  '';
+
+  sourceRoot = "${src.name}/${pname}";
+
+  patches = [
+    ./fix-find-tool.patch
+    ./run-lit-directly.patch
+  ];
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ cmake ninja perl pkg-config lit ];
+  buildInputs = [
+    (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm)
+  ];
+
+  nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
+
+  # Unsup:Pass:XFail:Fail
+  # 26:267:16:8
+  doCheck = false;
+  checkTarget = "check-openmp";
+
+  preCheck = ''
+    patchShebangs ../tools/archer/tests/deflake.bash
+  '';
+
+  cmakeFlags = [
+    "-DCLANG_TOOL=${clang-unwrapped}/bin/clang"
+    "-DOPT_TOOL=${llvm}/bin/opt"
+    "-DLINK_TOOL=${llvm}/bin/llvm-link"
+  ];
+
+  meta = llvm_meta // {
+    homepage = "https://openmp.llvm.org/";
+    description = "Support for the OpenMP language";
+    longDescription = ''
+      The OpenMP subproject of LLVM contains the components required to build an
+      executable OpenMP program that are outside the compiler itself.
+      Contains the code for the runtime library against which code compiled by
+      "clang -fopenmp" must be linked before it can run and the library that
+      supports offload to target devices.
+    '';
+    # "All of the code is dual licensed under the MIT license and the UIUC
+    # License (a BSD-like license)":
+    license = with lib.licenses; [ mit ncsa ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/openmp/fix-find-tool.patch b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/fix-find-tool.patch
new file mode 100644
index 000000000000..b7f51196f7ba
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/fix-find-tool.patch
@@ -0,0 +1,17 @@
+diff --git a/libomptarget/DeviceRTL/CMakeLists.txt b/libomptarget/DeviceRTL/CMakeLists.txt
+index 630947abec7e..9f032dc7bd3f 100644
+--- a/libomptarget/DeviceRTL/CMakeLists.txt
++++ b/libomptarget/DeviceRTL/CMakeLists.txt
+@@ -27,10 +27,10 @@ endif()
+ if (LLVM_DIR)
+   # Builds that use pre-installed LLVM have LLVM_DIR set.
+   # A standalone or LLVM_ENABLE_RUNTIMES=openmp build takes this route
+-  find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
++  find_program(CLANG_TOOL clang PATHS ${LLVM_TOOLS_BINARY_DIR})
+   find_program(PACKAGER_TOOL clang-offload-packager PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
+   find_program(LINK_TOOL llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
+-  find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
++  find_program(OPT_TOOL opt PATHS ${LLVM_TOOLS_BINARY_DIR})
+   if ((NOT CLANG_TOOL) OR (NOT LINK_TOOL) OR (NOT OPT_TOOL) OR (NOT PACKAGER_TOOL))
+     libomptarget_say("Not building DeviceRTL. Missing clang: ${CLANG_TOOL}, llvm-link: ${LINK_TOOL}, opt: ${OPT_TOOL}, or clang-offload-packager: ${PACKAGER_TOOL}")
+     return()
diff --git a/nixpkgs/pkgs/development/compilers/llvm/18/openmp/run-lit-directly.patch b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/run-lit-directly.patch
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/llvm/18/openmp/run-lit-directly.patch
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix
index 01b33c540ca2..1e777c6132e4 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/clang/default.nix
@@ -70,9 +70,6 @@ let
     postInstall = ''
       ln -sv $out/bin/clang $out/bin/cpp
 
-      mkdir -p $lib/lib/clang
-      mv $lib/lib/${lib.versions.major version} $lib/lib/clang/${lib.versions.major version}
-
       # Move libclang to 'lib' output
       moveToOutput "lib/libclang.*" "$lib"
       moveToOutput "lib/libclang-cpp.*" "$lib"
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch
index cc8737f35343..9517df973ad0 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch
@@ -1,30 +1,3 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index f7936d72e088..a362fa49b534 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -31,7 +31,21 @@ if(CLANG_BUILT_STANDALONE)
-   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
- 
--  # Turn into CACHE PATHs for overwritting
-+  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-+  # LLVM_CONFIG.
-+  if (NOT LLVM_CONFIG_FOUND)
-+    # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-+    # path is removed.
-+    set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
-+    set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-+    # N.B. this is just a default value, the CACHE PATHs below can be overriden.
-+    set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-+    set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
-+    set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
-+  else()
-+    set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
-+  endif()
-+
-   set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-   set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
-   set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
 diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
 index 75b0080f6715..c895b884cd27 100644
 --- a/cmake/modules/AddClang.cmake
@@ -48,7 +21,7 @@ index f2b0c5cddcbb..52f37fc368ce 100644
  add_header_target("utility-resource-headers" ${utility_files})
  
  get_clang_resource_dir(header_install_dir SUBDIR include)
-+set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/${CLANG_VERSION_MAJOR}/include)
++set(header_install_dir ${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include)
  
  #############################################################
  # Install rules for the catch-all clang-resource-headers target
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
index 51f4e95ef2b5..f51316beb570 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/default.nix
@@ -87,12 +87,9 @@ stdenv.mkDerivation {
 
   patches = [
     ./X86-support-extension.patch # Add support for i486 i586 i686 by reusing i386 config
-    ./gnu-install-dirs.patch
     # ld-wrapper dislikes `-rpath-link //nix/store`, so we normalize away the
     # extra `/`.
     ./normalize-var.patch
-    # Prevent a compilation error on darwin
-    ./darwin-targetconditionals.patch
     # See: https://github.com/NixOS/nixpkgs/pull/186575
     ../../common/compiler-rt/darwin-plistbuddy-workaround.patch
     # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893
@@ -111,6 +108,8 @@ stdenv.mkDerivation {
     substituteInPlace cmake/config-ix.cmake \
       --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
   '' + lib.optionalString (useLLVM && !haveLibc) ''
+    substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \
+      --replace "<stdlib.h>" "<stddef.h>"
     substituteInPlace lib/builtins/int_util.c \
       --replace "#include <stdlib.h>" ""
     substituteInPlace lib/builtins/clear_cache.c \
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch
deleted file mode 100644
index f3b1f63a7d71..000000000000
--- a/nixpkgs/pkgs/development/compilers/llvm/git/compiler-rt/gnu-install-dirs.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
-index 8a6219568b3f..30ee68a47ccf 100644
---- a/cmake/base-config-ix.cmake
-+++ b/cmake/base-config-ix.cmake
-@@ -100,13 +100,13 @@ endif()
- if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   set(COMPILER_RT_OUTPUT_LIBRARY_DIR
-     ${COMPILER_RT_OUTPUT_DIR}/lib)
--  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib)
-+  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}")
-   set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH
-     "Path where built compiler-rt libraries should be installed.")
- else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
-   set(COMPILER_RT_OUTPUT_LIBRARY_DIR
-     ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
--  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "lib/${COMPILER_RT_OS_DIR}")
-+  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_LIBDIR}/${COMPILER_RT_OS_DIR}")
-   set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH
-     "Path where built compiler-rt libraries should be installed.")
- endif()
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
index 6ebb2ea9fcc2..80cff85372d0 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/default.nix
@@ -17,15 +17,20 @@
     else pkgs.bintools
 , darwin
 # LLVM release information; specify one of these but not both:
-, gitRelease ? null
+, gitRelease ? {
+    version = "19.0.0-git";
+    rev = "65058a8d732c3c41664a4dad1a1ae2a504d5c98e";
+    rev-version = "19.0.0-unstable-2024-03-16";
+    sha256 = "sha256-xV33kx/8OZ2KLtaz25RmudDrlIX7nScauTykf87jyTE=";
+}
   # i.e.:
   # {
   #   version = /* i.e. "15.0.0" */;
   #   rev = /* commit SHA */;
-  #   rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
+  #   rev-version = /* human readable version; i.e. "15.0.0-unstable-2022-07-26" */;
   #   sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
   # }
-, officialRelease ? { version = "18.1.0-rc4"; sha256 = "sha256-fVpwewbjoPMPslIEZ+WAtaQ+YKc0XWGl8EbP/TbQb8o="; }
+, officialRelease ? null
   # i.e.:
   # {
   #   version = /* i.e. "15.0.0" */;
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
index 4e3404dbe194..d6c304c0b476 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libcxx/default.nix
@@ -1,5 +1,5 @@
 { lib, stdenv, llvm_meta
-, monorepoSrc, runCommand, fetchpatch
+, monorepoSrc, runCommand
 , cmake, lndir, ninja, python3, fixDarwinDylibNames, version
 , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null
 , libcxxrt, libunwind
@@ -19,11 +19,11 @@ let
   # Note: useLLVM is likely false for Darwin but true under pkgsLLVM
   useLLVM = stdenv.hostPlatform.useLLVM or false;
 
-  cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
-    "-DLIBCXXABI_USE_COMPILER_RT=ON"
-    "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
-  ] ++ lib.optionals (lib.versionAtLeast version "18" && !(useLLVM && !stdenv.hostPlatform.isWasm)) [
+  cxxabiCMakeFlags = [
     "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
+  ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [
+    "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind"
+    "-DLIBCXXABI_USE_COMPILER_RT=ON"
   ] ++ lib.optionals stdenv.hostPlatform.isWasm [
     "-DLIBCXXABI_ENABLE_THREADS=OFF"
     "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
@@ -87,18 +87,6 @@ stdenv.mkDerivation rec {
   patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
     # https://github.com/llvm/llvm-project/issues/64226
     ./0001-darwin-10.12-mbstate_t-fix.patch
-  ] ++ lib.optionals (cxxabi == null && lib.versionAtLeast version "18") [
-    # Allow building libcxxabi alone when using LLVM unwinder
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/77610dd10454e87bb387040d2b51100a17ac5755.patch";
-      revert = true;
-      hash = "sha256-jFbC3vBY3nKfjknJ7UzaPyoy0iSYdD3+jUmOFeOaVcA=";
-    })
-    (fetchpatch {
-      url = "https://github.com/llvm/llvm-project/commit/48e5b5ea92674ded69b998cf35724d9012c0f57d.patch";
-      revert = true;
-      hash = "sha256-WN63L4T3GxVozPZb6kx21AgNe4rwwSUOeeryIGsvQYY=";
-    })
   ];
 
   postPatch = ''
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix
index a3c8e2594f5a..e67823ffb85c 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/libunwind/default.nix
@@ -27,15 +27,6 @@ stdenv.mkDerivation rec {
 
   sourceRoot = "${src.name}/runtimes";
 
-  prePatch = ''
-    cd ../${pname}
-    chmod -R u+w .
-  '';
-
-  postPatch = ''
-    cd ../runtimes
-  '';
-
   postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
     # libcxxabi wants to link to libunwind_shared.so (?).
     ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lld/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/lld/default.nix
index cc18aee76a44..24ff0933dd1d 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/lld/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/lld/default.nix
@@ -24,13 +24,13 @@ stdenv.mkDerivation rec {
 
   sourceRoot = "${src.name}/${pname}";
 
+  nativeBuildInputs = [ cmake ninja ];
+  buildInputs = [ libllvm libxml2 ];
+
   patches = [
     ./gnu-install-dirs.patch
   ];
 
-  nativeBuildInputs = [ cmake ninja ];
-  buildInputs = [ libllvm libxml2 ];
-
   cmakeFlags = [
     "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
   ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch
index 86e76f4a16d8..6c73a240ab6d 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch
@@ -1,34 +1,3 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 3d6225646fe6..9b5d0b15af13 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -33,10 +33,22 @@ if(LLD_BUILT_STANDALONE)
-   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
- 
--  # Turn into CACHE PATHs for overwriting
--  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
--  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
--  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
-+  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-+  # LLVM_CONFIG.
-+  if (NOT LLVM_CONFIG_FOUND)
-+    # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-+    # path is removed.
-+    set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
-+    set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-+    # N.B. this is just a default value, the CACHE PATHs below can be overridden.
-+    set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-+  else()
-+    set(INCLUDE_DIRS "${LLVM_BINARY_DIR}/include" "${MAIN_INCLUDE_DIR}")
-+  endif()
-+
-+  set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
-+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree")
- 
-   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
-     NO_DEFAULT_PATH)
 diff --git a/cmake/modules/AddLLD.cmake b/cmake/modules/AddLLD.cmake
 index d3924f7243d4..42a7cd62281c 100644
 --- a/cmake/modules/AddLLD.cmake
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
index b8715228ab1c..670171a707f9 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/default.nix
@@ -179,6 +179,10 @@ stdenv.mkDerivation (rec {
     substituteInPlace test/ExecutionEngine/Interpreter/intrinsics.ll \
       --replace "%roundeven32 = call float @llvm.roundeven.f32(float 0.000000e+00)" "" \
       --replace "%roundeven64 = call double @llvm.roundeven.f64(double 0.000000e+00)" ""
+
+    # fails when run in sandbox
+    substituteInPlace unittests/Support/VirtualFileSystemTest.cpp \
+      --replace "PhysicalFileSystemWorkingDirFailure" "DISABLED_PhysicalFileSystemWorkingDirFailure"
   '' + optionalString (stdenv.isDarwin && stdenv.hostPlatform.isx86) ''
     # This test fails on darwin x86_64 because `sw_vers` reports a different
     # macOS version than what LLVM finds by reading
@@ -382,7 +386,6 @@ stdenv.mkDerivation (rec {
       --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")'
   ''
   + optionalString (stdenv.isDarwin && enableSharedLibraries) ''
-    ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
     ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
   ''
   + optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch
index 442ebddad3f6..6a359bdbefde 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch
@@ -1,12 +1,6 @@
-This is the one remaining Polly install dirs related change that hasn't made it
-into upstream yet; previously this patch file also included:
-https://reviews.llvm.org/D117541
-
-diff --git a/tools/polly/cmake/polly_macros.cmake b/tools/polly/cmake/polly_macros.cmake
-index 518a09b45a42..bd9d6f5542ad 100644
---- a/tools/polly/cmake/polly_macros.cmake
-+++ b/tools/polly/cmake/polly_macros.cmake
-@@ -45,8 +45,8 @@ macro(add_polly_library name)
+--- a/tools/polly/cmake/polly_macros.cmake	2024-03-15 17:36:20.550893344 -0700
++++ b/tools/polly/cmake/polly_macros.cmake	2024-03-15 17:37:06.277332960 -0700
+@@ -45,8 +45,8 @@
      install(TARGETS ${name}
        COMPONENT ${name}
        EXPORT LLVMExports
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
index e2122ebf603d..8b89839490ba 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch
@@ -40,7 +40,7 @@ index 230620c37027..dd16cab1835e 100644
    if (APPLE)
      set(_install_name_dir INSTALL_NAME_DIR "@rpath")
 -    set(_install_rpath "@loader_path/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-+    set(_install_rpath "@loader_path/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath ${extra_libdir})
    elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND BUILD_SHARED_LIBS)
      # $ORIGIN is not interpreted at link time by aix ld.
      # Since BUILD_SHARED_LIBS is only recommended for use by developers,
@@ -72,8 +72,8 @@ index 230620c37027..dd16cab1835e 100644
 +    # As noted in the differential above, an alternative solution is to have
 +    # all rdeps of nixpkgs' LLVM (that use the AddLLVM.cmake machinery) set
 +    # `CMAKE_INSTALL_RPATH`.
-+    set(_build_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
-+    set(_install_rpath "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
++    set(_install_rpath ${extra_libdir})
      if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
        set_property(TARGET ${name} APPEND_STRING PROPERTY
                     LINK_FLAGS " -Wl,-z,origin ")
@@ -86,10 +86,10 @@ index 891c9e6d618c..8d963f3b0069 100644
  
    if( APPLE )
 -    set(ocaml_rpath "@executable_path/../../../lib${LLVM_LIBDIR_SUFFIX}")
-+    set(ocaml_rpath "@executable_path/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath ${LLVM_LIBRARY_DIR})
    elseif( UNIX )
 -    set(ocaml_rpath "\\$ORIGIN/../../../lib${LLVM_LIBDIR_SUFFIX}")
-+    set(ocaml_rpath "\\$ORIGIN/../../../${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}")
++    set(ocaml_rpath ${LLVM_LIBRARY_DIR})
    endif()
    list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
  
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch
index 82b7b21c55fb..e4f049f4b177 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch
@@ -1,17 +1,12 @@
-diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
-index 0242e0b75af3..d732011306f7 100644
---- a/utils/lit/lit/TestRunner.py
-+++ b/utils/lit/lit/TestRunner.py
-@@ -1029,6 +1029,12 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
-             f.write('@echo off\n')
-         f.write('\n@if %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
+--- a/utils/lit/lit/TestRunner.py	2024-03-15 17:27:53.170780798 -0700
++++ b/utils/lit/lit/TestRunner.py	2024-03-15 17:28:43.277447791 -0700
+@@ -1183,6 +1183,9 @@
+         f.write("@echo on\n")
+         f.write("\n@if %ERRORLEVEL% NEQ 0 EXIT\n".join(commands))
      else:
-+        # This env var is *purged* when invoking subprocesses so we have to
-+        # manually set it from within the bash script in order for the commands
-+        # in run lines to see this var:
 +        if "DYLD_LIBRARY_PATH" in test.config.environment:
 +            f.write(f'export DYLD_LIBRARY_PATH="{test.config.environment["DYLD_LIBRARY_PATH"]}"\n')
 +
          for i, ln in enumerate(commands):
-             match = re.match(kPdbgRegex, ln)
+             match = re.fullmatch(kPdbgRegex, ln)
              if match:
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
index d51335436ad2..e1c3c2379af2 100644
--- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
+++ b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/default.nix
@@ -29,7 +29,6 @@ stdenv.mkDerivation rec {
 
   patches = [
     ./fix-find-tool.patch
-    ./gnu-install-dirs.patch
     ./run-lit-directly.patch
   ];
 
diff --git a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch b/nixpkgs/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch
deleted file mode 100644
index 0d0d4130c761..000000000000
--- a/nixpkgs/pkgs/development/compilers/llvm/git/openmp/gnu-install-dirs.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index b6ddbe90516d..311ab1d50e7f 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -29,7 +29,7 @@ if (OPENMP_STANDALONE_BUILD)
-   set(OPENMP_LIBDIR_SUFFIX "" CACHE STRING
-     "Suffix of lib installation directory, e.g. 64 => lib64")
-   # Do not use OPENMP_LIBDIR_SUFFIX directly, use OPENMP_INSTALL_LIBDIR.
--  set(OPENMP_INSTALL_LIBDIR "lib${OPENMP_LIBDIR_SUFFIX}" CACHE STRING
-+  set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${OPENMP_LIBDIR_SUFFIX}" CACHE STRING
-       "Path where built OpenMP libraries should be installed.")
- 
-   # Group test settings.
-@@ -47,7 +47,7 @@ if (OPENMP_STANDALONE_BUILD)
- else()
-   set(OPENMP_ENABLE_WERROR ${LLVM_ENABLE_WERROR})
-   # If building in tree, we honor the same install suffix LLVM uses.
--  set(OPENMP_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}" CACHE STRING
-+  set(OPENMP_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}${LLVM_LIBDIR_SUFFIX}" CACHE STRING
-       "Path where built OpenMP libraries should be installed.")
- 
-   if (NOT MSVC)
diff --git a/nixpkgs/pkgs/development/compilers/llvm/update-git.py b/nixpkgs/pkgs/development/compilers/llvm/update-git.py
index b5e900df502b..9be43e8e1afb 100755
--- a/nixpkgs/pkgs/development/compilers/llvm/update-git.py
+++ b/nixpkgs/pkgs/development/compilers/llvm/update-git.py
@@ -43,7 +43,7 @@ def get_current_revision():
     """Get the current revision of llvmPackages_git."""
     with open(DEFAULT_NIX) as f:
         for line in f:
-            rev = re.search(r'^  rev = "(.*)";', line)
+            rev = re.search(r'^    rev = "(.*)";', line)
             if rev:
                 return rev.group(1)
     sys.exit(1)
@@ -75,11 +75,11 @@ hash = nix_prefetch_url(f'https://github.com/llvm/llvm-project/archive/{commit["
 print('Updating default.nix...')
 with fileinput.FileInput(DEFAULT_NIX, inplace=True) as f:
     for line in f:
-        if match := re.search(r'^  rev-version = "unstable-(.+)";', line):
+        if match := re.search(r'^    rev-version = "unstable-(.+)";', line):
                 old_date = match.group(1)
-        result = re.sub(r'^  release_version = ".+";', f'  release_version = "{release_version}";', line)
-        result = re.sub(r'^  rev = ".*";', f'  rev = "{commit["sha"]}";', result)
-        result = re.sub(r'^  rev-version = ".+";', f'  rev-version = "{version}";', result)
+        result = re.sub(r'^    version = ".+";', f'    version = "{release_version}";', line)
+        result = re.sub(r'^    rev = ".*";', f'    rev = "{commit["sha"]}";', result)
+        result = re.sub(r'^    rev-version = ".+";', f'    rev-version = "{version}";', result)
         result = re.sub(r'^    sha256 = ".+";', f'    sha256 = "{hash}";', result)
         print(result, end='')
 # Commit the result:
diff --git a/nixpkgs/pkgs/development/compilers/ocaml/5.2.nix b/nixpkgs/pkgs/development/compilers/ocaml/5.2.nix
new file mode 100644
index 000000000000..26d77f63044d
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/ocaml/5.2.nix
@@ -0,0 +1,9 @@
+import ./generic.nix {
+  major_version = "5";
+  minor_version = "2";
+  patch_version = "0-beta1";
+  src = fetchTarball {
+    url = "https://caml.inria.fr/pub/distrib/ocaml-5.2/ocaml-5.2.0~beta1.tar.xz";
+    sha256 = "sha256:0prf87a41k2y1znnh2pjkggrvhh5cihj68sxqrjn162889rf7wam";
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/openjdk/22.nix b/nixpkgs/pkgs/development/compilers/openjdk/22.nix
new file mode 100644
index 000000000000..bef62b6755a2
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/openjdk/22.nix
@@ -0,0 +1,260 @@
+{ stdenv
+, lib
+, fetchurl
+, fetchpatch
+, fetchFromGitHub
+, bash
+, pkg-config
+, autoconf
+, cpio
+, file
+, which
+, unzip
+, zip
+, perl
+, cups
+, freetype
+, alsa-lib
+, libjpeg
+, giflib
+, libpng
+, zlib
+, lcms2
+, libX11
+, libICE
+, libXrender
+, libXext
+, libXt
+, libXtst
+, libXi
+, libXinerama
+, libXcursor
+, libXrandr
+, fontconfig
+, openjdk22-bootstrap
+, ensureNewerSourcesForZipFilesHook
+, setJavaClassPath
+  # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages
+  # which should be fixable, this is a no-rebuild workaround for GHC.
+, headless ? stdenv.targetPlatform.isGhcjs
+, enableJavaFX ? false
+, openjfx
+, enableGnome2 ? true
+, gtk3
+, gnome_vfs
+, glib
+, GConf
+}:
+
+let
+  version = {
+    feature = "22";
+    interim = "";
+    build = "36";
+  };
+
+  # when building a headless jdk, also bootstrap it with a headless jdk
+  openjdk-bootstrap = openjdk22-bootstrap.override { gtkSupport = !headless; };
+
+  openjdk = stdenv.mkDerivation {
+    pname = "openjdk" + lib.optionalString headless "-headless";
+    version = "${version.feature}${version.interim}+${version.build}";
+
+    src = fetchFromGitHub {
+      owner = "openjdk";
+      repo = "jdk${version.feature}u";
+      rev = "jdk-${version.feature}${version.interim}+${version.build}";
+      hash = "sha256-itjvIedPwJl/l3a2gIVpNMs1zkbrjioVqbCj1Z1nCJE=";
+    };
+
+    nativeBuildInputs = [ pkg-config autoconf unzip ensureNewerSourcesForZipFilesHook ];
+    buildInputs = [
+      cpio
+      file
+      which
+      zip
+      perl
+      zlib
+      cups
+      freetype
+      alsa-lib
+      libjpeg
+      giflib
+      libpng
+      zlib
+      lcms2
+      libX11
+      libICE
+      libXrender
+      libXext
+      libXtst
+      libXt
+      libXtst
+      libXi
+      libXinerama
+      libXcursor
+      libXrandr
+      fontconfig
+      openjdk-bootstrap
+    ] ++ lib.optionals (!headless && enableGnome2) [
+      gtk3
+      gnome_vfs
+      GConf
+      glib
+    ];
+
+    patches = [
+      ./fix-java-home-jdk21.patch
+      ./read-truststore-from-env-jdk10.patch
+      ./currency-date-range-jdk10.patch
+      ./increase-javadoc-heap-jdk13.patch
+      ./ignore-LegalNoticeFilePlugin-jdk18.patch
+
+      # -Wformat etc. are stricter in newer gccs, per
+      # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677
+      # so grab the work-around from
+      # https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24
+      (fetchurl {
+        url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch";
+        sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r";
+      })
+
+      # Fix build for gnumake-4.4.1:
+      #   https://github.com/openjdk/jdk/pull/12992
+      (fetchpatch {
+        name = "gnumake-4.4.1";
+        url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch";
+        hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg=";
+      })
+    ] ++ lib.optionals (!headless && enableGnome2) [
+      ./swing-use-gtk-jdk13.patch
+    ];
+
+    postPatch = ''
+      chmod +x configure
+      patchShebangs --build configure
+    '';
+
+    # JDK's build system attempts to specifically detect
+    # and special-case WSL, and we don't want it to do that,
+    # so pass the correct platform names explicitly
+    configurePlatforms = [ "build" "host" ];
+
+
+    # https://openjdk.org/groups/build/doc/building.html
+    configureFlags = [
+      "--with-boot-jdk=${openjdk-bootstrap.home}"
+      "--with-version-build=${version.build}"
+      "--with-version-opt=nixos"
+      "--with-version-pre="
+      "--enable-unlimited-crypto"
+      "--with-native-debug-symbols=internal"
+      "--with-libjpeg=system"
+      "--with-giflib=system"
+      "--with-libpng=system"
+      "--with-zlib=system"
+      "--with-lcms=system"
+      "--with-stdc++lib=dynamic"
+    ]
+    ++ lib.optional headless "--enable-headless-only"
+    ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}";
+
+    separateDebugInfo = true;
+
+    env.NIX_CFLAGS_COMPILE = "-Wno-error";
+
+    NIX_LDFLAGS = toString (lib.optionals (!headless) [
+      "-lfontconfig"
+      "-lcups"
+      "-lXinerama"
+      "-lXrandr"
+      "-lmagic"
+    ] ++ lib.optionals (!headless && enableGnome2) [
+      "-lgtk-3"
+      "-lgio-2.0"
+      "-lgnomevfs-2"
+      "-lgconf-2"
+    ]);
+
+    # -j flag is explicitly rejected by the build system:
+    #     Error: 'make -jN' is not supported, use 'make JOBS=N'
+    # Note: it does not make build sequential. Build system
+    # still runs in parallel.
+    enableParallelBuilding = false;
+
+    buildFlags = [ "images" ];
+
+    installPhase = ''
+      mkdir -p $out/lib
+
+      mv build/*/images/jdk $out/lib/openjdk
+
+      # Remove some broken manpages.
+      rm -rf $out/lib/openjdk/man/ja*
+
+      # Mirror some stuff in top-level.
+      mkdir -p $out/share
+      ln -s $out/lib/openjdk/include $out/include
+      ln -s $out/lib/openjdk/man $out/share/man
+
+      # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081)
+      ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip
+
+      # jni.h expects jni_md.h to be in the header search path.
+      ln -s $out/include/linux/*_md.h $out/include/
+
+      # Remove crap from the installation.
+      rm -rf $out/lib/openjdk/demo
+      ${lib.optionalString headless ''
+        rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so
+      ''}
+
+      ln -s $out/lib/openjdk/bin $out/bin
+    '';
+
+    preFixup = ''
+      # Propagate the setJavaClassPath setup hook so that any package
+      # that depends on the JDK has $CLASSPATH set up properly.
+      mkdir -p $out/nix-support
+      #TODO or printWords?  cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040
+      echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs
+
+      # Set JAVA_HOME automatically.
+      mkdir -p $out/nix-support
+      cat <<EOF > $out/nix-support/setup-hook
+      if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi
+      EOF
+    '';
+
+    postFixup = ''
+      # Build the set of output library directories to rpath against
+      LIBDIRS=""
+      for output in $(getAllOutputNames); do
+        if [ "$output" = debug ]; then continue; fi
+        LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS"
+      done
+      # Add the local library paths to remove dependencies on the bootstrap
+      for output in $(getAllOutputNames); do
+        if [ "$output" = debug ]; then continue; fi
+        OUTPUTDIR=$(eval echo \$$output)
+        BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
+        echo "$BINLIBS" | while read i; do
+          patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
+          patchelf --shrink-rpath "$i" || true
+        done
+      done
+    '';
+
+    disallowedReferences = [ openjdk-bootstrap ];
+
+    pos = builtins.unsafeGetAttrPos "feature" version;
+    meta = import ./meta.nix lib version.feature;
+
+    passthru = {
+      architecture = "";
+      home = "${openjdk}/lib/openjdk";
+      inherit gtk3;
+    };
+  };
+in
+openjdk
diff --git a/nixpkgs/pkgs/development/compilers/openjdk/openjfx/22.nix b/nixpkgs/pkgs/development/compilers/openjdk/openjfx/22.nix
new file mode 100644
index 000000000000..89908779c909
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/openjdk/openjfx/22.nix
@@ -0,0 +1,126 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, fetchpatch
+, writeText
+, openjdk21_headless
+, gradle
+, pkg-config
+, perl
+, cmake
+, gperf
+, gtk2
+, gtk3
+, libXtst
+, libXxf86vm
+, glib
+, alsa-lib
+, ffmpeg_4
+, python3
+, ruby
+, icu68
+, withMedia ? true
+, withWebKit ? false
+}:
+
+let
+  major = "22";
+  update = "";
+  build = "+30";
+  repover = "${major}${update}${build}";
+
+  makePackage = args: stdenv.mkDerivation ({
+    version = "${major}${update}${build}";
+
+    src = fetchFromGitHub {
+      owner = "openjdk";
+      repo = "jfx";
+      rev = repover;
+      hash = "sha256-sZF7ZPC0kgTTxWgtkxmGtOlfroGPGVZcMw0/wSTJUxQ=";
+    };
+
+    buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg_4 icu68 ];
+    nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ];
+
+    dontUseCmakeConfigure = true;
+
+    config = writeText "gradle.properties" (''
+      CONF = Release
+      JDK_HOME = ${openjdk21_headless.home}
+    '' + args.gradleProperties or "");
+
+    buildPhase = ''
+      runHook preBuild
+
+      export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
+      export GRADLE_USER_HOME=$(mktemp -d)
+      ln -s $config gradle.properties
+      export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
+      gradle --no-daemon $gradleFlags sdk
+
+      runHook postBuild
+    '';
+  } // args);
+
+  # Fake build to pre-download deps into fixed-output derivation.
+  # We run nearly full build because I see no other way to download everything that's needed.
+  # Anyone who knows a better way?
+  deps = makePackage {
+    pname = "openjfx-deps";
+
+    # perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
+    installPhase = ''
+      find $GRADLE_USER_HOME -type f -regex '.*/modules.*\.\(jar\|pom\)' \
+        | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
+        | sh
+      rm -rf $out/tmp
+    '';
+
+    outputHashAlgo = "sha256";
+    outputHashMode = "recursive";
+    outputHash = "sha256-2I7LvYcudlB4DKJ/wEiTjY6nICUxUY52euosUqOA+Bs=";
+  };
+
+in
+makePackage {
+  pname = "openjfx-modular-sdk";
+
+  gradleProperties = ''
+    COMPILE_MEDIA = ${lib.boolToString withMedia}
+    COMPILE_WEBKIT = ${lib.boolToString withWebKit}
+  '';
+
+  preBuild = ''
+    swtJar="$(find ${deps} -name org.eclipse.swt\*.jar)"
+    substituteInPlace build.gradle \
+      --replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${deps}") }' \
+      --replace 'name: SWT_FILE_NAME' "files('$swtJar')"
+  '';
+
+  installPhase = ''
+    cp -r build/modular-sdk $out
+  '';
+
+  stripDebugList = [ "." ];
+
+  postFixup = ''
+    # Remove references to bootstrap.
+    export openjdkOutPath='${openjdk21_headless.outPath}'
+    find "$out" -name \*.so | while read lib; do
+      new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')"
+      patchelf --set-rpath "$new_refs" "$lib"
+    done
+  '';
+
+  disallowedReferences = [ openjdk21_headless openjdk21_headless ];
+
+  passthru.deps = deps;
+
+  meta = with lib; {
+    homepage = "https://openjdk.org/projects/openjfx/";
+    license = licenses.gpl2Classpath;
+    description = "The next-generation Java client toolkit";
+    maintainers = with maintainers; [ abbradar ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/compilers/zulu/22.nix b/nixpkgs/pkgs/development/compilers/zulu/22.nix
new file mode 100644
index 000000000000..96b0e6805a5a
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/zulu/22.nix
@@ -0,0 +1,42 @@
+{ callPackage
+, enableJavaFX ? false
+, ...
+}@args:
+
+callPackage ./common.nix ({
+  # Details from https://www.azul.com/downloads/?version=java-22-lts&package=jdk
+  # Note that the latest build may differ by platform
+  dists = {
+    x86_64-linux = {
+      zuluVersion = "22.28.91";
+      jdkVersion = "22.0.0";
+      hash =
+        if enableJavaFX then "sha256-HvMiODsz+puu1xtxG2RRXH/PWCk91PGNZ7UcOd9orqQ="
+        else "sha256-HvMiODsz+puu1xtxG2RRXH/PWCk91PGNZ7UcOd9orqQ=";
+    };
+
+    aarch64-linux = {
+      zuluVersion = "22.28.91";
+      jdkVersion = "22.0.0";
+      hash =
+        if enableJavaFX then throw "JavaFX is not available for aarch64-linux"
+        else "sha256-3RLNNEbMk5wAZsQmbQj/jpx9iTL/yr9N3wL4t7m6c+s=";
+    };
+
+    x86_64-darwin = {
+      zuluVersion = "22.28.91";
+      jdkVersion = "22.0.0";
+      hash =
+        if enableJavaFX then "sha256-Y6PSNQjHRXukwux2sVbvpTIqT+Cg+KeG1C0iSEwyKZw="
+        else "sha256-Y6PSNQjHRXukwux2sVbvpTIqT+Cg+KeG1C0iSEwyKZw=";
+    };
+
+    aarch64-darwin = {
+      zuluVersion = "22.28.91";
+      jdkVersion = "22.0.0";
+      hash =
+        if enableJavaFX then "sha256-o0VkWB4+PzBmNNWy+FZlyjTgukBTe6owfydb3YNfEE0="
+        else "sha256-o0VkWB4+PzBmNNWy+FZlyjTgukBTe6owfydb3YNfEE0=";
+    };
+  };
+} // builtins.removeAttrs args [ "callPackage" ])