Skip to content

Commit 9fc84ae

Browse files
authored
fix: preserve local direnv settings (#26122)
## Which issue does this PR close? Closes #26101 , which was introduced in #26005. cc @kumarUjjawal @kosiew ## What changes are included in this PR? Load an ignored .envrc.local after the shared Nix environment so contributors can keep machine-specific settings without modifying tracked files. Document the Nix, direnv, and local override workflow in the development environment guide. Following recommendation from direnv: https://github.com/direnv/direnv/blob/e24ea74873aff78d5e371c85061dc7fafdeedd5a/README.md#quick-demo ## Are there any user-facing changes? No.
1 parent f868d60 commit 9fc84ae

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎.envrc‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
use flake
1+
source_up_if_exists
2+
if command -v nix >/dev/null 2>&1; then
3+
use flake
4+
fi
5+
source_env_if_exists .envrc.local

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ datafusion/core/benches/data/*
7272
# Generated Nix environment hooks
7373

7474
.direnv/
75+
.envrc.local
7576

7677
# rat
7778
filtered_rat.txt

‎docs/source/contributor-guide/development_environment.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ Notes:
5252
- `protoc` is required to compile DataFusion from source.
5353
- Some tests and examples rely on git submodule data being present locally.
5454

55+
## Nix and direnv
56+
57+
The repository's `flake.nix` provides a Nix development shell. Enter it directly
58+
with `nix develop`, or install and configure [direnv](https://direnv.net/) and run
59+
`direnv allow` from the repository root to load it automatically.
60+
61+
The repository's `.envrc` first loads the nearest ancestor `.envrc`, if one
62+
exists, and then loads the shared Nix environment when Nix is installed. Put
63+
project-specific direnv settings in `.envrc.local`. This file is ignored by Git
64+
and loaded last so that local settings take precedence.
65+
66+
If you previously kept personal settings in the repository's `.envrc`, move
67+
only those settings to `.envrc.local`. Do not copy the shared `.envrc`, as doing
68+
so would load the Nix environment twice.
69+
5570
## Windows Setup
5671

5772
```shell

0 commit comments

Comments
 (0)