From ca548d4da9036c1de4ebef87c29dad5405777728 Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Sun, 27 Jul 2025 12:00:00 +0000 Subject: [PATCH] nixos: make it possible for several modules to provide a debuginfod server by introducing a `environment.debuginfodServers` option. --- nixos/modules/config/debug-info.nix | 49 ++++++++++++++----- .../development/nixseparatedebuginfod.nix | 10 +--- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/nixos/modules/config/debug-info.nix b/nixos/modules/config/debug-info.nix index 1a2bbd319e57..6119f1202af3 100644 --- a/nixos/modules/config/debug-info.nix +++ b/nixos/modules/config/debug-info.nix @@ -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"; + }) + ]; + } diff --git a/nixos/modules/services/development/nixseparatedebuginfod.nix b/nixos/modules/services/development/nixseparatedebuginfod.nix index 63474272ccf0..db16b052c65f 100644 --- a/nixos/modules/services/development/nixseparatedebuginfod.nix +++ b/nixos/modules/services/development/nixseparatedebuginfod.nix @@ -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}" ]; }; }