id int64 0 755k | file_name stringlengths 3 109 | file_path stringlengths 13 185 | content stringlengths 31 9.38M | size int64 31 9.38M | language stringclasses 1
value | extension stringclasses 11
values | total_lines int64 1 340k | avg_line_length float64 2.18 149k | max_line_length int64 7 2.22M | alphanum_fraction float64 0 1 | repo_name stringlengths 6 65 | repo_stars int64 100 47.3k | repo_forks int64 0 12k | repo_open_issues int64 0 3.4k | repo_license stringclasses 9
values | repo_extraction_date stringclasses 92
values | exact_duplicates_redpajama bool 2
classes | near_duplicates_redpajama bool 2
classes | exact_duplicates_githubcode bool 2
classes | exact_duplicates_stackv2 bool 1
class | exact_duplicates_stackv1 bool 2
classes | near_duplicates_githubcode bool 2
classes | near_duplicates_stackv1 bool 2
classes | near_duplicates_stackv2 bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10,842 | log-store.cc | NixOS_nix/src/libstore/log-store.cc | #include "log-store.hh"
namespace nix {
std::optional<std::string> LogStore::getBuildLog(const StorePath & path) {
auto maybePath = getBuildDerivationPath(path);
if (!maybePath)
return std::nullopt;
return getBuildLogExact(maybePath.value());
}
}
| 270 | C++ | .cc | 9 | 26.444444 | 74 | 0.728682 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,843 | personality.cc | NixOS_nix/src/libstore/linux/personality.cc | #include "personality.hh"
#include "globals.hh"
#include <sys/utsname.h>
#include <sys/personality.h>
#include <cstring>
namespace nix::linux {
void setPersonality(std::string_view system)
{
/* Change the personality to 32-bit if we're doing an
i686-linux build on an x86_64-linux machine. */
... | 1,377 | C++ | .cc | 34 | 31.852941 | 98 | 0.582335 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,844 | fetchurl.cc | NixOS_nix/src/libstore/builtins/fetchurl.cc | #include "builtins.hh"
#include "filetransfer.hh"
#include "store-api.hh"
#include "archive.hh"
#include "compression.hh"
namespace nix {
void builtinFetchurl(
const BasicDerivation & drv,
const std::map<std::string, Path> & outputs,
const std::string & netrcData,
const std::string & caFileData)
{
... | 2,740 | C++ | .cc | 66 | 33.590909 | 129 | 0.605342 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,845 | unpack-channel.cc | NixOS_nix/src/libstore/builtins/unpack-channel.cc | #include "builtins.hh"
#include "tarfile.hh"
namespace nix {
namespace fs { using namespace std::filesystem; }
void builtinUnpackChannel(
const BasicDerivation & drv,
const std::map<std::string, Path> & outputs)
{
auto getAttr = [&](const std::string & name) -> const std::string & {
auto i = drv.... | 1,601 | C++ | .cc | 44 | 30.681818 | 105 | 0.624838 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,846 | buildenv.cc | NixOS_nix/src/libstore/builtins/buildenv.cc | #include "buildenv.hh"
#include "derivations.hh"
#include "signals.hh"
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <algorithm>
namespace nix {
struct State
{
std::map<Path, int> priorities;
unsigned long symlinks = 0;
};
/* For each activated package, create symlinks */
static v... | 7,313 | C++ | .cc | 180 | 29.744444 | 111 | 0.545237 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,847 | pathlocks.cc | NixOS_nix/src/libstore/unix/pathlocks.cc | #include "pathlocks.hh"
#include "util.hh"
#include "sync.hh"
#include "signals.hh"
#include <cerrno>
#include <cstdlib>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
namespace nix {
AutoCloseFD openLockFile(const Path & path, bool create)
{
AutoCloseFD fd;
fd = ope... | 4,467 | C++ | .cc | 128 | 26.21875 | 87 | 0.561338 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,848 | user-lock.cc | NixOS_nix/src/libstore/unix/user-lock.cc | #include <vector>
#include <pwd.h>
#include <grp.h>
#include "user-lock.hh"
#include "file-system.hh"
#include "globals.hh"
#include "pathlocks.hh"
#include "users.hh"
namespace nix {
#if __linux__
static std::vector<gid_t> get_group_list(const char *username, gid_t group_id)
{
std::vector<gid_t> gids;
gids... | 6,631 | C++ | .cc | 160 | 31.925 | 128 | 0.579857 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,849 | local-derivation-goal.cc | NixOS_nix/src/libstore/unix/build/local-derivation-goal.cc | #include "local-derivation-goal.hh"
#include "indirect-root-store.hh"
#include "hook-instance.hh"
#include "worker.hh"
#include "builtins.hh"
#include "builtins/buildenv.hh"
#include "path-references.hh"
#include "finally.hh"
#include "util.hh"
#include "archive.hh"
#include "git.hh"
#include "compression.hh"
#include ... | 120,485 | C++ | .cc | 2,572 | 35.595645 | 157 | 0.588964 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,850 | child.cc | NixOS_nix/src/libstore/unix/build/child.cc | #include "child.hh"
#include "current-process.hh"
#include "logging.hh"
#include <fcntl.h>
#include <unistd.h>
namespace nix {
void commonChildInit()
{
logger = makeSimpleLogger();
const static std::string pathNullDevice = "/dev/null";
restoreProcessContext(false);
/* Put the child in a separate se... | 1,041 | C++ | .cc | 29 | 31.137931 | 69 | 0.670319 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,851 | hook-instance.cc | NixOS_nix/src/libstore/unix/build/hook-instance.cc | #include "globals.hh"
#include "config-global.hh"
#include "hook-instance.hh"
#include "file-system.hh"
#include "child.hh"
#include "strings.hh"
#include "executable-path.hh"
namespace nix {
HookInstance::HookInstance()
{
debug("starting build hook '%s'", concatStringsSep(" ", settings.buildHook.get()));
au... | 2,681 | C++ | .cc | 72 | 31.055556 | 87 | 0.634533 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,852 | pathlocks.cc | NixOS_nix/src/libstore/windows/pathlocks.cc | #include "logging.hh"
#include "pathlocks.hh"
#include "signals.hh"
#include "util.hh"
#include <errhandlingapi.h>
#include <fileapi.h>
#include <windows.h>
#include "windows-error.hh"
namespace nix {
using namespace nix::windows;
void deleteLockFile(const Path & path, Descriptor desc)
{
int exit = DeleteFileA(... | 4,320 | C++ | .cc | 134 | 23.731343 | 112 | 0.549472 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,853 | substitution-goal.cc | NixOS_nix/src/libstore/build/substitution-goal.cc | #include "worker.hh"
#include "substitution-goal.hh"
#include "nar-info.hh"
#include "finally.hh"
#include "signals.hh"
#include <coroutine>
namespace nix {
PathSubstitutionGoal::PathSubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
: Goal(worker, ... | 9,388 | C++ | .cc | 234 | 32.08547 | 148 | 0.637354 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,854 | derivation-goal.cc | NixOS_nix/src/libstore/build/derivation-goal.cc | #include "derivation-goal.hh"
#ifndef _WIN32 // TODO enable build hook on Windows
# include "hook-instance.hh"
#endif
#include "processes.hh"
#include "config-global.hh"
#include "worker.hh"
#include "builtins.hh"
#include "builtins/buildenv.hh"
#include "references.hh"
#include "finally.hh"
#include "util.hh"
#includ... | 55,859 | C++ | .cc | 1,328 | 32.496235 | 173 | 0.608197 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,855 | entry-points.cc | NixOS_nix/src/libstore/build/entry-points.cc | #include "worker.hh"
#include "substitution-goal.hh"
#ifndef _WIN32 // TODO Enable building on Windows
# include "derivation-goal.hh"
#endif
#include "local-store.hh"
#include "strings.hh"
namespace nix {
void Store::buildPaths(const std::vector<DerivedPath> & reqs, BuildMode buildMode, std::shared_ptr<Store> evalSt... | 4,561 | C++ | .cc | 127 | 28.929134 | 124 | 0.623044 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,856 | drv-output-substitution-goal.cc | NixOS_nix/src/libstore/build/drv-output-substitution-goal.cc | #include "drv-output-substitution-goal.hh"
#include "finally.hh"
#include "worker.hh"
#include "substitution-goal.hh"
#include "callback.hh"
namespace nix {
DrvOutputSubstitutionGoal::DrvOutputSubstitutionGoal(
const DrvOutput & id,
Worker & worker,
RepairFlag repair,
std::optional<ContentAddress> ca)... | 4,942 | C++ | .cc | 127 | 29.826772 | 129 | 0.604058 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,857 | worker.cc | NixOS_nix/src/libstore/build/worker.cc | #include "local-store.hh"
#include "machines.hh"
#include "worker.hh"
#include "substitution-goal.hh"
#include "drv-output-substitution-goal.hh"
#include "derivation-goal.hh"
#ifndef _WIN32 // TODO Enable building on Windows
# include "local-derivation-goal.hh"
# include "hook-instance.hh"
#endif
#include "signals.hh... | 17,361 | C++ | .cc | 468 | 29.641026 | 154 | 0.622218 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,858 | goal.cc | NixOS_nix/src/libstore/build/goal.cc | #include "goal.hh"
#include "worker.hh"
namespace nix {
using Co = nix::Goal::Co;
using promise_type = nix::Goal::promise_type;
using handle_type = nix::Goal::handle_type;
using Suspend = nix::Goal::Suspend;
Co::Co(Co&& rhs) {
this->handle = rhs.handle;
rhs.handle = nullptr;
}
void Co::operator=(Co&& rhs) {
... | 6,536 | C++ | .cc | 175 | 31.697143 | 117 | 0.633687 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,859 | nix_api_store.cc | NixOS_nix/src/libstore-c/nix_api_store.cc | #include "nix_api_store.h"
#include "nix_api_store_internal.h"
#include "nix_api_util.h"
#include "nix_api_util_internal.h"
#include "path.hh"
#include "store-api.hh"
#include "build-result.hh"
#include "globals.hh"
nix_err nix_libstore_init(nix_c_context * context)
{
if (context)
context->last_err_code ... | 4,165 | C++ | .cc | 137 | 24.927007 | 117 | 0.626404 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,860 | build-remote.cc | NixOS_nix/src/build-remote/build-remote.cc | #include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>
#include <memory>
#include <tuple>
#include <iomanip>
#if __APPLE__
#include <sys/time.h>
#endif
#include "machines.hh"
#include "shared.hh"
#include "plugin.hh"
#include "pathlocks.hh"
#include "globals.hh"
#include "serialise.hh"
#include "bui... | 15,280 | C++ | .cc | 332 | 31.162651 | 124 | 0.519621 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,861 | context.cc | NixOS_nix/src/libexpr-test-support/tests/value/context.cc | #include <rapidcheck.h>
#include "tests/path.hh"
#include "tests/value/context.hh"
namespace rc {
using namespace nix;
Gen<NixStringContextElem::DrvDeep> Arbitrary<NixStringContextElem::DrvDeep>::arbitrary()
{
return gen::just(NixStringContextElem::DrvDeep {
.drvPath = *gen::arbitrary<StorePath>(),
}... | 862 | C++ | .cc | 25 | 30.4 | 97 | 0.722356 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,862 | posix-source-accessor.cc | NixOS_nix/src/libutil/posix-source-accessor.cc | #include "posix-source-accessor.hh"
#include "source-path.hh"
#include "signals.hh"
#include "sync.hh"
#include <unordered_map>
namespace nix {
PosixSourceAccessor::PosixSourceAccessor(std::filesystem::path && argRoot)
: root(std::move(argRoot))
{
assert(root.empty() || root.is_absolute());
displayPrefix... | 6,386 | C++ | .cc | 174 | 29.83908 | 117 | 0.622251 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,863 | experimental-features.cc | NixOS_nix/src/libutil/experimental-features.cc | #include "experimental-features.hh"
#include "fmt.hh"
#include "util.hh"
#include "nlohmann/json.hpp"
namespace nix {
struct ExperimentalFeatureDetails
{
ExperimentalFeature tag;
std::string_view name;
std::string_view description;
std::string_view trackingUrl;
};
/**
* If two different PRs both ad... | 14,049 | C++ | .cc | 343 | 32.183673 | 155 | 0.61606 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,864 | url.cc | NixOS_nix/src/libutil/url.cc | #include "url.hh"
#include "url-parts.hh"
#include "util.hh"
#include "split.hh"
#include "canon-path.hh"
namespace nix {
std::regex refRegex(refRegexS, std::regex::ECMAScript);
std::regex badGitRefRegex(badGitRefRegexS, std::regex::ECMAScript);
std::regex revRegex(revRegexS, std::regex::ECMAScript);
ParsedURL parse... | 5,623 | C++ | .cc | 172 | 25.97093 | 92 | 0.551889 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,865 | config-global.cc | NixOS_nix/src/libutil/config-global.cc | #include "config-global.hh"
#include <nlohmann/json.hpp>
namespace nix {
bool GlobalConfig::set(const std::string & name, const std::string & value)
{
for (auto & config : *configRegistrations)
if (config->set(name, value))
return true;
unknownSettings.emplace(name, value);
return f... | 1,706 | C++ | .cc | 53 | 28.396226 | 93 | 0.729383 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,866 | thread-pool.cc | NixOS_nix/src/libutil/thread-pool.cc | #include "thread-pool.hh"
#include "signals.hh"
#include "util.hh"
namespace nix {
ThreadPool::ThreadPool(size_t _maxThreads)
: maxThreads(_maxThreads)
{
if (!maxThreads) {
maxThreads = std::thread::hardware_concurrency();
if (!maxThreads) maxThreads = 1;
}
debug("starting pool of %d ... | 4,459 | C++ | .cc | 130 | 23.169231 | 102 | 0.510708 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,867 | executable-path.cc | NixOS_nix/src/libutil/executable-path.cc | #include "environment-variables.hh"
#include "executable-path.hh"
#include "strings-inline.hh"
#include "util.hh"
#include "file-path-impl.hh"
namespace nix {
namespace fs {
using namespace std::filesystem;
}
constexpr static const OsStringView path_var_separator{
&ExecutablePath::separator,
1,
};
Executabl... | 3,276 | C++ | .cc | 84 | 31.928571 | 113 | 0.637193 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,868 | config.cc | NixOS_nix/src/libutil/config.cc | #include "config.hh"
#include "args.hh"
#include "abstract-setting-to-json.hh"
#include "environment-variables.hh"
#include "experimental-features.hh"
#include "util.hh"
#include "file-system.hh"
#include "config-impl.hh"
#include <nlohmann/json.hpp>
#include "strings.hh"
namespace nix {
Config::Config(StringMap i... | 15,160 | C++ | .cc | 415 | 30.978313 | 153 | 0.653125 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,869 | util.cc | NixOS_nix/src/libutil/util.cc | #include "util.hh"
#include "fmt.hh"
#include "file-path.hh"
#include "signals.hh"
#include <array>
#include <cctype>
#include <iostream>
#include <regex>
#include <sodium.h>
#include <boost/lexical_cast.hpp>
#include <stdint.h>
#ifdef NDEBUG
#error "Nix may not be built with assertions disabled (i.e. with -DNDEBUG)... | 9,021 | C++ | .cc | 271 | 27.96679 | 213 | 0.593901 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,870 | logging.cc | NixOS_nix/src/libutil/logging.cc | #include "logging.hh"
#include "file-descriptor.hh"
#include "environment-variables.hh"
#include "terminal.hh"
#include "util.hh"
#include "config-global.hh"
#include "source-path.hh"
#include "position.hh"
#include <atomic>
#include <sstream>
#include <nlohmann/json.hpp>
#include <iostream>
namespace nix {
LoggerSe... | 9,335 | C++ | .cc | 293 | 25.245734 | 115 | 0.60049 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,871 | references.cc | NixOS_nix/src/libutil/references.cc | #include "references.hh"
#include "hash.hh"
#include "archive.hh"
#include <map>
#include <cstdlib>
#include <mutex>
#include <algorithm>
namespace nix {
static size_t refLength = 32; /* characters */
static void search(
std::string_view s,
StringSet & hashes,
StringSet & seen)
{
static std::once... | 3,545 | C++ | .cc | 111 | 26.477477 | 95 | 0.620376 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,872 | source-path.cc | NixOS_nix/src/libutil/source-path.cc | #include "source-path.hh"
namespace nix {
std::string_view SourcePath::baseName() const
{ return path.baseName().value_or("source"); }
SourcePath SourcePath::parent() const
{
auto p = path.parent();
assert(p);
return {accessor, std::move(*p)};
}
std::string SourcePath::readFile() const
{ return accessor... | 1,728 | C++ | .cc | 48 | 33.875 | 81 | 0.732852 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,873 | current-process.cc | NixOS_nix/src/libutil/current-process.cc | #include <algorithm>
#include <cstring>
#include "current-process.hh"
#include "util.hh"
#include "finally.hh"
#include "file-system.hh"
#include "processes.hh"
#include "signals.hh"
#include <math.h>
#ifdef __APPLE__
# include <mach-o/dyld.h>
#endif
#if __linux__
# include <mutex>
# include "cgroup.hh"
# include "n... | 3,797 | C++ | .cc | 129 | 21.899225 | 107 | 0.547051 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,874 | source-accessor.cc | NixOS_nix/src/libutil/source-accessor.cc | #include "source-accessor.hh"
#include "archive.hh"
namespace nix {
static std::atomic<size_t> nextNumber{0};
SourceAccessor::SourceAccessor()
: number(++nextNumber)
, displayPrefix{"«unknown»"}
{
}
bool SourceAccessor::pathExists(const CanonPath & path)
{
return maybeLstat(path).has_value();
}
std::st... | 2,650 | C++ | .cc | 92 | 22.565217 | 99 | 0.601575 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,875 | git.cc | NixOS_nix/src/libutil/git.cc | #include <cerrno>
#include <algorithm>
#include <vector>
#include <map>
#include <regex>
#include <strings.h> // for strcasecmp
#include "signals.hh"
#include "config.hh"
#include "hash.hh"
#include "git.hh"
#include "serialise.hh"
namespace nix::git {
using namespace nix;
using namespace std::string_literals;
std... | 9,066 | C++ | .cc | 297 | 23.468013 | 99 | 0.593958 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,876 | xml-writer.cc | NixOS_nix/src/libutil/xml-writer.cc | #include <cassert>
#include "xml-writer.hh"
namespace nix {
XMLWriter::XMLWriter(bool indent, std::ostream & output)
: output(output), indent(indent)
{
output << "<?xml version='1.0' encoding='utf-8'?>" << std::endl;
closed = false;
}
XMLWriter::~XMLWriter()
{
close();
}
void XMLWriter::close()... | 2,009 | C++ | .cc | 75 | 21.786667 | 70 | 0.560899 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
10,877 | file-descriptor.cc | NixOS_nix/src/libutil/file-descriptor.cc | #include "file-system.hh"
#include "signals.hh"
#include "finally.hh"
#include "serialise.hh"
#include "util.hh"
#include <fcntl.h>
#include <unistd.h>
#ifdef _WIN32
# include <winnt.h>
# include <fileapi.h>
# include "windows-error.hh"
#endif
namespace nix {
void writeLine(Descriptor fd, std::string s)
{
s += '... | 2,834 | C++ | .cc | 118 | 19.949153 | 112 | 0.613492 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,878 | archive.cc | NixOS_nix/src/libutil/archive.cc | #include <cerrno>
#include <algorithm>
#include <vector>
#include <map>
#include <strings.h> // for strcasecmp
#include "archive.hh"
#include "config-global.hh"
#include "posix-source-accessor.hh"
#include "source-path.hh"
#include "file-system.hh"
#include "signals.hh"
namespace nix {
struct ArchiveSettings : Conf... | 8,155 | C++ | .cc | 228 | 26.859649 | 143 | 0.553094 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,879 | fs-sink.cc | NixOS_nix/src/libutil/fs-sink.cc | #include <fcntl.h>
#include "error.hh"
#include "config-global.hh"
#include "fs-sink.hh"
#if _WIN32
# include <fileapi.h>
# include "file-path.hh"
# include "windows-error.hh"
#endif
namespace nix {
void copyRecursive(
SourceAccessor & accessor, const CanonPath & from,
FileSystemObjectSink & sink, const Can... | 5,247 | C++ | .cc | 162 | 26.796296 | 123 | 0.655589 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,880 | english.cc | NixOS_nix/src/libutil/english.cc | #include "english.hh"
namespace nix {
std::ostream & pluralize(
std::ostream & output,
unsigned int count,
const std::string_view single,
const std::string_view plural)
{
if (count == 1)
output << "1 " << single;
else
output << count << " " << plural;
return output;
}
}
| 318 | C++ | .cc | 15 | 17.066667 | 41 | 0.603333 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,881 | terminal.cc | NixOS_nix/src/libutil/terminal.cc | #include "terminal.hh"
#include "environment-variables.hh"
#include "sync.hh"
#if _WIN32
# include <io.h>
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# define isatty _isatty
#else
# include <sys/ioctl.h>
#endif
#include <unistd.h>
namespace nix {
bool isTTY()
{
static const bool tty =
isatty(STDER... | 3,811 | C++ | .cc | 115 | 23.365217 | 85 | 0.401088 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,882 | tarfile.cc | NixOS_nix/src/libutil/tarfile.cc | #include <archive.h>
#include <archive_entry.h>
#include "finally.hh"
#include "serialise.hh"
#include "tarfile.hh"
#include "file-system.hh"
namespace nix {
namespace fs {
using namespace std::filesystem;
}
namespace {
int callback_open(struct archive *, void * self)
{
return ARCHIVE_OK;
}
ssize_t callback_r... | 7,642 | C++ | .cc | 205 | 30.404878 | 117 | 0.638209 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,883 | canon-path.cc | NixOS_nix/src/libutil/canon-path.cc | #include "canon-path.hh"
#include "util.hh"
#include "file-path-impl.hh"
#include "strings-inline.hh"
namespace nix {
CanonPath CanonPath::root = CanonPath("/");
static std::string absPathPure(std::string_view path)
{
return canonPathInner<UnixPathTrait>(path, [](auto &, auto &){});
}
CanonPath::CanonPath(std::... | 3,397 | C++ | .cc | 124 | 22.580645 | 91 | 0.575823 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,884 | users.cc | NixOS_nix/src/libutil/users.cc | #include "util.hh"
#include "users.hh"
#include "environment-variables.hh"
#include "file-system.hh"
namespace nix {
Path getCacheDir()
{
auto dir = getEnv("NIX_CACHE_HOME");
if (dir) {
return *dir;
} else {
auto xdgDir = getEnv("XDG_CACHE_HOME");
if (xdgDir) {
return *... | 2,047 | C++ | .cc | 88 | 17.579545 | 89 | 0.542886 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,885 | json-utils.cc | NixOS_nix/src/libutil/json-utils.cc | #include "json-utils.hh"
#include "error.hh"
#include "types.hh"
#include <nlohmann/json_fwd.hpp>
#include <iostream>
namespace nix {
const nlohmann::json * get(const nlohmann::json & map, const std::string & key)
{
auto i = map.find(key);
if (i == map.end()) return nullptr;
return &*i;
}
nlohmann::json ... | 3,481 | C++ | .cc | 102 | 30.578431 | 122 | 0.691137 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,886 | memory-source-accessor.cc | NixOS_nix/src/libutil/memory-source-accessor.cc | #include "memory-source-accessor.hh"
namespace nix {
MemorySourceAccessor::File *
MemorySourceAccessor::open(const CanonPath & path, std::optional<File> create)
{
File * cur = &root;
bool newF = false;
for (std::string_view name : path)
{
auto * curDirP = std::get_if<File::Directory>(&cur->r... | 5,477 | C++ | .cc | 164 | 27.219512 | 109 | 0.611279 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,887 | hash.cc | NixOS_nix/src/libutil/hash.cc | #include <iostream>
#include <cstring>
#include <openssl/crypto.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#include "args.hh"
#include "hash.hh"
#include "archive.hh"
#include "split.hh"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sodium.h>
namespace nix {
static size_t reg... | 12,570 | C++ | .cc | 376 | 28.034574 | 113 | 0.625826 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,888 | compression.cc | NixOS_nix/src/libutil/compression.cc | #include "compression.hh"
#include "signals.hh"
#include "tarfile.hh"
#include "finally.hh"
#include "logging.hh"
#include <archive.h>
#include <archive_entry.h>
#include <cstdio>
#include <cstring>
#include <brotli/decode.h>
#include <brotli/encode.h>
namespace nix {
static const int COMPRESSION_LEVEL_DEFAULT = -1... | 9,606 | C++ | .cc | 270 | 28.177778 | 118 | 0.621343 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,889 | strings.cc | NixOS_nix/src/libutil/strings.cc | #include <filesystem>
#include <string>
#include <sstream>
#include "strings-inline.hh"
#include "os-string.hh"
namespace nix {
struct view_stringbuf : public std::stringbuf
{
inline std::string_view toView()
{
auto begin = pbase();
return {begin, begin + pubseekoff(0, std::ios_base::cur, std... | 2,149 | C++ | .cc | 40 | 51.55 | 107 | 0.757865 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,890 | serialise.cc | NixOS_nix/src/libutil/serialise.cc | #include "serialise.hh"
#include "signals.hh"
#include "util.hh"
#include <cstring>
#include <cerrno>
#include <memory>
#include <boost/coroutine2/coroutine.hpp>
#ifdef _WIN32
# include <fileapi.h>
# include <winsock2.h>
# include "windows-error.hh"
#else
# include <poll.h>
#endif
namespace nix {
void BufferedSi... | 10,444 | C++ | .cc | 379 | 20.825858 | 83 | 0.546266 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,891 | suggestions.cc | NixOS_nix/src/libutil/suggestions.cc | #include "suggestions.hh"
#include "ansicolor.hh"
#include "terminal.hh"
#include <algorithm>
#include <sstream>
namespace nix {
int levenshteinDistance(std::string_view first, std::string_view second)
{
// Implementation borrowed from
// https://en.wikipedia.org/wiki/Levenshtein_distance#Iterative_with_two_... | 2,867 | C++ | .cc | 95 | 23.778947 | 93 | 0.583546 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,892 | args.cc | NixOS_nix/src/libutil/args.cc | #include "args.hh"
#include "args/root.hh"
#include "hash.hh"
#include "environment-variables.hh"
#include "signals.hh"
#include "users.hh"
#include "json-utils.hh"
#include <fstream>
#include <string>
#include <regex>
#ifndef _WIN32
# include <glob.h>
#endif
namespace nix {
void Args::addFlag(Flag && flag_)
{
a... | 21,234 | C++ | .cc | 569 | 27.929701 | 148 | 0.548679 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,893 | position.cc | NixOS_nix/src/libutil/position.cc | #include "position.hh"
namespace nix {
Pos::Pos(const Pos * other)
{
if (!other) {
return;
}
line = other->line;
column = other->column;
origin = other->origin;
}
Pos::operator std::shared_ptr<Pos>() const
{
return std::make_shared<Pos>(&*this);
}
std::optional<LinesOfCode> Pos::getC... | 4,238 | C++ | .cc | 131 | 24.343511 | 114 | 0.52713 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,894 | environment-variables.cc | NixOS_nix/src/libutil/environment-variables.cc | #include "util.hh"
#include "environment-variables.hh"
extern char ** environ __attribute__((weak));
namespace nix {
std::optional<std::string> getEnv(const std::string & key)
{
char * value = getenv(key.c_str());
if (!value)
return {};
return std::string(value);
}
std::optional<std::string> get... | 1,100 | C++ | .cc | 43 | 21.139535 | 66 | 0.597712 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,895 | hilite.cc | NixOS_nix/src/libutil/hilite.cc | #include "hilite.hh"
namespace nix {
std::string hiliteMatches(
std::string_view s,
std::vector<std::smatch> matches,
std::string_view prefix,
std::string_view postfix)
{
// Avoid extra work on zero matches
if (matches.size() == 0)
return std::string(s);
std::sort(matches.begin(),... | 1,161 | C++ | .cc | 37 | 24.459459 | 82 | 0.549687 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,896 | error.cc | NixOS_nix/src/libutil/error.cc | #include <algorithm>
#include "error.hh"
#include "environment-variables.hh"
#include "signals.hh"
#include "terminal.hh"
#include "position.hh"
#include <iostream>
#include <optional>
#include "serialise.hh"
#include <sstream>
namespace nix {
void BaseError::addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TraceP... | 15,822 | C++ | .cc | 417 | 30.601918 | 146 | 0.589189 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,897 | compute-levels.cc | NixOS_nix/src/libutil/compute-levels.cc | #include "types.hh"
#if HAVE_LIBCPUID
#include <libcpuid/libcpuid.h>
#endif
namespace nix {
#if HAVE_LIBCPUID
StringSet computeLevels() {
StringSet levels;
if (!cpuid_present())
return levels;
cpu_raw_data_t raw;
cpu_id_t data;
if (cpuid_get_raw_data(&raw) < 0)
return levels;
... | 1,875 | C++ | .cc | 59 | 23.711864 | 47 | 0.580501 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
10,898 | unix-domain-socket.cc | NixOS_nix/src/libutil/unix-domain-socket.cc | #include "file-system.hh"
#include "unix-domain-socket.hh"
#include "util.hh"
#ifdef _WIN32
# include <winsock2.h>
# include <afunix.h>
#else
# include <sys/socket.h>
# include <sys/un.h>
# include "processes.hh"
#endif
#include <unistd.h>
namespace nix {
AutoCloseFD createUnixDomainSocket()
{
AutoCloseFD fdSock... | 3,528 | C++ | .cc | 99 | 28.717172 | 90 | 0.599531 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,899 | file-system.cc | NixOS_nix/src/libutil/file-system.cc | #include "environment-variables.hh"
#include "file-system.hh"
#include "file-path.hh"
#include "file-path-impl.hh"
#include "signals.hh"
#include "finally.hh"
#include "serialise.hh"
#include "util.hh"
#include <atomic>
#include <cerrno>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include... | 21,268 | C++ | .cc | 650 | 26.144615 | 110 | 0.582708 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,900 | file-content-address.cc | NixOS_nix/src/libutil/file-content-address.cc | #include "file-content-address.hh"
#include "archive.hh"
#include "git.hh"
#include "source-path.hh"
namespace nix {
static std::optional<FileSerialisationMethod> parseFileSerialisationMethodOpt(std::string_view input)
{
if (input == "flat") {
return FileSerialisationMethod::Flat;
} else if (input == ... | 3,230 | C++ | .cc | 115 | 22.965217 | 101 | 0.688408 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,901 | cgroup.cc | NixOS_nix/src/libutil/linux/cgroup.cc | #include "cgroup.hh"
#include "signals.hh"
#include "util.hh"
#include "file-system.hh"
#include "finally.hh"
#include <chrono>
#include <cmath>
#include <regex>
#include <unordered_set>
#include <thread>
#include <dirent.h>
#include <mntent.h>
namespace nix {
std::optional<Path> getCgroupFS()
{
static auto res... | 5,081 | C++ | .cc | 133 | 30.052632 | 107 | 0.580671 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,902 | namespaces.cc | NixOS_nix/src/libutil/linux/namespaces.cc | #include "current-process.hh"
#include "util.hh"
#include "finally.hh"
#include "file-system.hh"
#include "processes.hh"
#include "signals.hh"
#include <mutex>
#include <sys/resource.h>
#include "cgroup.hh"
#include <sys/mount.h>
namespace nix {
bool userNamespacesSupported()
{
static auto res = [&]() -> bool
... | 4,178 | C++ | .cc | 119 | 26.142857 | 112 | 0.551091 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,903 | local-keys.cc | NixOS_nix/src/libutil/signature/local-keys.cc | #include "signature/local-keys.hh"
#include "file-system.hh"
#include "util.hh"
#include <sodium.h>
namespace nix {
BorrowedCryptoValue BorrowedCryptoValue::parse(std::string_view s)
{
size_t colon = s.find(':');
if (colon == std::string::npos || colon == 0)
return {"", ""};
return {s.substr(0, c... | 3,244 | C++ | .cc | 95 | 29.705263 | 95 | 0.65739 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,904 | signer.cc | NixOS_nix/src/libutil/signature/signer.cc | #include "signature/signer.hh"
#include "error.hh"
#include <sodium.h>
namespace nix {
LocalSigner::LocalSigner(SecretKey && privateKey)
: privateKey(privateKey)
, publicKey(privateKey.toPublicKey())
{ }
std::string LocalSigner::signDetached(std::string_view s) const
{
return privateKey.signDetached(s);... | 399 | C++ | .cc | 17 | 21.176471 | 63 | 0.763298 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,905 | processes.cc | NixOS_nix/src/libutil/unix/processes.cc | #include "current-process.hh"
#include "environment-variables.hh"
#include "executable-path.hh"
#include "signals.hh"
#include "processes.hh"
#include "finally.hh"
#include "serialise.hh"
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <future>
#include <iostream>
#include <sstream>
#include <thread>
... | 11,595 | C++ | .cc | 341 | 27.307918 | 147 | 0.589842 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,906 | muxable-pipe.cc | NixOS_nix/src/libutil/unix/muxable-pipe.cc | #include <poll.h>
#include "logging.hh"
#include "util.hh"
#include "muxable-pipe.hh"
namespace nix {
void MuxablePipePollState::poll(std::optional<unsigned int> timeout)
{
if (::poll(pollStatus.data(), pollStatus.size(), timeout ? *timeout : -1) == -1) {
if (errno == EINTR)
return;
t... | 1,506 | C++ | .cc | 42 | 27.880952 | 89 | 0.580535 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,907 | file-descriptor.cc | NixOS_nix/src/libutil/unix/file-descriptor.cc | #include "file-system.hh"
#include "signals.hh"
#include "finally.hh"
#include "serialise.hh"
#include <fcntl.h>
#include <unistd.h>
namespace nix {
std::string readFile(int fd)
{
struct stat st;
if (fstat(fd, &st) == -1)
throw SysError("statting file");
return drainFD(fd, true, st.st_size);
}
... | 4,671 | C++ | .cc | 159 | 23.075472 | 89 | 0.541137 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,908 | signals.cc | NixOS_nix/src/libutil/unix/signals.cc | #include "signals.hh"
#include "util.hh"
#include "error.hh"
#include "sync.hh"
#include "terminal.hh"
#include <thread>
namespace nix {
using namespace unix;
std::atomic<bool> unix::_isInterrupted = false;
namespace unix {
static thread_local bool interruptThrown = false;
}
thread_local std::function<bool()> uni... | 5,325 | C++ | .cc | 152 | 29.657895 | 90 | 0.671083 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,909 | os-string.cc | NixOS_nix/src/libutil/unix/os-string.cc | #include <algorithm>
#include <codecvt>
#include <iostream>
#include <locale>
#include "file-path.hh"
#include "util.hh"
namespace nix {
std::string os_string_to_string(PathViewNG::string_view path)
{
return std::string{path};
}
std::filesystem::path::string_type string_to_os_string(std::string_view s)
{
re... | 346 | C++ | .cc | 16 | 19.8125 | 74 | 0.741538 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,910 | users.cc | NixOS_nix/src/libutil/unix/users.cc | #include "util.hh"
#include "users.hh"
#include "environment-variables.hh"
#include "file-system.hh"
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
namespace nix {
namespace fs { using namespace std::filesystem; }
std::string getUserName()
{
auto pw = getpwuid(geteuid());
std::string name = pw ... | 1,968 | C++ | .cc | 60 | 25.866667 | 168 | 0.571579 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,911 | file-path.cc | NixOS_nix/src/libutil/unix/file-path.cc | #include <algorithm>
#include <codecvt>
#include <iostream>
#include <locale>
#include "file-path.hh"
#include "util.hh"
namespace nix {
std::optional<std::filesystem::path> maybePath(PathView path)
{
return { path };
}
std::filesystem::path pathNG(PathView path)
{
return path;
}
}
| 296 | C++ | .cc | 16 | 16.6875 | 61 | 0.741818 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,912 | environment-variables.cc | NixOS_nix/src/libutil/unix/environment-variables.cc | #include <cstdlib>
#include "environment-variables.hh"
namespace nix {
int setEnv(const char * name, const char * value)
{
return ::setenv(name, value, 1);
}
std::optional<std::string> getEnvOs(const std::string & key)
{
return getEnv(key);
}
int setEnvOs(const OsString & name, const OsString & value)
{
... | 371 | C++ | .cc | 16 | 21.0625 | 60 | 0.710602 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,913 | file-system.cc | NixOS_nix/src/libutil/unix/file-system.cc | #include "file-system.hh"
namespace nix {
Descriptor openDirectory(const std::filesystem::path & path)
{
return open(path.c_str(), O_RDONLY | O_DIRECTORY);
}
}
| 167 | C++ | .cc | 7 | 21.857143 | 60 | 0.732484 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,914 | windows-async-pipe.cc | NixOS_nix/src/libutil/windows/windows-async-pipe.cc | #include "windows-async-pipe.hh"
#include "windows-error.hh"
namespace nix::windows {
void AsyncPipe::createAsyncPipe(HANDLE iocp)
{
// std::cerr << (format("-----AsyncPipe::createAsyncPipe(%x)") % iocp) << std::endl;
buffer.resize(0x1000);
memset(&overlapped, 0, sizeof(overlapped));
std::string pip... | 1,466 | C++ | .cc | 38 | 33.078947 | 117 | 0.651376 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,915 | processes.cc | NixOS_nix/src/libutil/windows/processes.cc | #include "current-process.hh"
#include "environment-variables.hh"
#include "error.hh"
#include "executable-path.hh"
#include "file-descriptor.hh"
#include "file-path.hh"
#include "signals.hh"
#include "processes.hh"
#include "finally.hh"
#include "serialise.hh"
#include "file-system.hh"
#include "util.hh"
#include "win... | 11,714 | C++ | .cc | 331 | 29.081571 | 129 | 0.628995 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,916 | muxable-pipe.cc | NixOS_nix/src/libutil/windows/muxable-pipe.cc | #include <ioapiset.h>
#include "windows-error.hh"
#include "logging.hh"
#include "util.hh"
#include "muxable-pipe.hh"
namespace nix {
void MuxablePipePollState::poll(HANDLE ioport, std::optional<unsigned int> timeout)
{
/* We are on at least Windows Vista / Server 2008 and can get many
(countof(oentries))... | 2,783 | C++ | .cc | 64 | 30.90625 | 119 | 0.523406 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,917 | file-descriptor.cc | NixOS_nix/src/libutil/windows/file-descriptor.cc | #include "file-system.hh"
#include "signals.hh"
#include "finally.hh"
#include "serialise.hh"
#include "windows-error.hh"
#include "file-path.hh"
#include <fileapi.h>
#include <error.h>
#include <namedpipeapi.h>
#include <namedpipeapi.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace nix {
using namespac... | 4,103 | C++ | .cc | 127 | 26.181102 | 103 | 0.578628 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,918 | os-string.cc | NixOS_nix/src/libutil/windows/os-string.cc | #include <algorithm>
#include <codecvt>
#include <iostream>
#include <locale>
#include "file-path.hh"
#include "file-path-impl.hh"
#include "util.hh"
namespace nix {
std::string os_string_to_string(PathViewNG::string_view path)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return conver... | 580 | C++ | .cc | 19 | 28.421053 | 74 | 0.748201 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,919 | users.cc | NixOS_nix/src/libutil/windows/users.cc | #include "util.hh"
#include "users.hh"
#include "environment-variables.hh"
#include "file-system.hh"
#include "windows-error.hh"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace nix {
using namespace nix::windows;
std::string getUserName()
{
// Get the required buffer size
DWORD size = 0;
if (... | 1,093 | C++ | .cc | 42 | 21.738095 | 77 | 0.657061 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,920 | file-path.cc | NixOS_nix/src/libutil/windows/file-path.cc | #include <algorithm>
#include <codecvt>
#include <iostream>
#include <locale>
#include "file-path.hh"
#include "file-path-impl.hh"
#include "util.hh"
namespace nix {
std::optional<std::filesystem::path> maybePath(PathView path)
{
if (path.length() >= 3 && (('A' <= path[0] && path[0] <= 'Z') || ('a' <= path[0] &&... | 1,392 | C++ | .cc | 35 | 34.771429 | 171 | 0.546598 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,921 | windows-error.cc | NixOS_nix/src/libutil/windows/windows-error.cc | #include "windows-error.hh"
#include <error.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace nix::windows {
std::string WinError::renderError(DWORD lastError)
{
LPSTR errorText = NULL;
FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM // use system message tables to retrieve error text
... | 1,041 | C++ | .cc | 25 | 32.32 | 143 | 0.614851 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,922 | environment-variables.cc | NixOS_nix/src/libutil/windows/environment-variables.cc | #include "environment-variables.hh"
#include "processenv.h"
namespace nix {
std::optional<OsString> getEnvOs(const OsString & key)
{
// Determine the required buffer size for the environment variable value
DWORD bufferSize = GetEnvironmentVariableW(key.c_str(), nullptr, 0);
if (bufferSize == 0) {
... | 1,091 | C++ | .cc | 34 | 28.411765 | 83 | 0.717973 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,923 | file-system.cc | NixOS_nix/src/libutil/windows/file-system.cc | #include "file-system.hh"
namespace nix {
Descriptor openDirectory(const std::filesystem::path & path)
{
return CreateFileW(
path.c_str(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
... | 332 | C++ | .cc | 14 | 18.214286 | 63 | 0.638095 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,924 | path.cc | NixOS_nix/src/libstore-test-support/tests/path.cc | #include <rapidcheck/gen/Arbitrary.h>
#include <regex>
#include <rapidcheck.h>
#include "path-regex.hh"
#include "store-api.hh"
#include "tests/hash.hh"
#include "tests/path.hh"
namespace nix {
void showValue(const StorePath & p, std::ostream & os)
{
os << p.to_string();
}
}
namespace rc {
using namespace ni... | 1,774 | C++ | .cc | 69 | 16.550725 | 94 | 0.448052 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,925 | derived-path.cc | NixOS_nix/src/libstore-test-support/tests/derived-path.cc | #include <regex>
#include <rapidcheck.h>
#include "tests/derived-path.hh"
namespace rc {
using namespace nix;
Gen<SingleDerivedPath::Opaque> Arbitrary<SingleDerivedPath::Opaque>::arbitrary()
{
return gen::just(DerivedPath::Opaque {
.path = *gen::arbitrary<StorePath>(),
});
}
Gen<SingleDerivedPath::... | 1,607 | C++ | .cc | 48 | 29.125 | 90 | 0.690323 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,926 | outputs-spec.cc | NixOS_nix/src/libstore-test-support/tests/outputs-spec.cc | #include "tests/outputs-spec.hh"
#include <rapidcheck.h>
namespace rc {
using namespace nix;
Gen<OutputsSpec> Arbitrary<OutputsSpec>::arbitrary()
{
switch (*gen::inRange<uint8_t>(0, std::variant_size_v<OutputsSpec::Raw>)) {
case 0:
return gen::just((OutputsSpec) OutputsSpec::All { });
case 1:
... | 607 | C++ | .cc | 20 | 24.35 | 79 | 0.617496 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,927 | public-key.cc | NixOS_nix/src/libfetchers-tests/public-key.cc | #include <gtest/gtest.h>
#include "fetchers.hh"
#include "json-utils.hh"
#include <nlohmann/json.hpp>
#include "tests/characterization.hh"
namespace nix {
using nlohmann::json;
class PublicKeyTest : public CharacterizationTest
{
std::filesystem::path unitTestData = getUnitTestData() / "public-key";
public:
... | 2,255 | C++ | .cc | 44 | 44.068182 | 93 | 0.463426 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,928 | git-utils.cc | NixOS_nix/src/libfetchers-tests/git-utils.cc | #include "git-utils.hh"
#include "file-system.hh"
#include "gmock/gmock.h"
#include <git2/global.h>
#include <git2/repository.h>
#include <git2/types.h>
#include <gtest/gtest.h>
#include "fs-sink.hh"
#include "serialise.hh"
namespace nix {
class GitUtilsTest : public ::testing::Test
{
// We use a single repositor... | 3,829 | C++ | .cc | 94 | 35.670213 | 120 | 0.669357 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,929 | graphml.cc | NixOS_nix/src/nix-store/graphml.cc | #include "graphml.hh"
#include "store-api.hh"
#include "derivations.hh"
#include <iostream>
using std::cout;
namespace nix {
static inline std::string_view xmlQuote(std::string_view s)
{
// Luckily, store paths shouldn't contain any character that needs to be
// quoted.
return s;
}
static std::strin... | 2,350 | C++ | .cc | 64 | 30.5 | 95 | 0.585506 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,930 | nix-store.cc | NixOS_nix/src/nix-store/nix-store.cc | #include "archive.hh"
#include "derivations.hh"
#include "dotgraph.hh"
#include "globals.hh"
#include "store-cast.hh"
#include "local-fs-store.hh"
#include "log-store.hh"
#include "serve-protocol.hh"
#include "serve-protocol-connection.hh"
#include "shared.hh"
#include "graphml.hh"
#include "legacy.hh"
#include "posix-... | 41,387 | C++ | .cc | 1,006 | 31.183897 | 147 | 0.569562 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,931 | dotgraph.cc | NixOS_nix/src/nix-store/dotgraph.cc | #include "dotgraph.hh"
#include "store-api.hh"
#include <iostream>
using std::cout;
namespace nix {
static std::string dotQuote(std::string_view s)
{
return "\"" + std::string(s) + "\"";
}
static const std::string & nextColour()
{
static int n = 0;
static std::vector<std::string> colours
{ "... | 1,569 | C++ | .cc | 48 | 27.3125 | 92 | 0.601734 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,932 | pool.cc | NixOS_nix/src/libutil-tests/pool.cc | #include "pool.hh"
#include <gtest/gtest.h>
namespace nix {
struct TestResource
{
TestResource() {
static int counter = 0;
num = counter++;
}
int dummyValue = 1;
bool good = true;
int num;
};
/* ----------------------------------------... | 4,453 | C++ | .cc | 99 | 36.363636 | 94 | 0.577901 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
10,933 | checked-arithmetic.cc | NixOS_nix/src/libutil-tests/checked-arithmetic.cc | #include <cstdint>
#include <gtest/gtest.h>
#include <limits>
#include <rapidcheck/Assertions.h>
#include <rapidcheck/gtest.h>
#include <rapidcheck/gen/Arbitrary.hpp>
#include <checked-arithmetic.hh>
#include "tests/gtest-with-params.hh"
namespace rc {
using namespace nix;
template<std::integral T>
struct Arbitrary... | 5,200 | C++ | .cc | 132 | 35.962121 | 114 | 0.688219 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,934 | url.cc | NixOS_nix/src/libutil-tests/url.cc | #include "url.hh"
#include <gtest/gtest.h>
namespace nix {
/* ----------- tests for url.hh --------------------------------------------------*/
std::string print_map(std::map<std::string, std::string> m) {
std::map<std::string, std::string>::iterator it;
std::string s = "{ ";
for (it = m.... | 11,762 | C++ | .cc | 298 | 30.281879 | 84 | 0.513079 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,935 | chunked-vector.cc | NixOS_nix/src/libutil-tests/chunked-vector.cc | #include "chunked-vector.hh"
#include <gtest/gtest.h>
namespace nix {
TEST(ChunkedVector, InitEmpty) {
auto v = ChunkedVector<int, 2>(100);
ASSERT_EQ(v.size(), 0);
}
TEST(ChunkedVector, GrowsCorrectly) {
auto v = ChunkedVector<int, 2>(100);
for (auto i = 1; i < 20; i++) {
... | 1,357 | C++ | .cc | 46 | 20.847826 | 67 | 0.4835 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,936 | processes.cc | NixOS_nix/src/libutil-tests/processes.cc | #include "processes.hh"
#include <gtest/gtest.h>
namespace nix {
/* ----------------------------------------------------------------------------
* statusOk
* --------------------------------------------------------------------------*/
TEST(statusOk, zeroIsOk)
{
ASSERT_EQ(statusOk(0), true);
ASSERT_EQ(stat... | 359 | C++ | .cc | 12 | 27.666667 | 79 | 0.383041 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,937 | executable-path.cc | NixOS_nix/src/libutil-tests/executable-path.cc | #include <gtest/gtest.h>
#include "executable-path.hh"
namespace nix {
#ifdef WIN32
# define PATH_VAR_SEP L";"
#else
# define PATH_VAR_SEP ":"
#endif
#define PATH_ENV_ROUND_TRIP(NAME, STRING_LIT, CXX_LIT) \
TEST(ExecutablePath, NAME) \
{ ... | 1,515 | C++ | .cc | 54 | 22.5 | 82 | 0.481048 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,938 | config.cc | NixOS_nix/src/libutil-tests/config.cc | #include "config.hh"
#include "args.hh"
#include <sstream>
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
namespace nix {
/* ----------------------------------------------------------------------------
* Config
* --------------------------------------------------------------------------*/
T... | 10,103 | C++ | .cc | 251 | 30.956175 | 96 | 0.580139 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
10,939 | closure.cc | NixOS_nix/src/libutil-tests/closure.cc | #include "closure.hh"
#include <gtest/gtest.h>
namespace nix {
using namespace std;
map<string, set<string>> testGraph = {
{ "A", { "B", "C", "G" } },
{ "B", { "A" } }, // Loops back to A
{ "C", { "F" } }, // Indirect reference
{ "D", { "A" } }, // Not reachable, but has backreferences
{ "E", {} ... | 1,867 | C++ | .cc | 62 | 22.080645 | 96 | 0.533667 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
10,940 | util.cc | NixOS_nix/src/libutil-tests/util.cc | #include "util.hh"
#include "types.hh"
#include "file-system.hh"
#include "terminal.hh"
#include "strings.hh"
#include <limits.h>
#include <gtest/gtest.h>
#include <numeric>
namespace nix {
/* ----------- tests for util.hh --------------------------------------------*/
/* ------------------------------------------... | 9,504 | C++ | .cc | 303 | 28.141914 | 91 | 0.471524 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
10,941 | logging.cc | NixOS_nix/src/libutil-tests/logging.cc | #if 0
#include "logging.hh"
#include "nixexpr.hh"
#include <fstream>
#include <gtest/gtest.h>
namespace nix {
/* ----------------------------------------------------------------------------
* logEI
* --------------------------------------------------------------------------*/
const char *test_fil... | 14,815 | C++ | .cc | 265 | 45.758491 | 879 | 0.554479 | NixOS/nix | 12,186 | 1,472 | 3,401 | LGPL-2.1 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.