This commit is contained in:
Peder Bergebakken Sundt 2025-03-13 19:53:30 +01:00
parent 0cb15af485
commit e9f58b8142

@ -25,7 +25,7 @@ _ns() {
cmd=("${cmd[@]:1}")
if [[ ${#cmd[@]} -gt 0 ]]; then
(
_ns false "${args[@]}"
_ns "$is_dev" "${args[@]}"
set -x
"${cmd[@]}"
)
@ -53,7 +53,7 @@ _ns() {
# traverse propagated inputs
# this is safe since the store paths form a DAG
# TODO: rethink this logic
# TODO: rethink native logic
local -i idx=-1
while [[ $((++idx)) -lt "${#storepaths_native[@]}" ]]; do
if [[ -f "${storepaths_native[$idx]}"/nix-support/propagated-native-build-inputs ]]; then
@ -72,16 +72,11 @@ _ns() {
done
# find things to add to env
local -a add_to_path=()
local -a add_to_libs=()
local -a add_to_share=()
local -a add_to_include=()
local -a add_to_pythonpath=()
local -A seen=()
# for storepath in "${storepaths_native[@]}"; do
for storepath in "${storepaths_build[@]}"; do
if [[ -n "${seen["$storepath"]:-}" ]]; then
if [[ -v seen["$storepath"] ]]; then
continue
fi
seen["$storepath"]=1
@ -90,10 +85,15 @@ _ns() {
export PATH="$storepath/bin${PATH:+":$PATH"}"
fi
if >/dev/null compgen -G "$storepath/lib/*.so"; then
export LD_LIBRARY_PATH="$(IFS=: ; printf "%s" "$storepath"/lib/*.so)${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}"
for path in "$storepath"/lib/*.so; do
export LD_LIBRARY_PATH="${path}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}"
done
fi
if >/dev/null compgen -G "$storepath/lib/*.so.*"; then
export LD_LIBRARY_PATH="$(IFS=: ; printf "%s" "$storepath"/lib/*.so.*)${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}"
local path
for path in "$storepath"/lib/*.so.*; do
export LD_LIBRARY_PATH="${path}${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}"
done
export CMAKE_LIBRARY_PATH="$storepath/lib${CMAKE_LIBRARY_PATH:+":$CMAKE_LIBRARY_PATH"}"
fi
if [[ -d "$storepath/lib/pkgconfig" ]]; then
@ -102,6 +102,9 @@ _ns() {
if [[ -d "$storepath/share" ]]; then
export XDG_DATA_DIRS="$storepath/share${XDG_DATA_DIRS:+":$XDG_DATA_DIRS"}"
fi
if [[ -d "$storepath/share/man" ]]; then
export MANPATH="$storepath/share/man${MANPATH:+":$MANPATH"}"
fi
if [[ -d "$storepath/share/pkgconfig" ]]; then
export PKG_CONFIG_PATH="$storepath/share/pkgconfig${PKG_CONFIG_PATH:+":$PKG_CONFIG_PATH"}"
fi