Commit graph

28 commits

Author SHA1 Message Date
Robert Hensing
de5050f73b
Merge pull request #9590 from wh0/patch-1
nix-profile: fix both profile links detection
2024-06-03 14:37:08 +02:00
Andrew Davis
a2a633d332
Prevent nix-daemon.sh from leaking variable into user environment
The script at `/nix/store/...-nix-2.21.0/etc/profile.d/nix-daemon.sh`  was leaving behind a variable, which was visible in the user's shell environment, but not used outside the script.
2024-04-06 10:26:29 -04:00
w
29eb4d354a nix-profile: add cross reference to installer test 2023-12-29 07:14:53 +00:00
wh0
5d0bdb1d3f nix-profile: fix both profile links detection 2023-12-29 05:43:22 +00:00
Felix Uhl
64827360be Fix "unbound variable" errors in bash
Fixes #9414
2023-11-21 14:49:48 +01: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
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
Eelco Dolstra
ffadc35df1
Merge pull request #7925 from cole-h/fixup-xdg-nix-env
Check if NIX_LINK_NEW exists instead of checking that NIX_LINK doesn't exist
2023-03-01 23:01:42 +01:00
Cole Helbling
2b801d6e3c Check if NIX_LINK_NEW exists instead of checking that NIX_LINK doesn't exist
For brand new installations, neither NIX_LINK_NEW
(`$XDG_STATE_HOME/nix/profile` or `~/.local/state/nix/profile`), nor
NIX_LINK (`~/.nix-profile`) will exist.

This restores functionality to nix-env, which is relied upon by GitHub
Actions such as https://github.com/cachix/cachix-action and the Nixpkgs
EditorConfig (and other) CI.
2023-02-28 16:10:42 -08:00
Cole Helbling
24eaa086f0 nix-profile{,-daemon}.sh.in: Allow XDG_STATE_HOME to be unset
One of our CI machines installs Nix via the official script and then
sources the nix-profile.sh script to setup the environment. However, it
doesn't have XDG_STATE_HOME set, which causes sourcing the script to
fail.
2023-02-28 10:10:20 -08:00
Alexander Bantyev
2384d36083
A setting to follow XDG Base Directory standard
XDG Base Directory is a standard for locations for storing various
files. Nix has a few files which seem to fit in the standard, but
currently use a custom location directly in the user's ~, polluting
it:

- ~/.nix-profile
- ~/.nix-defexpr
- ~/.nix-channels

This commit adds a config option (use-xdg-base-directories) to follow
the XDG spec and instead use the following locations:

- $XDG_STATE_HOME/nix/profile
- $XDG_STATE_HOME/nix/defexpr
- $XDG_STATE_HOME/nix/channels

If $XDG_STATE_HOME is not set, it is assumed to be ~/.local/state.

Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
Co-authored-by: Tim Fenney <kodekata@gmail.com>
Co-authored-by: pasqui23 <pasqui23@users.noreply.github.com>
Co-authored-by: Artturin <Artturin@artturin.com>
Co-authored-by: John Ericson <Ericson2314@Yahoo.com>
2023-02-10 20:14:06 +04:00
Sandro Jäckel
eff48e84d9
Apply some shellcheck suggestions 2021-11-19 15:18:10 +01:00
Yuriy Taraday
39fbd3d828 Fix iterating over $NIX_PROFILES in Zsh
NIX_PROFILES is space separated list of directories, and passing it into
for as is is considered to be 1-element list with the whole string. With
shwordsplit option Zsh emulates other shells in this regard ans
implicitely splits unquoted strings into words.

Fixes #4167.
2020-10-21 00:03:38 +04:00
Eelco Dolstra
ec9dd9a5ae
Provide a default value for NIX_PATH 2019-11-22 22:08:51 +01:00
Eelco Dolstra
1c3ccba0f5
Remove $NIX_USER_PROFILE_DIR
This is not used anywhere.
2019-11-22 16:27:48 +01:00
Eelco Dolstra
c9159f86cc
nix-env: Create ~/.nix-defexpr automatically 2019-10-09 23:35:02 +02:00
Eelco Dolstra
9348f9291e
nix-env: Create ~/.nix-profile automatically 2019-10-09 23:35:01 +02:00
Eelco Dolstra
26762ceb86
nix-profile.sh: Don't create .nix-channels
This is already done by the installer, so no need to do it again.
2019-10-09 23:35:01 +02:00
Eelco Dolstra
5a303093dc
Remove world-writability from per-user directories
'nix-daemon' now creates subdirectories for users when they first
connect.

Fixes #509 (CVE-2019-17365).
Should also fix #3127.
2019-10-09 23:34:48 +02:00
Matthew Bauer
92f461e4f4 Don’t set NIX_REMOTE=daemon in daemon profile
This is now autodetected. There is no need to put it in the profile.
2019-05-15 22:24:24 -04:00
Eelco Dolstra
32a0a223d5
Merge pull request #2432 from luke-clifton/fixssl
SSL certificate search failed to find user profile certificates.
2018-11-15 13:07:43 +01:00
Matthew Bauer
9cc876fb11
nix-profile-daemon: remove cruft
This removes part of the PATH that were being added automatically in multi-user installs:

- $HOME/.nix-profile/lib/kde4/libexec - shouldn't be needed anymore, we are now using kde5
- @localstatedir@/nix/profiles/default/lib/kde4/libexec - same as above
- @localstatedir@/nix/profiles/default - shouldn't ever contain binaries
2018-10-01 13:26:59 -05:00
Luke Clifton
fb72104b80 Search NIX_PROFILE for SSL CA 2018-09-20 07:33:35 +08:00
Luke Clifton
1241a58975 Look inside the user profile 2018-09-19 15:22:39 +08:00
Graham Christensen
d459d3307c
nix-daemon.sh profile script: operate under set -u
If the profile is sourced inside a script with `set -u`, the check for
__ETC_PROFILE_NIX_SOURCED and NIX_SSL_CERT_FILE would raise an error.
A simple guard around this check allows the script to operate under
standard environments (where it is fairly reasonable to assume USER
and HOME are set.)
2018-05-30 09:15:46 -04:00
Graham Christensen
cad903b634
multi-user profile: borrow single user profiles' NIX_SSL_CERT_FILE finding logic 2018-05-25 15:59:10 -04:00
Matthew Justin Bauer
d7a84d330c Setup nix_path correctly in nix-profile-daemon
We need nixpkgs to be set in NIX_PATH for Nix 1.12 to work correctly
2018-04-04 18:02:59 -05:00
Shea Levy
6a037a738a
Pull nix-profile-daemon from 1.11 2017-10-16 14:51:39 -04:00