jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

[RFC][Devbox] computeEnv: remove __ETC_PROFILE_NIX_SOURCED=1 #2147

Closed savil closed 2 weeks ago

savil commented 2 weeks ago

Summary

This was introduced in #635 (cc @ipince). I don't think its needed anymore. It seems to be used in the /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh script, at the very top to prevent re-execution:

  1 # Only execute this file once per shell.
  2 if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi
  3 __ETC_PROFILE_NIX_SOURCED=1
  4

Perhaps it has other use-cases as well? RFC.

From my casual usage of a Devbox binary built with this change, it all seems to still work fine.

How was it tested?

savil commented 2 weeks ago

I can't remember why this was explicitly added either. Does nix-daemon.sh still only run once in devbox shell and devbox shell --pure? I think a good way to check is to see if there are duplicate paths in NIX_PROFILES.

My observations:

# start with devbox global 
 % env | grep NIX_PROFILE
NIX_PROFILES=/nix/var/nix/profiles/default /Users/savil/.nix-profile

# go to devbox repo and start the shell
% cd ~/code/jetpack/devbox
% devbox shell
Starting a devbox shell...
 % env | grep NIX_PROFILE
NIX_PROFILES=/nix/var/nix/profiles/default /Users/savil/.nix-profile

no duplicates seen!

gcurtis commented 2 weeks ago

Thanks for double checking!