···11+{ config, lib, ... }:
22+33+with lib;
44+55+{
66+77+ options = {
88+99+ environment.enableDebugInfo = mkOption {
1010+ type = types.bool;
1111+ default = false;
1212+ description = ''
1313+ Some NixOS packages provide debug symbols. However, these are
1414+ not included in the system closure by default to save disk
1515+ space. Enabling this option causes the debug symbols to appear
1616+ in <filename>/run/current-system/sw/lib/debug/.build-id</filename>,
1717+ where tools such as <command>gdb</command> can find them.
1818+ If you need debug symbols for a package that doesn't
1919+ provide them by default, you can enable them as follows:
2020+ <!-- FIXME: ugly, see #10721 -->
2121+ <programlisting>
2222+ nixpkgs.config.packageOverrides = pkgs: {
2323+ hello = overrideDerivation pkgs.hello (attrs: {
2424+ outputs = attrs.outputs or ["out"] ++ ["debug"];
2525+ buildInputs = attrs.buildInputs ++ [<nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>];
2626+ });
2727+ };
2828+ </programlisting>
2929+ '';
3030+ };
3131+3232+ };
3333+3434+3535+ config = {
3636+3737+ # FIXME: currently disabled because /lib is already in
3838+ # environment.pathsToLink, and we can't have both.
3939+ #environment.pathsToLink = [ "/lib/debug/.build-id" ];
4040+4141+ environment.outputsToLink =
4242+ optional config.environment.enableDebugInfo "debug";
4343+4444+ };
4545+4646+}