前置阅读:Home Manager 入门 | nixos 从0实现全集 - 目录
一般情况下 flake.nix 中我们这样写 home-manager:
1
2
3
4
5
6
7
8
9
10
11
12
13
| {
inputs = {
nixpkgs.url = "https://mirrors.ustc.edu.cn/nix-channels/nixos-24.05/nixexprs.tar.xz";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ nixpkgs, home-manager, ... }: {
nixosConfigurations={
.....
};
}
|
在无梯子环境下 nixos-rebuild 大概率会卡在获取 GitHub 上文件的地方。记住这个 URL:https://github.com/nix-community/home-manager/archive/2f23fa308a7c067e52dfcc30a0758f47043ec176.tar.gz
第一个方案是使用国内支持 GitHub 同步的 Git 镜像,镜像一下 https://github.com/nix-community/home-manager 这个仓库。
第二个方案是使用 GitHub 下载代理网站,例如 https://ghp.ci/。此类网站稳定性很差,因为用的人太多,域名经常被封,建议自建:https://github.com/joyanhui/gh-proxy
然后:
1
| url = "github:nix-community/home-manager/release-24.05";
|
这行修改为:
1
| url="https://github代理地址/https://github.com/nix-community/home-manager/archive/2f23fa308a7c067e52dfcc30a0758f47043ec176.tar.gz";
|
例如:
1
| url="https://ghp.ci/https://github.com/nix-community/home-manager/archive/2f23fa308a7c067e52dfcc30a0758f47043ec176.tar.gz";
|
理论上过一段时间,你可能需要重新复原到 GitHub,然后关闭代理后获得这个 URL 后更新。或者直接去 https://github.com/nix-community/home-manager/ 对应的 tree/release-24.05 里面查询。