Files
home-manager/tests/modules/misc/debug/default.nix
Austin Horstman 04d39635a6 home-environment: merge search variables idempotently
Switches `home.sessionPath` and `home.sessionSearchVariables` from
concatenation to the merge helper added in the previous commit. The
first merge preserves configured-first search order while removing
duplicate entries. Later merge blocks preserve inherited positions.

Entries that expand to an empty string are ignored. Statically empty
entries also produce an evaluation warning so an accidental
current-directory entry does not disappear silently.

Fish gets a native merge helper because babelfish rejects the POSIX
helper's quoted pattern removal, and Fish stores names ending in PATH as
lists. Candidate assignments and merge calls are translated together so
references to earlier search variables observe the same values as the
POSIX file. The native helper also preserves newline-bearing values
through Fish command substitutions.

A shared behavioral fixture sources both generated files for first and
later merges. It covers expansion and escaping, cross-variable
references, unset and empty values, duplicates, separator-bearing
entries, empty fields, Fish list shape, helper cleanup, and leading,
embedded, and trailing newlines.

Removes `prependToVar`, which has no consumers left and produced the
self-referential form this replaces. It was public through
`lib.hm.shell`, so the release notes include migration guidance.
2026-09-30 21:06:23 -05:00

40 lines
1.3 KiB
Nix

{
debug =
{
realPkgs,
config,
lib,
...
}:
lib.mkIf config.test.enableBig {
home.enableDebugInfo = true;
home.packages = with realPkgs; [
curl
gdb
];
nmt.script = ''
[ -L $TESTED/home-path/lib/debug/curl ] \
|| fail "Debug-symbols for pkgs.curl should exist in \`/home-path/lib/debug'!"
assertFileExists home-path/etc/profile.d/hm-session-vars.sh
(
export NIX_DEBUG_INFO_DIRS=/inherited/debug
unset __HM_SESS_VARS_SOURCED __HM_SESS_VARS_MERGED
. "$TESTED/home-path/etc/profile.d/hm-session-vars.sh"
case "$NIX_DEBUG_INFO_DIRS" in
*/lib/debug:/inherited/debug) ;;
*) echo "NIX_DEBUG_INFO_DIRS: $NIX_DEBUG_INFO_DIRS"; exit 1 ;;
esac
) || fail "Invalid NIX_DEBUG_INFO_DIRS!"
# We need to override NIX_DEBUG_INFO_DIRS here as $HOME evaluates 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"
'';
};
}