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

Add cache.nixos.org to trusted substituters by default #4306

Closed
wants to merge 2 commits into from

Conversation

matthewbauer
Copy link
Member

When a user is untrusted, Nix will only trust substituters that are in
trusted-substituters. But users don’t always know if they are trusted
or not by the Nix daemon, especially when sharing configs accross
machines. So for example, a user has a nix.conf in $HOME/.config/nix/
that looks like this:

substituters = https://cache.nixos.org https://my-custom-cache.cachix.org

Nix will override the default substituters, but skip both with:

warning: ignoring untrusted substituter ‘https://cache.nixos.org’
warning: ignoring untrusted substituter ‘https://my-custom-cache.cachix.org’

So the user now gets no substituters, and would have to remove the
substituters config setting to reenable cache.nixos.org. To fix this,
just include https://cache.nixos.org by default. This can still be
overridden by the user.

When a user is untrusted, Nix will only trust substituters that are in
trusted-substituters. But users don’t always know if they are trusted
or not by the Nix daemon, especially when sharing configs accross
machines. So for example, a user has a nix.conf in $HOME/.config/nix/
that looks like this:

  substituters = https://cache.nixos.org https://my-custom-cache.cachix.org

Nix will override the default substituters, but skip both with:

  warning: ignoring untrusted substituter ‘https://cache.nixos.org’
  warning: ignoring untrusted substituter ‘https://my-custom-cache.cachix.org’

So the user now gets no substituters, and would have to remove the
substituters config setting to reenable cache.nixos.org. To fix this,
just include https://cache.nixos.org by default. This can still be
overridden by the user.
@Ericson2314
Copy link
Member

Because of relocatable source code / deprecation hassjed mirrors, maybe this should be unconditional?

@matthewbauer
Copy link
Member Author

That sounds like a good idea. Should both substituters and trusted-substituters be unconditional?

Since 0744f7f, it is now useful to
have cache.nixos.org in substituers even if /nix/store is not the Nix
Store Dir. This can always be overridden via configuration, though.
@grahamc
Copy link
Member

grahamc commented Dec 3, 2020 via email

@grahamc
Copy link
Member

grahamc commented Dec 3, 2020

To say more, there are Nix users who don't use our cache and don't want to trust our cache.

@matthewbauer
Copy link
Member Author

Does this set a default, or does it force users to trust c.n.o?

So it adds another option they need to set if they don't trust our cache.nixos.org. Currently, they just need to set substituters = ... to remove cache.nixos.org. With this, they also need to set trusted-substituters = .... to do that. If we're concerned that's too much configuration, we could make trusted-substituters default to the value of substituters if unset I think.

@Ericson2314
Copy link
Member

Ericson2314 commented Dec 3, 2020

Two questions:

  1. Does ~/.config/nix/nix.conf vs CLI flags make a difference?
  2. What about if Nix made every substituter also a trusted-substituter?

These two has been terrible for years, and it would be nice to really fix. Maybe call them default-substituters and available-substituters, too.

@domenkozar
Copy link
Member

Since 99% of users will use this I support this being opt-out via some flag.

@matthewbauer
Copy link
Member Author

  1. Does ~/.config/nix/nix.conf vs CLI flags make a difference?

It shouldn't make any difference - CLI flags should always have precedence over any nix.conf though.

  1. What about if Nix made every substituter also a trusted-substituter?

I'm not sure how to do this in the way the current configuration works. We'd want the default for one setting to depend on the default of the other setting, which I don't think? we have a way to do right now.

@Ericson2314
Copy link
Member

I'm not sure how to do this in the way the current configuration works. We'd want the default for one setting to depend on the default of the other setting, which I don't think? we have a way to do right now.

I would change every access of trusted-substitutors to instead check substitutors ++ trusted-substitutors.

@edolstra
Copy link
Member

edolstra commented Dec 4, 2020

What about if Nix made every substituter also a trusted-substituter?

That's already the case, see daemon.cc:

                StringSet trusted = settings.trustedSubstituters;
                for (auto & s : settings.substituters.get())
                    trusted.insert(s);

@matthewbauer
Copy link
Member Author

matthewbauer commented Dec 5, 2020

Oh this was my bad! This was just a case of a missing slash in my substituters not being picked up (https://cache.nixos.org/ was in trusted-substituters but not https://cache.nixos.org/). I had assumed trusted-substituters was completely empty.

See #4318 for a real fix for that problem.

@domenkozar
Copy link
Member

I wish that uris would be normalized, that would save lots of frustration.

@Ericson2314
Copy link
Member

@matthewbauer we may still want to do the change of not caring about the store path?

@matthewbauer
Copy link
Member Author

@matthewbauer we may still want to do the change of not caring about the store path?

Yes - #4321

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

Successfully merging this pull request may close these issues.

None yet

5 participants