Stream: nix

Topic: Cache config in `nix run` of flake


view this post on Zulip Srid (Feb 13 2024 at 14:57):

This convo with @Andreas began as a way to provide project-specific caches to users who are installing these Nix packages outside of nixpkgs.

One way to automate that providing of cache is to add the cache to flake.nix (see example), and then ask the user to use --accept-flake-config to automatically use that cache when doing nix run or nix profile install, eg.:

nix --accept-flake-config run github:juspay/nix-browser#nix-health

view this post on Zulip Srid (Feb 13 2024 at 14:58):

If you run this command on macOS or Linux, it should just get binaries from the cache without building any of the Rust packages.

view this post on Zulip Andreas (Feb 13 2024 at 15:07):

I get the error warning: ignoring untrusted substituter 'https://cache.garnix.io', you are not a trusted user.

Which apparently has been an issue: https://discourse.nixos.org/t/ux-problems-with-flakes-and-custom-caches-substituters/23691

So it appears I have to configure this cache as a trusted substituter before using this?

view this post on Zulip Srid (Feb 13 2024 at 15:10):

You need to make yourself a trusted user.

srid on appreciate ~
❯ nix show-config | grep trusted-users
trusted-users = root srid

srid on appreciate ~
❯ grep trusted-users /etc/nix/nix.conf
trusted-users = root srid

view this post on Zulip Andreas (Feb 13 2024 at 15:16):

I'll set this in my system flake nix.settings.trusted-users and check later

view this post on Zulip Srid (Feb 13 2024 at 15:20):

It is one of the defaults we recommend to all, https://github.com/juspay/nix-dev-home?tab=readme-ov-file#cannot-use-cache--cachix

view this post on Zulip Andreas (Feb 13 2024 at 15:21):

Very wise suggestion I'd say. Also explains why I had trouble using other people's caches in the past when I didn't care to investigate.

view this post on Zulip Tim DeHerrera (Feb 13 2024 at 15:31):

you can also set a group to the trusted users by prepending with @. I usually just drop @wheel as a trusted user since they also have sudo access.

Also, even if you don't pass the --accept-flake-config flag, you will still be interactively prompted if you want to accept the cache config or not by default.

view this post on Zulip Andreas (Feb 13 2024 at 16:04):

I just found this comment https://github.com/NixOS/nix/issues/6672#issuecomment-1920721589

Suggesting to use the trusted-public-keys and substituters or trusted-substituters setting instead because just adding your user is a bit of a security issue. What do you guys say to that?

view this post on Zulip Srid (Feb 13 2024 at 16:16):

Depends on how you want to balance security vs usability.

view this post on Zulip Tim DeHerrera (Feb 13 2024 at 16:28):

Sure it is important to be aware that a trusted-user is essentially as powerful as root. Same issue as adding your user to the docker group as well. But multi-user systems are pretty rare these days. If you have one then sure, maybe you care more, but I am the admin in all my systems, and I get sudo based on the presence or absence of my yubikey where possible.

What I would really like is some sort of remote protocol for sending my yubikey creds over an ssh connection. For Nix, it might be interesting if someone could be a "trusted-user" based on the presence or absence of a yubikey OTP. That would really be an "improvement" in my view, but on single user systems where you are basically the only user and admin, the point is kinda moot.

Not being a trusted user just makes things more of a pain in the same way not having root on a smartphone can be a pain :sweat_smile:

view this post on Zulip Srid (Feb 13 2024 at 17:34):

Tim DeHerrera said:

What I would really like is some sort of remote protocol for sending my yubikey creds over an ssh connection. [..]

I enjoy a similar UX for ssh-based auths (like git pull in a ssh session, which uses local Touch ID for 1Password key access):

https://nixos.zulipchat.com/#narrow/stream/413950-nix/topic/1Password.20TouchID.20auth.20for.20git.2C.20ssh.2C.20etc.2E


Last updated: Nov 15 2024 at 12:33 UTC