build: make environment adapt to Nixos

This commit is contained in:
2025-12-08 16:04:06 +08:00
parent 3bc68ced4c
commit 7c09706628
3 changed files with 221 additions and 111 deletions

View File

@@ -60,6 +60,18 @@
KERNEL_DIR = "${pkgs.linuxHeaders}/include";
};
# 创建 .venv 软链接到 .devenv/state/venv
scripts.linkVenv.exec = ''
if [ -L ".venv" ] || [ ! -e ".venv" ]; then
rm -f ".venv" 2>/dev/null || true
ln -s ".devenv/state/venv" ".venv"
echo "Created symlink: .venv -> .devenv/state/venv"
elif [ -e ".venv" ]; then
echo "Warning: .venv exists and is not a symlink. Not replacing it."
echo "If you want to replace it with a symlink, please remove it manually first."
fi
'';
# https://devenv.sh/basics/
enterShell = ''
export NIX_LD_LIBRARY_PATH="$NIX_LD_LIBRARY_PATH:${lib.makeLibraryPath [ pkgs.linuxHeaders ]}";
@@ -69,5 +81,7 @@
echo "LD_LIBRARY_PATH set to $LD_LIBRARY_PATH"
echo "CPATH set to $CPATH"
echo "KERNEL_DIR set to $KERNEL_DIR"
linkVenv
'';
}