Help, i broke my nix channel

Today I planned to upgrade my system but cache.nixos.org was too slow and unable to fully download all the necessary packages.

Therefore, I changed my nix-channel to the following because I currently live in China:

> sudo nix-channel --list
> nixos https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-24.11
> store https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store

I also edited my configuration.nix to include the following:

>   `# Change Nix channels`
>   system.autoUpgrade.channel = "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-24.11"
> 
>   `# Change binaryCaches mirror`
>   nix.binaryCaches = ["https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"];

When I do

sudo nix-channel --update

It returned the following:

error: unable to download ‘https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store//nixexprs.tar.bz2’: HTTP error 404

   response body:

   <html>
   <head><title>404 Not Found</title></head>
   <body>
   <center><h1>404 Not Found</h1></center>
   <hr><center>nginx/1.22.1</center>
   </body>
   </html>

Now I am unable to upgrade the system or download any packages.
I tried rollback but it did not work. I do not know how to fix this.

Please help.

Remove the store channel. Not sure what that is meant to reflect from the channel.nixos.org anyway…

1 Like

Without the store channel, it says:

warning: Nix search path entry ‘/nix/var/nix/profiles/per-user/root/channels’ does not exist, ignoring

And didn’t upgrade anything.
That is why I am asking for help because I tried.

Thank you for your reply.

This warning suggests, that there is no channel left at all…

You have to keep a nixos channel.

Also it might be necessary that you rerung sudo nix-channel --update after removing the faulty channel, or adding a new channel.

Thank you. I will remove the store one and try again when I get back home.

Hi, I triey and it says syntax error of the following line.

I do not see a syntax error in that line.

Can you please share the exact error message you get?

Also I think you actually want nix.settings.substituters… As nix.binaryCaches is not a valid option regarding to NixOS Search

error:
… while evaluating the attribute ‘config’
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12284:
… while calling the ‘seq’ builtin
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:1:12293:
(stack trace truncated; use ‘–show-trace’ to show the full, detailed trace)

   error: syntax error, unexpected '=', expecting ';'
   at /etc/nixos/configuration.nix:121:29:
      120|   # Change binaryCaches mirror
      121|   nix.settings.substituters = "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
         |                             ^
      122|

In the lines before that, you seem to lack a semicolon.

Thanks, but it is still fetching from cache.nixos.org instead of mirrors.tuna.tsinghua.edu.cn

That means that you have not disabled cache.nixos.org.

The way the defaults are laid out, is that ["cache.nixos.org"] is not defined as a default value, but as a “flat” value with the same priority as any the values you add yourself. This way one doesn’t have to add it manually when also adding other caches. So “adding” is easier this way, and it is not really expected that poeple want to use nixos without the nixos caches.

You probaly want to use lib.mkForce to give your value a lower priority and therefore precedence over the NixOS provided value.

How can I use that?
Is that an nixOS option?

I also found a user who had a problem with the previous Tuna mirror. So I am going to use this one instead.
https://discourse.nixos.org/t/enable-different-priority-substituters-with-flake/56073/3

Its a function. You use it by calling it. The module system knows how to deal with that.

nix.binaryCaches = lib.mkForce ["https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"];

No use, it still fetches from cache.nixos.org


You have to rebuild/switch at least once to make it realize in the /etc/nix/nix.conf.

For this initial rebuild, you have to use --option substituters "your.thing.here" if the global fastly provided nixos cache does you any trouble for you.

1 Like

Thank you so much.
It finally worked.
It is now downloading blazingly fast.
I finally solved this problem.
Now I gntta work on kde’s random freezing problem.