Adding `trusted-substituters` on the fly when running nixos-rebuild?

Accessing caches.nixos.org is extremely from my side for the moment.

I tried to use the --option binary-cache option when I run nixos-rebuild boot, but it complained that

warning: ignoring untrusted substituter 'https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store'

and ignored the binary cache that I supply.

Is there a way to force nixos-rebuild to trust my cache on-the-fly?

Though I can add it into configuration.nix, but it can only be applied after I succeed to run nixos-rebuild !

1 Like

Try adding the query param ?trusted=1 at the end of your substituter URL.

Seems not working:

$> nix-shell -p blender --option binary-caches 'https://mirrors.tsinghua.edu.cn/nix-channels/store?trusted=1'
warning: ignoring untrusted substituter 'https://mirrors.tsinghua.edu.cn/nix-channels/store?trusted=1'

Running nix commands with sudo seems resolves this problem.

To add a substitute, you need to be a trusted user. By default only root is a trusted user.

3 Likes