nix-community / nixos-anywhere

install nixos everywhere via ssh [maintainer=@numtide]
https://nix-community.github.io/nixos-anywhere/
MIT License
1.2k stars 90 forks source link

Deployment slow due to nix-copy-closure #57

Open DavHau opened 1 year ago

DavHau commented 1 year ago

Describe the bug

The deployment is quite slow for me, likely because the derivations are built using the nix remote build protocol which is very sensitive to network delay.

Lassulus commented 1 year ago

The deployment builds the system locally and nix-copy-closures it to the target

DavHau commented 1 year ago

I guess to deploy on foreign platforms we'd need to introduce a remote build strategy anyways. If so, maybe we can make this the default once we have it. Copying the flake to the remote host and building it there would do the job, I guess?

phaer commented 1 year ago

Remote building isn't supported yet - and I believe it might require some form of plugin/hook system.

A workaround might be to use nixos-anywheres --from parameter to pull from a remote store. That still requires you to push your system closure to said store first, but that could be done from a dedicated builder

Lassulus commented 1 year ago

we use -s in the copy closure, so we try to get most of the stuff from the binary cache. but this misses a lot of dependencies ofc. I'm usually nixos-remoting from a server, so everything works fast. I guess that is the best approach here? Maybe we can have an option for remote evaluation? but I guess we basically want to support what nixos-rebuild supports

phaer commented 1 year ago

But those are public caches by default, unless you set trusted-substituters via --option? --from would be what allows you to refer to your own remote nix store here. That store could contain your whole system closure, put there e.g. by your builder. In that case it shouldn't miss any dependencies, unless I am mistaken?

blaggacao commented 1 year ago

Tip: If nix copy is slow, maybe consider using this trick (export + ssh + zstd + unzstd + import): https://github.com/divnix/std-action/blob/main/run/action.yaml#L116-L122

nbraud commented 12 months ago

Tip: If nix copy is slow, maybe consider using this trick (export + ssh + zstd + unzstd + import): https://github.com/divnix/std-action/blob/main/run/action.yaml#L116-L122

FYI, the “trick” you linked is gone from current versions of that repo. I'm guessing you were referring to that revision?

I-Want-ToBelieve commented 1 month ago

--option substituters "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" don't work

Always use https://cache.nixos.org