1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-01 10:58:31 +02:00
home-manager/tests/modules/misc/debug/default.nix
Maximilian Bosch 0056a5aea1
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
2020-03-07 15:03:44 +01:00

26 lines
1.0 KiB
Nix

{
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"
'';
};
}