nixos: make it possible for several modules to provide a debuginfod server

by introducing a `environment.debuginfodServers` option.

Changed files
+36 -17
nixos
modules
config
services
+35 -8
nixos/modules/config/debug-info.nix
···
-
{ config, lib, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
{
options = {
···
'';
};
+
environment.debuginfodServers = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
+
default = [ ];
+
description = ''
+
List of urls of debuginfod servers for tools like {command}`gdb` and {command}`valgrind` to use.
+
+
Unrelated to {option}`environment.enableDebugInfo`.
+
'';
+
};
+
};
-
config = lib.mkIf config.environment.enableDebugInfo {
+
config = lib.mkMerge [
+
(lib.mkIf config.environment.enableDebugInfo {
+
+
# FIXME: currently disabled because /lib is already in
+
# environment.pathsToLink, and we can't have both.
+
#environment.pathsToLink = [ "/lib/debug/.build-id" ];
-
# FIXME: currently disabled because /lib is already in
-
# environment.pathsToLink, and we can't have both.
-
#environment.pathsToLink = [ "/lib/debug/.build-id" ];
+
environment.extraOutputsToInstall = [ "debug" ];
+
+
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/debug" ];
-
environment.extraOutputsToInstall = [ "debug" ];
+
})
+
(lib.mkIf (config.environment.debuginfodServers != [ ]) {
+
environment.variables.DEBUGINFOD_URLS = lib.strings.concatStringsSep " " config.environment.debuginfodServers;
-
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/debug" ];
+
environment.systemPackages = [
+
# valgrind support requires debuginfod-find on PATH
+
(lib.getBin pkgs.elfutils)
+
];
-
};
+
environment.etc."gdb/gdbinit.d/nixseparatedebuginfod2.gdb".text = "set debuginfod enabled on";
+
})
+
];
}
+1 -9
nixos/modules/services/development/nixseparatedebuginfod.nix
···
extra-allowed-users = [ "nixseparatedebuginfod" ];
};
-
environment.variables.DEBUGINFOD_URLS = "http://${url}";
-
-
environment.systemPackages = [
-
# valgrind support requires debuginfod-find on PATH
-
(lib.getBin pkgs.elfutils)
-
];
-
-
environment.etc."gdb/gdbinit.d/nixseparatedebuginfod.gdb".text = "set debuginfod enabled on";
-
+
environment.debuginfodServers = [ "http://${url}" ];
};
}