aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/globals.hh
diff options
context:
space:
mode:
authorAlexander Bantyev <balsoft@balsoft.ru>2021-11-17 23:35:21 +0300
committerAlexander Bantyev <balsoft@balsoft.ru>2023-02-10 20:14:06 +0400
commit2384d360839e27edb3c928da858ec911415c8b4d (patch)
tree95e5360fc7016b9d171f4bad320486eda168bbb1 /src/libstore/globals.hh
parenta31d7d4e5e5eeeb7ca12ca798dc383045e5be1a1 (diff)
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>
Diffstat (limited to 'src/libstore/globals.hh')
-rw-r--r--src/libstore/globals.hh21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index c3ccb5e11..40f10fde3 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -975,6 +975,27 @@ public:
resolves to a different location from that of the build machine. You
can enable this setting if you are sure you're not going to do that.
)"};
+
+ Setting<bool> useXDGBaseDirectories{
+ this, false, "use-xdg-base-directories",
+ R"(
+ If set to `true`, Nix will conform to the [XDG Base Directory Specification] for files in `$HOME`.
+ The environment variables used to implement this are documented in the [Environment Variables section](@docroot@/installation/env-variables.md).
+
+ [XDG Base Directory Specification]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
+
+ > **Warning**
+ > This changes the location of some well-known symlinks that Nix creates, which might break tools that rely on the old, non-XDG-conformant locations.
+
+ In particular, the following locations change:
+
+ | Old | New |
+ |-------------------|--------------------------------|
+ | `~/.nix-profile` | `$XDG_STATE_HOME/nix/profile` |
+ | `~/.nix-defexpr` | `$XDG_STATE_HOME/nix/defexpr` |
+ | `~/.nix-channels` | `$XDG_STATE_HOME/nix/channels` |
+ )"
+ };
};