summary refs log tree commit diff
path: root/pkgs/misc
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/misc.nix38
1 files changed, 36 insertions, 2 deletions
diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix
index de23d6fa2c8d..df4a0ce81023 100644
--- a/pkgs/misc/misc.nix
+++ b/pkgs/misc/misc.nix
@@ -109,14 +109,15 @@ in
   # build a debug version of a package
   debugVersion = pkg: lib.overrideDerivation pkg (attrs: {
 
-    prePhases = ["preHook"] ++ lib.optionals (pkgs ? prePhases) pkgs.prePhases;
+    prePhases = ["debugPhase"] ++ lib.optionals (attrs ? prePhases) attrs.prePhases;
+    postPhases = ["objectsPhase"] ++ lib.optionals (attrs ? postPhases) attrs.postPhases;
 
     dontStrip = true;
 
     CFLAGS="-ggdb -O0";
     CXXFLAGS="-ggdb -O0";
 
-    preHook = ''
+    debugPhase = ''
       s=$out/src
       mkdir -p $s; cd $s;
       export TMP=$s
@@ -128,5 +129,38 @@ in
       echo "file should tell that executable has not been stripped"
     '';
 
+    objectsPhase = ''
+      cd $out/src
+      find . -name "*.o" -exec rm {} \;
+    '';
+  });
+
+  # build an optimized ersion of a package but with symbols and source
+  symbolsVersion = pkg: lib.overrideDerivation pkg (attrs: {
+
+    prePhases = ["debugPhase"] ++ lib.optionals (attrs ? prePhases) attrs.prePhases;
+    postPhases = ["objectsPhase"] ++ lib.optionals (attrs ? postPhases) attrs.postPhases;
+
+    dontStrip = true;
+
+    CFLAGS="-g -O2";
+    CXXFLAGS="-g -O2";
+
+    debugPhase = ''
+      s=$out/src
+      mkdir -p $s; cd $s;
+      export TMP=$s
+      export TEMP=$s
+
+      for var in CFLAGS CXXFLAGS NIX_CFLAGS_COMPILE; do
+        declare -x "$var=''${!var} -g -O2"
+      done
+      echo "file should tell that executable has not been stripped"
+    '';
+
+    objectsPhase = ''
+      cd $out/src
+      find . -name "*.o" -exec rm {} \;
+    '';
   });
 }