@@ -0,0 +1,46 @@
1+{ config, lib, ... }:
2+
3+with lib;
4+
5+{
6+
7+ options = {
8+
9+ environment.enableDebugInfo = mkOption {
10+ type = types.bool;
11+ default = false;
12+ description = ''
13+ Some NixOS packages provide debug symbols. However, these are
14+ not included in the system closure by default to save disk
15+ space. Enabling this option causes the debug symbols to appear
16+ in <filename>/run/current-system/sw/lib/debug/.build-id</filename>,
17+ where tools such as <command>gdb</command> can find them.
18+ If you need debug symbols for a package that doesn't
19+ provide them by default, you can enable them as follows:
20+ <!-- FIXME: ugly, see #10721 -->
21+ <programlisting>
22+ nixpkgs.config.packageOverrides = pkgs: {
23+ hello = overrideDerivation pkgs.hello (attrs: {
24+ outputs = attrs.outputs or ["out"] ++ ["debug"];
25+ buildInputs = attrs.buildInputs ++ [<nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>];
26+ });
27+ };
28+ </programlisting>
29+ '';
30+ };
31+
32+ };
33+
34+
35+ config = {
36+
37+ # FIXME: currently disabled because /lib is already in
38+ # environment.pathsToLink, and we can't have both.
39+ #environment.pathsToLink = [ "/lib/debug/.build-id" ];
40+
41+ environment.outputsToLink =
42+ optional config.environment.enableDebugInfo "debug";
43+
44+ };
45+
46+}