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

by introducing a `environment.debuginfodServers` option.
This commit is contained in:
Guillaume Girol 2025-07-27 12:00:00 +00:00
parent 4a2c2ca553
commit ca548d4da9
2 changed files with 39 additions and 20 deletions

View File

@ -1,4 +1,9 @@
{ config, lib, ... }:
{
config,
lib,
pkgs,
...
}:
{
options = {
@ -23,18 +28,40 @@
'';
};
};
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.
config = 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" ];
environment.extraOutputsToInstall = [ "debug" ];
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/debug" ];
Unrelated to {option}`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" ];
environment.extraOutputsToInstall = [ "debug" ];
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/debug" ];
})
(lib.mkIf (config.environment.debuginfodServers != [ ]) {
environment.variables.DEBUGINFOD_URLS = lib.strings.concatStringsSep " " config.environment.debuginfodServers;
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";
})
];
}

View File

@ -101,14 +101,6 @@ in
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}" ];
};
}