From 0056a5aea1a7b68bdacb7b829c325a1d4a3c4259 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 21 Feb 2020 19:11:58 +0100 Subject: debug: add module This one is fairly similar to `environment.enableDebugInfo`[1] (hence the name). It ensures that the `debug`-output of packages defined in `home.packages` is installed if available and ensures that `gdb`/`elfutils` find those symbols by adding `~/.nix-profile/lib/debug` to the `NIX_DEBUG_INFO_DIRS`[2] variable. [1] https://github.com/NixOS/nixpkgs/blob/release-19.09/nixos/modules/config/debug-info.nix [2] https://github.com/NixOS/nixpkgs/blob/release-19.09/pkgs/development/tools/misc/gdb/debug-info-from-env.patch PR #1040 --- modules/misc/debug.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 modules/misc/debug.nix (limited to 'modules/misc') diff --git a/modules/misc/debug.nix b/modules/misc/debug.nix new file mode 100644 index 00000000000..d27d496b423 --- /dev/null +++ b/modules/misc/debug.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +with lib; + +{ + options.home = { + enableDebugInfo = mkEnableOption "" // { + description = '' + Some Nix-packages provide debug symbols for + gdb in the debug-output. + This option ensures that those are automatically fetched from + the binary cache if available and gdb is + configured to find those symbols. + ''; + }; + }; + + config = mkIf config.home.enableDebugInfo { + home.extraOutputsToInstall = [ "debug" ]; + + home.sessionVariables = { + NIX_DEBUG_INFO_DIRS = + "$NIX_DEBUG_INFO_DIRS\${NIX_DEBUG_INFO_DIRS:+:}${config.home.profileDirectory}/lib/debug"; + }; + }; +} -- cgit v1.2.3