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 = { options = {
@ -23,9 +28,20 @@
''; '';
}; };
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 # FIXME: currently disabled because /lib is already in
# environment.pathsToLink, and we can't have both. # environment.pathsToLink, and we can't have both.
@ -35,6 +51,17 @@
environment.variables.NIX_DEBUG_INFO_DIRS = [ "/run/current-system/sw/lib/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" ]; extra-allowed-users = [ "nixseparatedebuginfod" ];
}; };
environment.variables.DEBUGINFOD_URLS = "http://${url}"; environment.debuginfodServers = [ "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";
}; };
} }