summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc/setup-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/ghc/setup-hook.sh')
-rw-r--r--pkgs/development/compilers/ghc/setup-hook.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/development/compilers/ghc/setup-hook.sh b/pkgs/development/compilers/ghc/setup-hook.sh
new file mode 100644
index 0000000000000..11ad50a0c7963
--- /dev/null
+++ b/pkgs/development/compilers/ghc/setup-hook.sh
@@ -0,0 +1,17 @@
+# Create isolated package config
+packages_db=$TMPDIR/.package.conf
+cp @ghc@/lib/ghc-*/package.conf $packages_db
+chmod u+w $packages_db
+
+export GHC_PACKAGE_PATH=$packages_db
+
+# Env hook to add packages to the package config
+addLibToPackageConf () {
+    local fn
+    shopt -s nullglob
+    for fn in $1/lib/ghc-pkgs/ghc-@ghcVersion@/*.conf; do
+        @ghc@/bin/ghc-pkg register --force $fn
+    done
+}
+
+envHooks=(${envHooks[@]} addLibToPackageConf)