aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/users.hh
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-05-30 02:33:05 +0000
committerGerrit Code Review <gerrit@lix-systems>2024-05-30 02:33:05 +0000
commit562ff516ab27b8e98490646dd30ac96e7e2c36bb (patch)
tree1798a20b33da0101bd91acf7da26c891f0cda620 /src/libutil/users.hh
parentc71f21da3ac4d95ef9a42a26416ccee71639dbd6 (diff)
parenta39ba22ff7112cd3984bbf28d8610d84dd525a0f (diff)
Merge changes from topic "libutil-split" into main
* changes: util.hh: Delete remaining file and clean up headers util.hh: Move nativeSystem to local-derivation-goal.cc util.hh: Move stuff to types.hh util.cc: Delete remaining file util.{hh,cc}: Move ignoreException to error.{hh,cc} util.{hh,cc}: Split out namespaces.{hh,cc} util.{hh,cc}: Split out users.{hh,cc} util.{hh,cc}: Split out strings.{hh,cc} util.{hh,cc}: Split out unix-domain-socket.{hh,cc} util.{hh,cc}: Split out child.{hh,cc} util.{hh,cc}: Split out current-process.{hh,cc} util.{hh,cc}: Split out processes.{hh,cc} util.{hh,cc}: Split out file-descriptor.{hh,cc} util.{hh,cc}: Split out file-system.{hh,cc} util.{hh,cc}: Split out terminal.{hh,cc} util.{hh,cc}: Split out environment-variables.{hh,cc}
Diffstat (limited to 'src/libutil/users.hh')
-rw-r--r--src/libutil/users.hh61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/libutil/users.hh b/src/libutil/users.hh
new file mode 100644
index 000000000..3add4c732
--- /dev/null
+++ b/src/libutil/users.hh
@@ -0,0 +1,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);
+
+}