1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

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
This commit is contained in:
Maximilian Bosch 2020-02-21 19:11:58 +01:00 committed by Robert Helgesson
parent b36d3e0261
commit 0056a5aea1
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 54 additions and 1 deletions

26
modules/misc/debug.nix Normal file
View file

@ -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";
};
};
}

View file

@ -26,6 +26,7 @@ let
(loadModule ./home-environment.nix { }) (loadModule ./home-environment.nix { })
(loadModule ./manual.nix { }) (loadModule ./manual.nix { })
(loadModule ./misc/dconf.nix { }) (loadModule ./misc/dconf.nix { })
(loadModule ./misc/debug.nix { })
(loadModule ./misc/fontconfig.nix { }) (loadModule ./misc/fontconfig.nix { })
(loadModule ./misc/gtk.nix { }) (loadModule ./misc/gtk.nix { })
(loadModule ./misc/lib.nix { }) (loadModule ./misc/lib.nix { })

View file

@ -43,10 +43,11 @@ import nmt {
./modules/programs/zsh ./modules/programs/zsh
./modules/xresources ./modules/xresources
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
./modules/programs/abook ./modules/misc/debug
./modules/misc/pam ./modules/misc/pam
./modules/misc/xdg ./modules/misc/xdg
./modules/misc/xsession ./modules/misc/xsession
./modules/programs/abook
./modules/programs/firefox ./modules/programs/firefox
./modules/programs/getmail ./modules/programs/getmail
./modules/programs/rofi ./modules/programs/rofi

View file

@ -0,0 +1,25 @@
{
debug = { pkgs, config, lib, ... }: {
home.enableDebugInfo = true;
home.packages = with pkgs; [ curl gdb ];
nmt.script = ''
[ -L $TESTED/home-path/lib/debug/curl ] \
|| fail "Debug-symbols for pkgs.curl should exist in \`/home-path/lib/debug'!"
#source $TESTED/home-path/etc/profile.d/hm-session-vars.sh
#[[ "$NIX_DEBUG_INFO_DIRS" =~ /lib/debug$ ]] \
#|| fail "Invalid NIX_DEBUG_INFO_DIRS!"
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'NIX_DEBUG_INFO_DIRS=.*/lib/debug'
# We need to override NIX_DEBUG_INFO_DIRS here as $HOME evalutes to the home
# of the user who executes this testcase :/
{ echo quit | PATH="$TESTED/home-path/bin''${PATH:+:}$PATH" NIX_DEBUG_INFO_DIRS=$TESTED/home-path/lib/debug \
gdb curl 2>&1 | \
grep 'Reading symbols from ${builtins.storeDir}/'; \
} || fail "Failed to read debug symbols from curl in gdb"
'';
};
}