tuna / issues

Code Unrelated Issues
362 stars 28 forks source link

nix binary cache mirror doesn't work on macOS #1447

Open athrunsun opened 2 years ago

athrunsun commented 2 years ago

先决条件 (Prerequisites)

发生了什么(What happened)

Add nix channel mirror:

nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable nixpkgs1
nix-channel --update

Add binary cache mirror to /etc/nix/nix.conf and add myself to trusted-users:

build-users-group = nixbld
substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
trusted-users = bruce root

Restart nix daemon:

sudo launchctl kickstart system/org.nixos.nix-daemon

Verify configuration is updated: nix --extra-experimental-features nix-command show-config, output:

accept-flake-config = false
access-tokens = 
allow-dirty = true
allow-import-from-derivation = true
allow-symlinked-store = false
allow-unsafe-native-code-during-evaluation = false
allowed-impure-host-deps = /System/Library /bin/sh /dev /usr/lib
allowed-uris = 
allowed-users = *
auto-optimise-store = false
bash-prompt = 
bash-prompt-suffix = 
build-hook = /nix/store/669p1vjnzi56fib98qczwlaglcwcnip4-nix-2.6.0/libexec/nix/build-remote
build-poll-interval = 5
build-users-group = nixbld
builders = @/etc/nix/machines
builders-use-substitutes = false
commit-lockfile-summary = 
compress-build-log = true
connect-timeout = 0
cores = 8
darwin-log-sandbox-violations = false
diff-hook = 
download-attempts = 5
enforce-determinism = true
eval-cache = true
experimental-features = nix-command
extra-platforms = x86_64-darwin
fallback = false
flake-registry = https://github.com/NixOS/flake-registry/raw/master/flake-registry.json
fsync-metadata = true
gc-reserved-space = 8388608
hashed-mirrors = 
http-connections = 25
http2 = true
impersonate-linux-26 = false
keep-build-log = true
keep-derivations = true
keep-env-derivations = false
keep-failed = false
keep-going = false
keep-outputs = false
log-lines = 10
max-build-log-size = 0
max-free = 18446744073709551615
max-jobs = 1
max-silent-time = 0
min-free = 0
min-free-check-interval = 5
nar-buffer-size = 33554432
narinfo-cache-negative-ttl = 3600
narinfo-cache-positive-ttl = 2592000
netrc-file = /etc/nix/netrc
nix-path = /Users/bruce/.nix-defexpr/channels nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs /nix/var/nix/profiles/per-user/root/channels
plugin-files = 
post-build-hook = 
pre-build-hook = 
preallocate-contents = false
print-missing = true
pure-eval = true
repeat = 0
require-sigs = true
restrict-eval = false
run-diff-hook = false
sandbox = false
sandbox-fallback = true
sandbox-paths = /System/Library/Frameworks /System/Library/PrivateFrameworks /bin/bash /bin/sh /private/tmp /private/var/tmp /usr/lib
secret-key-files = 
show-trace = false
stalled-download-timeout = 300
store = auto
substitute = true
substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
sync-before-registering = false
system = aarch64-darwin
system-features = benchmark big-parallel nixos-test
tarball-ttl = 3600
timeout = 0
trace-function-calls = false
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
trusted-substituters = 
trusted-users = bruce root
use-case-hack = true
use-registries = true
use-sqlite-wal = true
user-agent-suffix = 
warn-dirty = true

Install a package: nix-env -iA nixpkgs1.tig, output:

installing 'tig-2.5.5'
these 117 paths will be fetched (39.38 MiB download, 248.66 MiB unpacked):
...
copying path '/nix/store/m0nsx4ai768kjp9c40vhkpj9pxlii46m-bash-5.1-p12' from 'https://cache.nixos.org'...

期望的现象(What you expected to happen)

Install a package: nix-env -iA nixpkgs1.tig, output:

installing 'tig-2.5.5'
these 117 paths will be fetched (39.38 MiB download, 248.66 MiB unpacked):
...
copying path '/nix/store/m0nsx4ai768kjp9c40vhkpj9pxlii46m-bash-5.1-p12' from 'https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store'...

如何重现此问题(How to reproduce it)

Follow steps in "What happened".

操作系统(OS Version)

macOS monterey 12.2.1

浏览器(如果适用)(Browser version, if applicable)

No response

其他环境(Other environments)

nix version: 2.6.0

其他需要说明的事项(Anything else we need to know)

No response

ZenithalHourlyRate commented 2 years ago

I suddenly recalled an issue on tuna nix-darwin. Refer to https://github.com/sjtug/mirror-requests/issues/220

athrunsun commented 2 years ago

@ZenithalHourlyRate I came across that issue yesterday, and I've tried https://mirror.sjtu.edu.cn/nix-channels/store, doesn't work, still downloading fom https://cache.nixos.org. Are you using nix on macOS?

ZenithalHourlyRate commented 2 years ago

We have two issues here. One is untrusted-user, another one is tuna did not mirror nix-darwin.

sjtu should work as it is a reverse proxy instead of a mirror.

doesn't work

Did nix prompt untrusted user or just fallback to cache.nixos.org silently.

athrunsun commented 2 years ago

@ZenithalHourlyRate I've already added myself into the trusted users list: trusted-users = bruce root.

It just fallback to cache.nixos.org silently.

I should see sth. like copying path '/nix/store/m0nsx4ai768kjp9c40vhkpj9pxlii46m-bash-5.1-p12' from 'https://mirror.sjtu.edu.cn/nix-channels/store'... right?

ZenithalHourlyRate commented 2 years ago

I should see sth. like copying path '/nix/store/m0nsx4ai768kjp9c40vhkpj9pxlii46m-bash-5.1-p12' from 'https://mirror.sjtu.edu.cn/nix-channels/store'... right?

Unfortunately no. TUNA currently does not mirror nix-darwin contents. Refer again to https://github.com/sjtug/mirror-requests/issues/220

athrunsun commented 2 years ago

@ZenithalHourlyRate I mean, if I use sjtu mirror (NOT tuna mirror), I should see sth. like copying path '/nix/store/m0nsx4ai768kjp9c40vhkpj9pxlii46m-bash-5.1-p12' from 'https://mirror.sjtu.edu.cn/nix-channels/store'... right?

ZenithalHourlyRate commented 2 years ago

(NOT tuna mirror),

Sorry for that mistake. Yes you should see that, but now I don't know why it did not work. I'll look into it later.