aboutsummaryrefslogtreecommitdiff
path: root/modules/misc
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2020-02-21 19:11:58 +0100
committerRobert Helgesson <robert@rycee.net>2020-03-07 15:03:44 +0100
commit0056a5aea1a7b68bdacb7b829c325a1d4a3c4259 (patch)
treef4f8d2a5c3260a026ad07e58991fe71bee6e8beb /modules/misc
parentb36d3e02611d9eb64765549f74110ed42d723837 (diff)
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
Diffstat (limited to 'modules/misc')
-rw-r--r--modules/misc/debug.nix26
1 files changed, 26 insertions, 0 deletions
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
+ <command>gdb</command> in the <literal>debug</literal>-output.
+ This option ensures that those are automatically fetched from
+ the binary cache if available and <command>gdb</command> 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";
+ };
+ };
+}