nix-profile{,-daemon}.fish: Do not source twice, fmt #12252
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
nix-profile-daemon.fish
andnix-profile.fish
scripts perform almost identical actions.Yet, they are written with slight differences that make it harder to see what is actually the same and what is different.
This is already discussed in #9441
I think
nix-profile-daemon.fish
andnix-profile.fish
might eventually turn out to be identical or use a common implementation.This change is a step is a step in this direction.
You can see the differences between
nix-profile-daemon.fish
andnix-profile.fish
here:https://gist.github.com/ilya-bobyr/c957a9f998b85833064b2d64b4ae4062
Context
A few bug fixes and indentation changes on both sides:
nix-profile-daemon.fish
:When checking for repeated execution, exit before the helper function
add_path
is defined. Making sure it does not leak to the caller.Check that
$HOME
is set, as it is actually used in the configuration.Use 4 space indentation in the configuration subsection, as this is the indentation used for the rest of the file and in
nix-profile.fish
.Mark
__ETC_PROFILE_NIX_SOURCED
as--global
as, by default,set
creates a--local
variable that might not be visible to a subsequent execution of this script in the same shell. Effectively breaking the protection.nix-profile.fish
:Use early exit when checking for required environment variables and double execution.
Identical to the
nix-profile-daemon.fish
.Use
__ETC_PROFILE_NIX_SOURCED
for double execution protection, similarly tonix-profile-daemon.fish
.Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.