1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00
Commit graph

17 commits

Author SHA1 Message Date
Jörg Thalheim
247f166f87
Merge pull request #13245 from stefanboca/sb/push-yoorqzwsxmzn
nix-profile{,-daemon}.fish: check for profile in XDG_DATA_HOME
2025-05-26 00:14:40 +02:00
Stefan Boca
751f50f4ad nix-profile{,-daemon}.fish: check for profile in XDG_DATA_HOME
...and also NIX_STATE_HOME in nix-profile.fish. This is directly
translated from the bash scripts and makes the fish scripts equivalent
in functionality to the bash scripts.

Note that nix-profile.fish checks for NIX_STATE_HOME and
nix-profile-daemon.fish does not, so the two scripts are no longer
identical.
2025-05-25 17:15:32 +02:00
Stefan Boca
b9ed3ae36e
nix-profile{,-daemon}.fish: fix do not source twice
Commit b36637c8f7 set
`__ETC_PROFILE_NIX_SOURCED` globally, but this is not enough to prevent
the script from being run again by child shells, because the
variable was not exported and thus not inherited by any child process.
Exporting the variable also agrees with the bash scripts.

Notably, the old behavior broke `nix develop -c fish` in some cases,
because the profile bin directory got prepended to the path, causing
binaries from the profile to override binareis from the devshell.
2025-05-21 11:29:47 -07:00
Stefan Boca
f627b8c721
nix-profile{,-daemon}.fish: format with fish_indent 2025-05-20 22:11:39 -07:00
Illia Bobyr
470c521bcc
nix-profile-daemon.fish: Set MANPATH
There seems to be no good reason for `nix-profile.fish` to set
`$MANPATH` while it being unset when `nix-profile-daemon.fish` is used.
2025-04-16 17:14:47 -07:00
Illia Bobyr
50300772e4
nix-profile.fish: set --local NIX_LINK
Using `set --local` is better than using `set`/`set --erase`.  `--local`
will preserve any existing `NIX_LINK` value.  And the local variable is
automatically removed for any execution path.
2025-02-04 16:01:29 -08:00
Illia Bobyr
85aa624126
nix-profile-daemon.fish: XDG_DATA_DIRS: .profile/share
It seems reasonable to add the `share` folder from the user profile into
`$XDG_DATA_DIRS` both for daemon and profile execution.  Nix could add
package shared files into this folder regardless of how the nix daemon
itself is running.
2025-02-03 16:24:14 -08:00
Illia Bobyr
b36637c8f7
nix-profile{,-daemon}.fish: Do not source twice
In order for the script not be sourced multiple times by the same shell
instance, `__ETC_PROFILE_NIX_SOURCED` needs to be set with a `--global`
flag.

Both files are almost identical.  And style differences make it harder
to see what is actually different and keep them in sync, when it is
required.
2025-01-18 12:39:10 -08:00
Illia Bobyr
666d656593
nix-profile-daemon.fish: fmt
`nix-profile.fish` and part of `nix-profile-daemon.fish` use 4 space
indentation.  Which is also the indentation that the fish shell
documentation is using.

Reformatting a chunk of `nix-profile-daemon.fish` from 2 space
indentation to 4 space indentation for consistency.
2025-01-18 12:39:10 -08:00
Jesse Schalken
c448636f7c
Fix loop over $NIX_PROFILES in nix-profile-daemon.fish.in 2024-03-20 15:23:31 +11:00
Felix Uhl
1362a0a55a Fix logic for default XDG_DATA_DIRS value
The [POSIX test manpage](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html)
as well as the [fish test manpage](https://fishshell.com/docs/current/cmds/test.html#operators-for-text-strings)
specify that `-z` will be "True if the length of string string is zero;
otherwise, false."

The `-n` was likely a mixup and not caught during testing of
https://github.com/NixOS/nix/pull/8985 due to a lack of missing
conflicting entries in `XDG_DATA_DIRS`.
2023-11-07 03:41:19 +01:00
Ana Hobden
150b5aba50 Update scripts/nix-profile-daemon.fish.in
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-11-06 20:43:27 +01:00
Ana Hobden
896013ec0c Fix bad copy-paste 2023-11-06 20:43:27 +01:00
Ana Hobden
867f894289 Populate $XDG_DATA_DIRS with appropriate folder from Nix profile
On non-NixOS systems, the default `nix` install does not populate the
`$XDG_DATA_DIRS`. This populates it and enables things like bash-completion
and `.desktop` file detection for `nix` profile installed packages.

Signed-off-by: Ana Hobden <operator@hoverbear.org>
2023-11-06 20:43:27 +01:00
Alexandre Thomas
49e058f1cf Fix Nix installation on older versions of fish
The `fish_add_path` function is only available for fish 3.2.0 or newer,
and not on older versions.
This commit adds an alternative way to update the PATH when
`fish_add_path` does not exist.
2023-01-03 21:14:01 +01:00
Jonathan Coates
0259702219
Use exit instead of return in fish profile
Older versions of Fish (such as those bundled with Ubuntu LTS 22.04) do
not support return outside of functions. We need to use the equivalent
exit instead.
2022-09-27 12:59:37 +01:00
Ana Hobden
8ebdbeb257 Add fish suport to installer
Before this patch, installing Nix using the Fish shell did not
work because Fish wasn't configured to add Nix to the PATH. Some
options in #1512 offered workarounds, but they typically involve
extra plugins or packages.

This patch adds native, out-of-the-box support for the Fish shell.

Note that Fish supports a `conf.d` directory, which is intended
for exactly use cases like this: software projects distributing
shell snippets. This patch takes advantage of it. The installer
doesn't append any Nix loader behavior to any Fish config file.
Because of that, the uninstall process is smooth and a reinstall
obliterates the existing nix.fish files that we place instead of
bothering the user with a backup / manual removal.

Both single-user and multi-user cases are covered. It has been
tested on Ubuntu, and a Mac with MacPorts, homebrew, and the
Fish installer pkg.

Closes #1512

Co-authored-by: Graham Christensen <graham@grahamc.com>
2022-09-13 12:56:16 -04:00