aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/users.hh
blob: 3add4c732e5d9068349c58fe66f7fc2bc52f22dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
///@file

#include "types.hh"

#include <sys/types.h>

namespace nix {

std::string getUserName();

/**
 * @return the given user's home directory from /etc/passwd.
 */
Path getHomeOf(uid_t userId);

/**
 * @return $HOME or the user's home directory from /etc/passwd.
 */
Path getHome();

/**
 * @return $XDG_CACHE_HOME or $HOME/.cache.
 */
Path getCacheDir();

/**
 * @return $XDG_CONFIG_HOME or $HOME/.config.
 */
Path getConfigDir();

/**
 * @return the directories to search for user configuration files
 */
std::vector<Path> getConfigDirs();

/**
 * @return $XDG_DATA_HOME or $HOME/.local/share.
 */
Path getDataDir();

/**
 * @return $XDG_STATE_HOME or $HOME/.local/state.
 *
 * @note Not to be confused with settings.nixStateDir.
 */
Path getStateDir();

/**
 * Create $XDG_STATE_HOME/nix or $HOME/.local/state/nix, and return
 * the path to it.
 * @note Not to be confused with settings.nixStateDir.
 */
Path createNixStateDir();

/**
 * Perform tilde expansion on a path.
 */
std::string expandTilde(std::string_view path);

}