Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS - Migration from direnv #36

Closed
rdelgatte opened this issue Sep 1, 2020 · 12 comments
Closed

MacOS - Migration from direnv #36

rdelgatte opened this issue Sep 1, 2020 · 12 comments

Comments

@rdelgatte
Copy link

Hello,

I've been using direnv for some times now and I wanted to use nix-direnv to benefit from the caching mechanism but I can't figure out why it does not work on my side.
It looks like it keeps using direnv whereas I tried to install and configure nix-direnv following the documentation.

  • I updated my project .envrc file as below:
use nix
  • I installed nix-direnv using nix-env and tried but I still get the following output:
  • I ran direnv allow in my project directory
  • Result = It keeps using direnv as before:
➜  projects cd my-project
direnv: loading ~/projects/my-project/.envrc
direnv: using nix
direnv: ([/Users/Remi/.nix-profile/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.
direnv: export +API_MGT_HOST +AR +AR_FOR_TARGET +AS +AS_FOR_TARGET +CC +CC_FOR_TARGET +CLIENT_ID +CLIENT_SECRET +CONFIG_SHELL +CXX +CXX_FOR_TARGET +DATA_DICTIONARY_X_API_KEY +DETERMINISTIC_BUILD +GRAFANA_ADMIN_PASSWORD +GRAFANA_ADMIN_USER +HOST_PATH +INFLUXDB_PASSWORD +IN_NIX_SHELL +LD +LD_DYLD_PATH +LD_FOR_TARGET +LOCALES +MACOSX_DEPLOYMENT_TARGET +MASTER_DATA_X_API_KEY +NIX_BINTOOLS +NIX_BINTOOLS_FOR_TARGET +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_apple_darwin +NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_apple_darwin +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_FOR_TARGET +NIX_CC_WRAPPER_TARGET_HOST_x86_64_apple_darwin +NIX_CC_WRAPPER_TARGET_TARGET_x86_64_apple_darwin +NIX_CFLAGS_COMPILE +NIX_CFLAGS_COMPILE_FOR_TARGET +NIX_COREFOUNDATION_RPATH +NIX_DONT_SET_RPATH +NIX_DONT_SET_RPATH_FOR_BUILD +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_IGNORE_LD_THROUGH_GCC +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_LDFLAGS_FOR_TARGET +NIX_NO_SELF_RPATH +NIX_STORE +NM +NM_FOR_TARGET +PATH_LOCALE +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +RANLIB +RANLIB_FOR_TARGET +SDKROOT +SIZE +SIZE_FOR_TARGET +SOURCE_DATE_EPOCH +STRINGS +STRINGS_FOR_TARGET +STRIP +STRIP_FOR_TARGET +TEMP +TEMPDIR +TMP +__CF_USER_TEXT_ENCODING +__darwinAllowLocalNetworking +__impureHostDeps +__propagatedImpureHostDeps +__propagatedSandboxProfile +__sandboxProfile +buildInputs +builder +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +gl_cv_func_getcwd_abort_bug +name +nativeBuildInputs +nobuildPhase +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~NIX_PATH ~PATH

I also tried to install it "from source" as explained in the documentation but I got the same result in the end.

Here are more details about my nix-env installed packages:

cachix-0.3.7
direnv-2.21.3
nix-2.3.7
nix-direnv-1.1
nss-cacert-3.49.2

I must have mis-installed something as I am new to nix stuff so any help debugging my problem is very much appreciated!

Thank you!

@Mic92
Copy link
Member

Mic92 commented Sep 1, 2020

Have you added nix-direnv to your ~/.direnvrc, i.e. source $HOME/nix-direnv/direnvrc?

@rdelgatte
Copy link
Author

Unfortunately I already tried doing that (after installing from source = https://github.com/nix-community/nix-direnv#installation-from-source) but it didn't help. I keep having the same result.
Do you have any other clue?

@Mic92
Copy link
Member

Mic92 commented Sep 2, 2020

To exclude any potential error sources, can you just clone the repository and than use the full path to the direnvrc in nix-direnv in your project .envrc?

i.e.:

# .envrc
source /User/bla/nix-direnv/direnvrc
use nix

@rdelgatte
Copy link
Author

rdelgatte commented Sep 2, 2020

It looks a lot better this way! Thank you for your help 👍
What should we do about that? Do you have any clue about why the former option (installing from source = nix-community/nix-direnv#installation-from-source) did not work?

BTW because I did not install it using nix-env I am experiencing the same MacOS issue with grep described here: #3.

@Mic92
Copy link
Member

Mic92 commented Sep 3, 2020

I don't know why it is not picking up your .direnvrc in your home directory. You may want to post its content. Regarding grep on macOS it is probably the idea to just use the home-manager variant: https://github.com/nix-community/nix-direnv#home-manager

@rdelgatte
Copy link
Author

Sorry for my late feedback. Here is my ~/.direnvrc file content:

source $HOME/nix-direnv/direnvrc

@Mic92
Copy link
Member

Mic92 commented Sep 14, 2020

@zimbatm I suppose also on macOS, direnv reads ~/.direnvrc?

@zimbatm
Copy link
Member

zimbatm commented Sep 14, 2020

it's the same logic as on Linux

@Mic92
Copy link
Member

Mic92 commented Sep 28, 2020

I updated https://github.com/nix-community/nix-direnv#with-nix-env to be more clear how to install nix.

@blaggacao
Copy link

blaggacao commented Sep 30, 2020

Wouldn't it make sense to consider upstreaming this directly to direnv? Or does it still need evolution / refinement? Even with numtide/devshell the speedup is in the order of megaseconds. (Just normal seconds that feel mega long. 😉 )

@Mic92
Copy link
Member

Mic92 commented Oct 2, 2020

The cache invalidation is not sound. direnv/direnv#238
There might be cases when we need to re-evaluate the nix expression i.e. if imported file is updated. The generic use_nix from direnv does not have this problem but is slower.

@Mic92
Copy link
Member

Mic92 commented Dec 9, 2020

I think the questions has been answered.

@Mic92 Mic92 closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants