cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.56k stars 259 forks source link

Cache error even with devenv cache set up #1097

Closed aidalgol closed 1 month ago

aidalgol commented 1 month ago

Describe the bug I have the devenv Cachix cache set as a substituter in my NixOS configuration, but I still get the cache warning when activating the direnv environment created by devenv init.

To reproduce

Contents of /etc/nix/nix.conf:

# WARNING: this file is generated from the nix.* options in
# your NixOS configuration, typically
# /etc/nixos/configuration.nix.  Do not edit it!
allowed-users = *
auto-optimise-store = true
builders = 
cores = 0
max-jobs = auto
require-sigs = true
sandbox = true
sandbox-fallback = false
substituters = https://cache.nixos.org/ https://cuda-maintainers.cachix.org https://devenv.cachix.org https://helix.cachix.org
system-features = nixos-test benchmark big-parallel kvm
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E= devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=
trusted-substituters = 
trusted-users = root
extra-sandbox-paths = 
experimental-features = nix-command flakes

Creating a fresh devenv project:

~ 
❯ mkdir junk

~ 
❯ cd junk

~/junk 
❯ devenv init
• Creating devenv.nix
• Creating devenv.yaml
• Creating .envrc
• Creating .gitignore
direnv: loading ~/junk/.envrc
direnv: loading https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc (sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0=)
direnv: using devenv
direnv: .envrc changed, reloading
✖ You're not a trusted user of the Nix store. You have the following options:

1. Add yourself to the trusted-users list in /etc/nix/nix.conf for devenv to manage caches for you.

trusted-users = root aidan

Restart nix-daemon with:

  $ sudo systemctl restart nix-daemon

2. Add binary caches to /etc/nix/nix.conf yourself:

extra-substituters = https://devenv.cachix.org
extra-trusted-public-keys = 

3. Disable Cachix in `devenv.nix`:

{
    cachix.enable = false;
}

• Failed to get cachix caches due to evaluation error
[0/1 built, 0.0 MiB DL] querying devenv-shell-env on https://cuda-maintainers.cachix.orgdirenv: ([/nix/store/lhcz6v59vwcdavh73aixrnzq5ppli1w5-direnv-2.34.0/bin/direnv export json]) is taking a while to execute. Use CTRL-C to give up.
direnv: updated devenv shell cache
hello from devenv
git version 2.43.2
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +DEVENV_DOTFILE +DEVENV_PROFILE +DEVENV_ROOT +DEVENV_RUNTIME +DEVENV_STATE +GREET +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_PKG_CONFIG_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_STORE +NM +OBJCOPY +OBJDUMP +PKG_CONFIG +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +cmakeFlags +configureFlags +dontAddDisableDepTrack +mesonFlags +name +system ~PATH ~XDG_DATA_DIRS

Version

devenv 1.0.2 (x86_64-linux)
domenkozar commented 1 month ago

Does it work if you set cachix.enable = false;?

aidalgol commented 1 month ago

I stop getting the error with that set.

qaristote commented 1 month ago

Same problem here, with the same nix.conf file (by this I mean I also have devenv as a substituter and the key as a trusted public key, and I'm not a trusted user), devenv version and error. Adding

extra-substituters = https://devenv.cachix.org
extra-trusted-public-keys =

at the end of nix.conf doesn't solve the problem (unsurprisingly), and neither does adding myself as a trusted user (it wouldn't be a satisfying solution if it did work though).

domenkozar commented 1 month ago

I'll release 1.0.3 shortly to address this.

domenkozar commented 1 month ago

https://github.com/cachix/devenv/releases/tag/v1.0.3

aidalgol commented 1 month ago

I'm still having this issue with 1.0.3.

domenkozar commented 1 month ago

@aidalgol can you share more what error you get an what you tried?

qaristote commented 1 month ago

I thought I still had this issue with 1.0.3 as well but I had actually misunderstood what the fix was supposed to do, so I'll say it here explicitely: I thought it would change the source code so that you could have cachix.enable = true while keeping track of your substituters manually, whereas it's actually just changing the error message to tell you that if you're not a trusted user, you should both add devenv to your trusted substituters and disable cachix.

aidalgol commented 1 month ago

Ah, I misunderstood what the fix was then. Thanks.