Skip to content

.envrc: add dotenv_if_exists#327493

Closed
hellwolf wants to merge 1 commit intoNixOS:masterfrom
hellwolf:patch-2
Closed

.envrc: add dotenv_if_exists#327493
hellwolf wants to merge 1 commit intoNixOS:masterfrom
hellwolf:patch-2

Conversation

@hellwolf
Copy link
Contributor

Description of changes

.envrc: add dotenv_if_exists

As a developer, I would like to use my local .env when working on a new PR.

Following some advice from: https://github.com/direnv/direnv/wiki/.envrc-Boilerplate

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@hellwolf hellwolf requested review from a team and infinisil as code owners July 15, 2024 22:09
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jul 16, 2024
@hellwolf
Copy link
Contributor Author

hellwolf commented Jul 23, 2024

Any chance to have this considered? @infinisil

@infinisil
Copy link
Member

There's a longer discussion on this in #325793

# following the advice from https://github.com/direnv/direnv/wiki/.envrc-Boilerplate
# load developer's own local .env

dotenv_if_exists || direnv status # https://direnv.net/man/direnv-stdlib.1.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I want to load variables before use nix that influence how Nix will operate?

Copy link
Contributor Author

@hellwolf hellwolf Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know... maybe you shouldn't? that's probably the bad "side effects" and can give surprises.

I think the upstream decides to remove the .envrc after all. So I guess, we are gonna be back to the previous status quo.

I actually wouldn't mind much, and started to commit .envrc in other projects after I saw the wki page on direnv...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting something like NIXPKGS_ALLOW_UNFREE could be useful to some before Nix is invoked on a per-project basis. This does not seem weird.

@hellwolf hellwolf closed this Jul 27, 2024
@hellwolf hellwolf deleted the patch-2 branch April 6, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants