Skip to content

Commit

Permalink
Add custom cache server
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRTitor committed Mar 15, 2024
1 parent 2092eb6 commit 3cdfcbf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

# include adb settings
./dev-environment/adb.nix

# include custom cache server settings
./misc/custom-cache-server.nix
];

networking.hostName = systemSettings.hostname; # Define your hostname.
Expand Down
34 changes: 34 additions & 0 deletions misc/custom-cache-server.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This config is used to define a custom cache server setting for the system
# It is useful when your build time is slow due to the network latency
{ userSettings, ... }:
{
nix.settings = {
# main user has access to modify trusted cache server
trusted-users = [ userSettings.username ];

substituters = [
# cache mirror located in China
# status: https://mirror.sjtu.edu.cn/
# "https://mirror.sjtu.edu.cn/nix-channels/store"
# status: https://mirrors.ustc.edu.cn/status/
# "https://mirrors.ustc.edu.cn/nix-channels/store"

# default cache server
"https://cache.nixos.org"
# nix community's cache server
"https://nix-community.cachix.org"
];

trusted-public-keys = [
# nix community's cache server public key
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
# Use socks5 proxy for nix-daemon
# To accelerate downloads
systemd.services.nix-daemon.environment = {
# socks5h means that the hostname is resolved by the SOCKS server
https_proxy = "socks5h://localhost:7891";
# https_proxy = "http://localhost:7890"; # or use http protocol instead of socks5
};
}

0 comments on commit 3cdfcbf

Please sign in to comment.