[Nix#9441] Assorted peculiarities of the various nix-profile{,-daemon}.{,fi}sh files #96
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
awaiting
author
awaiting
contributors
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#96
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?
Upstream-Issue: NixOS/nix#9441
Recently, a patch was introduced to add Nix's paths to
XDG_DATA_DIRS: https://github.com/NixOS/nix/pull/8985This had an oversight, which was fixed in a PR: https://github.com/NixOS/nix/pull/9312
...which also had an oversight which was released as 2.19.0, and fixed in a PR: https://github.com/NixOS/nix/pull/9425
This reminded me of all the reasons the Determinate Nix Installer was created, and inspired me to examine the profile scripts and experiment with porting it to Rust.
Note that this isn't intended to be a "call-out" thread where I drag people through the mud or whatever. I probably introduced several of these personally! This code was written by smart people, trying to do the right thing, but the challenges of scripting languages makes it hard to do it right.
I identified the following inconsistencies:
nix-profile-daemon.{fish,sh}protect against double-loading butnix-profile.{fish,sh}don't:nix-profile-daemeon.fishsometimes leaks theadd_pathfunction, because it registers the function and then detects if Nix was sourced already:nix-profile.{fish,sh}check thatHOMEis defined before using it, butnix-profile-daemon.{fish,sh}don't, exposing users withset -uto a potential crash in the most common use case:nix-profile.{fish,sh}requires thatUSERis defined, despite never using it. Likely leftover from a refactor around how GC roots were configured.nix-profile{-daemon}.shwere updated to account for the XDG directory migration, but the Fish equivalent weren't:vs. the naive Fish:
By way of note, the XDG migration included a useful, user-forward migration path for users who had both a legacy and an XDG-based path. It was made defunct by a logical inversion by mistake,
nix-profile.sh,nix-profile.fish,nix-profile-daemon.shall include the user's Nix profile in theXDG_DATA_DIRS, butnix-profile-daemon.fishdoes not:vs.
The profile scripts typically make an attempt at leaving the
NIX_SSL_CERT_FILEenvironment variable alone if the user set it, but...nix-profile.shdoesn't bothernix-profile.{fish,sh}look to see ifNIX_SSH_CERT_FILE(note theH!) is set instead ofNIX_SSL_CERT_FILE(note theL).All but
nix-profile-daemon.shwill check to see if$NIX_LINK/etc/ca-bundle.crtexists and use that.nix-profile-daemon.{sh,fish}both check for a file calledetc/ssl/certs/ca-bundle.crtin all the definedNIX_PROFILES, butnix-profile.{sh,fish}don't.nix-profile.{sh,fish}will extendMANPATHif it is already set, but the-daemonscripts won't.The
nix-profile-daemon.{fish,sh}scripts put/nix/var/nix/profiles/default/bininto thePATH, but the others don't. This is true, despite all four setting up the default profile.I don't know which of these are intentional or bugs, but since I found them during the Rust port I thought it would be useful food for thought!