mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
8433027e35
At this point many features are stripped out, but this works: - Can run libnix{util,store,expr} unit tests - Can run some Nix commands Co-Authored-By volth <volth@volth.com> Co-Authored-By Brian McKenna <brian@brianmckenna.org>
56 lines
1 KiB
C++
56 lines
1 KiB
C++
#pragma once
|
|
/**
|
|
* @file
|
|
*
|
|
* Utilities for working with the current process's environment
|
|
* variables.
|
|
*/
|
|
|
|
#include <optional>
|
|
|
|
#include "types.hh"
|
|
|
|
namespace nix {
|
|
|
|
/**
|
|
* @return an environment variable.
|
|
*/
|
|
std::optional<std::string> getEnv(const std::string & key);
|
|
|
|
/**
|
|
* @return a non empty environment variable. Returns nullopt if the env
|
|
* variable is set to ""
|
|
*/
|
|
std::optional<std::string> getEnvNonEmpty(const std::string & key);
|
|
|
|
/**
|
|
* Get the entire environment.
|
|
*/
|
|
std::map<std::string, std::string> getEnv();
|
|
|
|
#ifdef _WIN32
|
|
/**
|
|
* Implementation of missing POSIX function.
|
|
*/
|
|
int unsetenv(const char * name);
|
|
#endif
|
|
|
|
/**
|
|
* Like POSIX `setenv`, but always overrides.
|
|
*
|
|
* We don't need the non-overriding version, and this is easier to
|
|
* reimplement on Windows.
|
|
*/
|
|
int setEnv(const char * name, const char * value);
|
|
|
|
/**
|
|
* Clear the environment.
|
|
*/
|
|
void clearEnv();
|
|
|
|
/**
|
|
* Replace the entire environment with the given one.
|
|
*/
|
|
void replaceEnv(const std::map<std::string, std::string> & newEnv);
|
|
|
|
}
|