mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
Merge pull request #5588 from tweag/balsoft/xdg
Follow XDG Base Directory standard
This commit is contained in:
commit
9ebbe35817
16 changed files with 153 additions and 20 deletions
|
|
@ -608,6 +608,19 @@ Path getDataDir()
|
|||
return dataDir ? *dataDir : getHome() + "/.local/share";
|
||||
}
|
||||
|
||||
Path getStateDir()
|
||||
{
|
||||
auto stateDir = getEnv("XDG_STATE_HOME");
|
||||
return stateDir ? *stateDir : getHome() + "/.local/state";
|
||||
}
|
||||
|
||||
Path createNixStateDir()
|
||||
{
|
||||
Path dir = getStateDir() + "/nix";
|
||||
createDirs(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
std::optional<Path> getSelfExe()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,6 +158,12 @@ Path getDataDir();
|
|||
/* Return the path of the current executable. */
|
||||
std::optional<Path> getSelfExe();
|
||||
|
||||
/* Return $XDG_STATE_HOME or $HOME/.local/state. */
|
||||
Path getStateDir();
|
||||
|
||||
/* Create the Nix state directory and return the path to it. */
|
||||
Path createNixStateDir();
|
||||
|
||||
/* Create a directory and all its parents, if necessary. Returns the
|
||||
list of created directories, in order of creation. */
|
||||
Paths createDirs(const Path & path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue