1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7{
8
9 options = {
10
11 environment.enableDebugInfo = lib.mkOption {
12 type = lib.types.bool;
13 default = false;
14 description = ''
15 Some NixOS packages provide debug symbols. However, these are
16 not included in the system closure by default to save disk
17 space. Enabling this option causes the debug symbols to appear
18 in {file}`/run/current-system/sw/lib/debug/.build-id`,
19 where tools such as {command}`gdb` can find them.
20 If you need debug symbols for a package that doesn't
21 provide them by default, you can enable them as follows:
22
23 nixpkgs.config.packageOverrides = pkgs: {
24 hello = pkgs.hello.overrideAttrs (oldAttrs: {
25 separateDebugInfo = true;
26 });
27 };
28 '';
29 };
30
31 environment.debuginfodServers = lib.mkOption {
32 type = lib.types.listOf lib.types.str;
33 default = [ ];
34 description = ''
35 List of urls of debuginfod servers for tools like {command}`gdb` and {command}`valgrind` to use.
36
37 Unrelated to {option}`environment.enableDebugInfo`.
38 '';
39 };
40
41 };
42
43 config = lib.mkMerge [
44 (lib.mkIf config.environment.enableDebugInfo {
45
46 # FIXME: currently disabled because /lib is already in
47 # environment.pathsToLink, and we can't have both.
48 #environment.pathsToLink = [ "/lib/debug/.build-id" ];
49
50 environment.extraOutputsToInstall = [ "debug" ];
51
52 environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/debug" ];
53
54 })
55 (lib.mkIf (config.environment.debuginfodServers != [ ]) {
56 environment.variables.DEBUGINFOD_URLS = lib.strings.concatStringsSep " " config.environment.debuginfodServers;
57
58 environment.systemPackages = [
59 # valgrind support requires debuginfod-find on PATH
60 (lib.getBin pkgs.elfutils)
61 ];
62
63 environment.etc."gdb/gdbinit.d/nixseparatedebuginfod2.gdb".text = "set debuginfod enabled on";
64 })
65 ];
66
67}