-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.envrc
More file actions
56 lines (51 loc) · 2.2 KB
/
Copy path.envrc
File metadata and controls
56 lines (51 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# shellcheck shell=bash
set -euo pipefail
if ! has nix_direnv_version || ! nix_direnv_version 3.1.1; then
source_url https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.1/direnvrc sha256-p+fzQdrms/hDa7g+soShAybJNo4bN4SIAeSfqNKgD5I=
fi
# `use flake` only invalidates the cached dev shell when flake.nix or
# flake.lock change — not the .nix files they import. Watch those too,
# so edits to the devShell package list (e.g. adding x264) or the
# toolchain rebuild the shell instead of serving a stale cache.
# Must run BEFORE `use flake`: nix-direnv snapshots the watch list into
# its cache manifest when `use flake` executes; files watched later only
# re-source .envrc while the stale dev shell keeps being served.
watch_file nix/packages.nix nix/common.nix nix/tasks.nix
# `nix print-dev-env` reports stdenv's bash as `SHELL`. Interactive direnv
# hooks protect the caller's login shell from that value, but `direnv exec`
# does not. Muster starts the development server with `direnv exec`, and the
# server in turn uses `SHELL` for every new terminal, so preserve the value
# with which direnv was invoked.
_blit_had_shell=${SHELL+x}
_blit_shell=${SHELL-}
use flake .
if [ "$_blit_had_shell" = x ]; then
export SHELL="$_blit_shell"
else
unset SHELL
fi
unset _blit_had_shell _blit_shell
# nix-direnv does not propagate LD_LIBRARY_PATH from the devShell
# (direnv filters it). blit-server dlopen's GPU libraries at runtime:
# VA-API: libva.so, libva-drm.so
# EGL: libEGL.so, libGLESv2.so (via GLVND dispatch)
# GBM: libgbm.so
# NVIDIA: libcuda.so, libnvidia-encode.so (from /run/opengl-driver)
# Mesa: VA-API / EGL drivers (from /run/opengl-driver)
#
# Re-export from LIBRARY_PATH (which nix-direnv does propagate from
# buildInputs) plus the NixOS driver runpath.
_gpu_ld=""
if [ -d /run/opengl-driver/lib ]; then
_gpu_ld="/run/opengl-driver/lib"
fi
# LIBRARY_PATH has the Nix store paths for libva, libglvnd, libgbm etc.
# from the devShell's buildInputs.
if [ -n "${LIBRARY_PATH:-}" ]; then
_gpu_ld="${_gpu_ld:+$_gpu_ld:}$LIBRARY_PATH"
fi
if [ -n "$_gpu_ld" ]; then
export LD_LIBRARY_PATH="$_gpu_ld${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi
unset _gpu_ld
dotenv_if_exists .env.local