Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
users.hh File Reference
#include <filesystem>
#include <sys/types.h>
#include "nix/util/types.hh"

Go to the source code of this file.

Functions

std::string nix::getUserName ()
std::filesystem::path nix::getHomeOf (uid_t userId)
std::filesystem::path nix::getHome ()
std::filesystem::path nix::getCacheDir ()
std::filesystem::path nix::getConfigDir ()
std::vector< std::filesystem::path > nix::getConfigDirs ()
std::filesystem::path nix::getDataDir ()
std::filesystem::path nix::getStateDir ()
std::filesystem::path nix::createNixStateDir ()
std::string nix::expandTilde (std::string_view path)
bool nix::isRootUser ()

Function Documentation

◆ createNixStateDir()

std::filesystem::path nix::createNixStateDir ( )

Create the Nix state directory and return the path to it.

◆ expandTilde()

std::string nix::expandTilde ( std::string_view path)

Perform tilde expansion on a path, replacing tilde with the user's home directory.

◆ getCacheDir()

std::filesystem::path nix::getCacheDir ( )
Returns
$NIX_CACHE_HOME or $XDG_CACHE_HOME/nix or $HOME/.cache/nix.

◆ getConfigDir()

std::filesystem::path nix::getConfigDir ( )
Returns
$NIX_CONFIG_HOME or $XDG_CONFIG_HOME/nix or $HOME/.config/nix.

◆ getConfigDirs()

std::vector< std::filesystem::path > nix::getConfigDirs ( )
Returns
the directories to search for user configuration files

◆ getDataDir()

std::filesystem::path nix::getDataDir ( )
Returns
$NIX_DATA_HOME or $XDG_DATA_HOME/nix or $HOME/.local/share/nix.

◆ getHome()

std::filesystem::path nix::getHome ( )
Returns
$HOME or the user's home directory from /etc/passwd.

◆ getHomeOf()

std::filesystem::path nix::getHomeOf ( uid_t userId)
Returns
the given user's home directory from /etc/passwd.

◆ getStateDir()

std::filesystem::path nix::getStateDir ( )
Returns
$NIX_STATE_HOME or $XDG_STATE_HOME/nix or $HOME/.local/state/nix.

◆ isRootUser()

bool nix::isRootUser ( )

Is the current user UID 0 on Unix?

Currently always false on Windows, but that may change.