Skip to content

Unable to use a different binary cache as root #127

Closed

Description

@wizeman

In NixOS, when using the following command line as root:

nixos-rebuild switch --option binary-caches "http://cache.nixos.org" -I /home/wizeman/nixos-dev/

or even:

nixos-rebuild switch --option trusted-binary-caches "http://cache.nixos.org" --option binary-caches "http://cache.nixos.org" -I /home/wizeman/nixos-dev/

I got the following error:

building the system configuration...
error: substituter `/nix/store/sxhiwkydfwcvsm77splhzlda63p8l5cv-nix-1.5.2/libexec/nix/substituters/download-from-binary-cache.pl' failed: binary cache ‘http://cache.nixos.org’ is not trusted (please add it to ‘trusted-binary-caches’ [http://nixos.org/binary-cache] in /etc/nix/nix.conf)

I don't have any special "nix.*" option in configuration.nix, and NIX_REMOTE is empty.

The way to reproduce it is somewhat complicated:

  1. Make sure you don't have any "nix.*" option in configuration.nix, or any non-default setting in /etc/nix/nix.conf
  2. Make sure that you are root and that NIX_REMOTE is empty
  3. Make your changes effective and simulate that nixos.org is down (so that you want to use a different binary cache):
nixos-rebuild switch
route add -host nixos.org reject
  1. Remove some package from your environment.systemPackages in configuration.nix
  2. Run:
nix-collect-garbage -d
  1. Now try to make your change effective by doing:
nixos-rebuild switch --option binary-caches "http://cache.nixos.org"

Most likely, you will get the error above.

Activity

  1. wizeman commented on May 31, 2013

    @wizeman
    MemberAuthor

    BTW, the workaround I used was to run "nixos-rebuild switch" without "--option binary-caches", waiting for the download to fail, then in another console I ran (as a user):

    $ sudo nix-build --option binary-caches http://cache.nixos.org -A patchelf
    

    (... of course, replacing "patchelf" by whatever package was failing to download).

    Then I went back to running "nixos-rebuild switch" without any option, and cyclically did this until I downloaded all necessary files and "nixos-rebuild switch" wouldn't need to download any more.

    Finally, I set the following in configuration.nix:

    nix.trustedBinaryCaches = [ "http://nixos.org/binary-cache" "http://cache.nixos.org" ];
    
  2. added 2 commits that reference this issue on Jan 1, 2024
  3. added a commit that references this issue on Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions