Nix SSL path set incorrectly in the daemon on macOS #226
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#226
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There's a bug in
scripts/nix-profile-daemon.sh.in(and debatably all the other activation scripts) where on macOS, if you don't for some reason have system certificates in a path matching a Linux distribution (not a default configuration), it will try to find one in the default or user profile, which if you've accidentally misconfigured them without certificates, will then break, as there's no fallback for macOS.It will then set the environment variable to a "random" broken path within the last profile
This is worse than expected for extremely silly reasons.
It turns out that on macOS, the daemon itself never even actually sees
/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.shbecause that file is loaded by (amongst other places that are unused)/etc/bashrc. Nix's default daemon is launched via non-interactive, non-login/bin/shwhich runs/bin/bashin compatibility mode on macOS.This means that it will not even see
/etc/profilein the first place. So we try running it as a login shell right? Well. Not quite enough either. That will process/etc/profileand it will recognize itself as running under bash with$BASHbeing set, and properly source/etc/bashrc, except, that won't even get to the line that loads the environment for the Lix daemon, because it starts by checking if there's a$PS1set already as a proxy for "are we running interactively".What a mess. Let's just manually include the proper sourcing of the environment...
Lix looks at
/etc/ssl/certs/ca-certificates.crtand/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crtby default for thessl-cert-fileoption, which it will then override ifNIX_SSL_CERT_FILEorSSL_CERT_FILEis defined. So thenix-daemon.shscript doesn't really matter here. If/etc/ssl/certs/ca-certificates.crtdoesn't exist and all profiles have uninstalledca-certificatesthen we don't have certificates to even find regardless of the environment. A proper fix here is to teach Lix to read the system certificates out of the keychain and synthesize a file for itself. Either that or to have Lix itself depend onpkgs.cacertto use as a fallback path if the system doesn't have any.If we want to get system certs without writing a bunch of keychain code we could run
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychainto print all the system roots in PEM format.Does this issue mean that all fresh lix macOS installed does not really work? I tried following the instructions from the website and ends up with an installation where I cannot basically do anything:
Output
I did run into this problem: https://github.com/NixOS/nix/issues/2899. Even though I used lix-installer uninstall and manually removed a bunch of stuff from previous installs. I had a bad/broken symlink in
/etc/ssl/certs/ca-certificates.crtwhich made it fail.I haven't run a fresh install in ages, my recollection is it sets up the default profile with both lix and
pkgs.cacert, and that default profile is how it should find the certs. If you have a broken/etc/ssl/certs/ca-certificates.crtsymlink though that will certainly break things. Perhaps we should detect the broken link when looking for certs?I filed #560 about the broken symlink.