diff --git a/Justfile b/Justfile
new file mode 100644
--- /dev/null
+++ b/Justfile
@@ -0,0 +1,34 @@
+test:
+	nix-shell shell-args.nix --argstr llvmVersion 2100 --run "just test-pkg-config"
+	just test-versions
+
+
+test-pkg-config:
+	runhaskell Setup clean
+	runhaskell Setup configure -fbuildExamples -fpkgConfig
+	runhaskell Setup build
+	runhaskell Setup haddock
+	./dist/build/llvm-ffi-host/llvm-ffi-host
+	./dist/build/llvm-ffi-jit/llvm-ffi-jit
+
+test-versions:
+	just test-nix 2100
+	just test-nix 2000
+	just test-nix 1900
+	just test-nix 1800
+	just test-nix 1700
+	just test-nix 1600
+	just test-nix 1500
+	just test-nix 1400
+	just test-nix 1300
+
+test-nix version:
+	nix-shell shell-args.nix --argstr llvmVersion {{version}} --run "just test-version {{version}}"
+
+test-version version:
+	# "{{ env_var('CPATH') }}"
+	# "{{ env_var('LD_LIBRARY_PATH') }}"
+	runhaskell Setup clean
+	runhaskell Setup configure -fbuildExamples -fllvm{{version}}
+	runhaskell Setup build
+	./dist/build/llvm-ffi-jit/llvm-ffi-jit
diff --git a/ReadMe.md b/ReadMe.md
--- a/ReadMe.md
+++ b/ReadMe.md
@@ -91,6 +91,13 @@
 cabal install -fpkgConfig
 ~~~~
 
+We ship a `pkg-config.nix` file.
+If you import this into your Nix expression,
+Nix will prepare and install a llvm.pc file for you.
+
+
+## Known issues
+
 Warning for inplace builds:
 Re-configuring the package using, say `-fllvm1600`,
 and re-buildung it might result in corrupt code.
@@ -98,14 +105,21 @@
 Cabal or GHC may forget about that.
 You are safe if you run `cabal clean`.
 
-Caution: Nasty crashes can occur
+
+Caution:
+Surprises are ahead
 if you have configured paths for LLVM version X in `.cabal/config`
-and try to build `llvm-ffi` for a different LLVM version Y.
-Counterintuitively, global search paths have higher precedence
+and try to build `llvm-ffi` for a different LLVM version Y
+by adding custom include and library paths to `cabal.project`.
+Counterintuitively, global search paths take higher precedence
 [than local ones](https://github.com/haskell/cabal/issues/7782).
-But that does not simply mean
-that the local configuration is ignored completely.
-Instead the local library file is found,
-because its name libLLVM-Y.so is unique,
-whereas the include file names clash,
-thus the ones from the global include directory are used.
+
+We now depend on libLLVM.so, not on libLLVM-X.so anymore.
+This is for consistency with the include files,
+where there are no include file names including version numbers.
+In former versions of this binding package
+we depend on generic LLVM/Core.h but specific libLLVM-X.so.
+This meant,
+that the include files configured in `.cabal/config`
+were mixed with the library configured in `cabal.project`.
+This lead to ugly, hard to debug crashes.
diff --git a/flatpak/llvm-3.8.1.json b/flatpak/llvm-3.8.1.json
deleted file mode 100644
--- a/flatpak/llvm-3.8.1.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
-    "cleanup": [
-        "/bin",
-        "/include",
-        "/lib/debug",
-        "/lib/libLLVM*.a",
-        "/lib/LLVMHello.so",
-        "/share"
-    ],
-    "sources": [
-        {
-            "url": "http://releases.llvm.org/3.8.1/llvm-3.8.1.src.tar.xz",
-            "type": "archive",
-            "sha256": "6e82ce4adb54ff3afc18053d6981b6aed1406751b8742582ed50f04b5ab475f9"
-        }
-    ],
-    "config-opts": [
-        "-DCMAKE_BUILD_TYPE=Release",
-        "-DLLVM_ENABLE_ASSERTIONS=ON",
-        "-DLLVM_BUILD_TOOLS=OFF",
-        "-DLLVM_INCLUDE_EXAMPLES=OFF",
-        "-DLLVM_BUILD_LLVM_DYLIB=ON"
-    ],
-    "name": "llvm-3.8",
-    "buildsystem": "cmake",
-    "builddir": true
-}
diff --git a/flatpak/llvm-3.9.1.json b/flatpak/llvm-3.9.1.json
deleted file mode 100644
--- a/flatpak/llvm-3.9.1.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
-    "cleanup": [
-        "/bin",
-        "/include",
-        "/lib/debug",
-        "/lib/libLLVM*.a",
-        "/lib/LLVMHello.so",
-        "/share"
-    ],
-    "sources": [
-        {
-            "url": "http://releases.llvm.org/3.9.1/llvm-3.9.1.src.tar.xz",
-            "type": "archive",
-            "sha256": "1fd90354b9cf19232e8f168faf2220e79be555df3aa743242700879e8fd329ee"
-        }
-    ],
-    "config-opts": [
-        "-DCMAKE_BUILD_TYPE=Release",
-        "-DLLVM_ENABLE_ASSERTIONS=ON",
-        "-DLLVM_BUILD_TOOLS=OFF",
-        "-DLLVM_INCLUDE_EXAMPLES=OFF",
-        "-DLLVM_BUILD_LLVM_DYLIB=ON"
-    ],
-    "name": "llvm-3.9",
-    "buildsystem": "cmake",
-    "builddir": true
-}
diff --git a/llvm-ffi.cabal b/llvm-ffi.cabal
--- a/llvm-ffi.cabal
+++ b/llvm-ffi.cabal
@@ -1,6 +1,6 @@
 Cabal-Version: 2.2
 Name:          llvm-ffi
-Version:       21.0.0.1
+Version:       21.0.0.2
 License:       BSD-3-Clause
 License-File:  LICENSE
 Synopsis:      FFI bindings to the LLVM compiler toolkit.
@@ -28,8 +28,9 @@
   include/support.h
   tool/ltrace.config
   tool/ltrace.readme
-  flatpak/llvm-3.8.1.json
-  flatpak/llvm-3.9.1.json
+  shell-args.nix
+  pkg-config.nix
+  Justfile
 
 Extra-Doc-Files:
   ReadMe.md
@@ -99,7 +100,7 @@
   Location: https://hub.darcs.net/thielema/llvm-ffi/
 
 Source-Repository this
-  Tag:      21.0.0.1
+  Tag:      21.0.0.2
   Type:     darcs
   Location: https://hub.darcs.net/thielema/llvm-ffi/
 
@@ -150,8 +151,6 @@
         PkgConfig-Depends: llvm-13
       Else
         PkgConfig-Depends: llvm == 13.*
-    Else
-      Extra-Libraries: LLVM-13
     Hs-Source-Dirs: src/13, src/before14
     CC-Options: -DHS_LLVM_VERSION=1300
     Cxx-Options: -DHS_LLVM_VERSION=1300
@@ -164,8 +163,6 @@
           PkgConfig-Depends: llvm-14
         Else
           PkgConfig-Depends: llvm == 14.*
-      Else
-        Extra-Libraries: LLVM-14
       Hs-Source-Dirs: src/14
       CC-Options: -DHS_LLVM_VERSION=1400
       Cxx-Options: -DHS_LLVM_VERSION=1400
@@ -177,8 +174,6 @@
             PkgConfig-Depends: llvm-15
           Else
             PkgConfig-Depends: llvm == 15.*
-        Else
-          Extra-Libraries: LLVM-15
         Hs-Source-Dirs: src/15
         CC-Options: -DHS_LLVM_VERSION=1500
         Cxx-Options: -DHS_LLVM_VERSION=1500
@@ -191,8 +186,6 @@
               PkgConfig-Depends: llvm-16
             Else
               PkgConfig-Depends: llvm == 16.*
-          Else
-            Extra-Libraries: LLVM-16
           Hs-Source-Dirs: src/16
           CC-Options: -DHS_LLVM_VERSION=1600
           Cxx-Options: -DHS_LLVM_VERSION=1600
@@ -204,8 +197,6 @@
                 PkgConfig-Depends: llvm-17
               Else
                 PkgConfig-Depends: llvm == 17.*
-            Else
-              Extra-Libraries: LLVM-17
             Hs-Source-Dirs: src/17
             CC-Options: -DHS_LLVM_VERSION=1700
             Cxx-Options: -DHS_LLVM_VERSION=1700
@@ -217,8 +208,6 @@
                   PkgConfig-Depends: llvm-18
                 Else
                   PkgConfig-Depends: llvm == 18.*
-              Else
-                Extra-Libraries: LLVM-18
               Hs-Source-Dirs: src/18
               CC-Options: -DHS_LLVM_VERSION=1800
               Cxx-Options: -DHS_LLVM_VERSION=1800
@@ -230,8 +219,6 @@
                     PkgConfig-Depends: llvm-19
                   Else
                     PkgConfig-Depends: llvm == 19.*
-                Else
-                  Extra-Libraries: LLVM-19
                 Hs-Source-Dirs: src/19
                 CC-Options: -DHS_LLVM_VERSION=1900
                 Cxx-Options: -DHS_LLVM_VERSION=1900
@@ -243,8 +230,6 @@
                       PkgConfig-Depends: llvm-20
                     Else
                       PkgConfig-Depends: llvm == 20.*
-                  Else
-                    Extra-Libraries: LLVM-20
                   Hs-Source-Dirs: src/20
                   CC-Options: -DHS_LLVM_VERSION=2000
                   Cxx-Options: -DHS_LLVM_VERSION=2000
@@ -255,13 +240,13 @@
                       PkgConfig-Depends: llvm-21
                     Else
                       PkgConfig-Depends: llvm == 21.*
-                  Else
---                    Extra-Libraries: LLVM-21
-                    Extra-Libraries: LLVM-21git
                   Hs-Source-Dirs: src/21
                   CC-Options: -DHS_LLVM_VERSION=2100
                   Cxx-Options: -DHS_LLVM_VERSION=2100
                   CPP-Options: -DHS_LLVM_VERSION=2100
+
+  If !flag(pkgConfig)
+    Extra-Libraries: LLVM
 
   CC-Options: -DHAVE_LLVM_SUPPORT_DYNAMICLIBRARY_H=1
   CPP-Options: -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
diff --git a/pkg-config.nix b/pkg-config.nix
new file mode 100644
--- /dev/null
+++ b/pkg-config.nix
@@ -0,0 +1,15 @@
+{ stdenv, llvmPackages, haskellPackages }:
+stdenv.mkDerivation rec {
+  pname = "llvm-pc";
+  version = llvmPackages.llvm.version;
+
+  buildInputs = [ haskellPackages.llvm-pkg-config ];
+  propagatedBuildInputs = [ llvmPackages.libllvm ];
+
+  phases = [ "installPhase" ];
+
+  installPhase = ''
+    mkdir -p $out/lib/pkgconfig
+    llvm-pkg-config >$out/lib/pkgconfig/llvm-${llvmPackages.llvm.shortVersion}.pc
+  '';
+}
diff --git a/shell-args.nix b/shell-args.nix
new file mode 100644
--- /dev/null
+++ b/shell-args.nix
@@ -0,0 +1,36 @@
+{ pkgs ? import <unstable> {}
+, llvmVersion ? "2100"
+}:
+
+let
+  llvmPackagesSet = {
+    "1300" = pkgs.llvmPackages_13;
+    "1400" = pkgs.llvmPackages_14;
+    "1500" = pkgs.llvmPackages_15;
+    "1600" = pkgs.llvmPackages_16;
+    "1700" = pkgs.llvmPackages_17;
+    "1800" = pkgs.llvmPackages_18;
+    "1900" = pkgs.llvmPackages_19;
+    "2000" = pkgs.llvmPackages_20;
+    "2100" = pkgs.llvmPackages_21;
+    "2200" = pkgs.llvmPackages_git;
+  };
+  llvmPkgs = llvmPackagesSet.${llvmVersion};
+  llvmPkg = llvmPkgs.libllvm;
+in
+pkgs.mkShell {
+  buildInputs = (with pkgs; [
+    gnumake
+    just
+    pkg-config
+    (haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [enumset]))
+    cabal-install
+    llvmPkg
+    haskellPackages.llvm-pkg-config
+    (callPackage ./pkg-config.nix {llvmPackages=llvmPkgs;})
+  ]);
+  CPATH="${llvmPkg.dev}/include";
+  C_INCLUDE_PATH="${llvmPkg.dev}/include";
+  LD_LIBRARY_PATH="${llvmPkg.lib}/lib";
+  PKG_CONFIG_PATH=".";
+}
