1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 12:21:48 +02:00

Separate headers from source files

The short answer for why we need to do this is so we can consistently do
`#include "nix/..."`. Without this change, there are ways to still make
that work, but they are hacky, and they have downsides such as making it
harder to make sure headers from the wrong Nix library (e..g.
`libnixexpr` headers in `libnixutil`) aren't being used.

The C API alraedy used `nix_api_*`, so its headers are *not* put in
subdirectories accordingly.

Progress on #7876

We resisted doing this for a while because it would be annoying to not
have the header source file pairs close by / easy to change file
path/name from one to the other. But I am ameliorating that with
symlinks in the next commit.
This commit is contained in:
John Ericson 2025-02-20 14:15:07 -05:00
parent 326548bae5
commit f3e1c47f47
664 changed files with 2974 additions and 2913 deletions

View file

@ -5,12 +5,12 @@
#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"
#include "nix/archive.hh"
#include "nix/config-global.hh"
#include "nix/posix-source-accessor.hh"
#include "nix/source-path.hh"
#include "nix/file-system.hh"
#include "nix/signals.hh"
namespace nix {

View file

@ -1,10 +1,10 @@
#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 "nix/args.hh"
#include "nix/args/root.hh"
#include "nix/hash.hh"
#include "nix/environment-variables.hh"
#include "nix/signals.hh"
#include "nix/users.hh"
#include "nix/json-utils.hh"
#include <fstream>
#include <string>

View file

@ -1,7 +1,7 @@
#include "canon-path.hh"
#include "util.hh"
#include "file-path-impl.hh"
#include "strings-inline.hh"
#include "nix/canon-path.hh"
#include "nix/util.hh"
#include "nix/file-path-impl.hh"
#include "nix/strings-inline.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#include "compression.hh"
#include "signals.hh"
#include "tarfile.hh"
#include "finally.hh"
#include "logging.hh"
#include "nix/compression.hh"
#include "nix/signals.hh"
#include "nix/tarfile.hh"
#include "nix/finally.hh"
#include "nix/logging.hh"
#include <archive.h>
#include <archive_entry.h>

View file

@ -1,4 +1,4 @@
#include "types.hh"
#include "nix/types.hh"
#if HAVE_LIBCPUID
#include <libcpuid/libcpuid.h>

View file

@ -1,4 +1,4 @@
#include "config-global.hh"
#include "nix/config-global.hh"
#include <nlohmann/json.hpp>

View file

@ -1,16 +1,16 @@
#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 "nix/config.hh"
#include "nix/args.hh"
#include "nix/abstract-setting-to-json.hh"
#include "nix/environment-variables.hh"
#include "nix/experimental-features.hh"
#include "nix/util.hh"
#include "nix/file-system.hh"
#include "config-impl.hh"
#include "nix/config-impl.hh"
#include <nlohmann/json.hpp>
#include "strings.hh"
#include "nix/strings.hh"
namespace nix {

View file

@ -1,12 +1,12 @@
#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 "nix/current-process.hh"
#include "nix/util.hh"
#include "nix/finally.hh"
#include "nix/file-system.hh"
#include "nix/processes.hh"
#include "nix/signals.hh"
#include <math.h>
#ifdef __APPLE__
@ -15,8 +15,8 @@
#if __linux__
# include <mutex>
# include "cgroup.hh"
# include "namespaces.hh"
# include "nix/cgroup.hh"
# include "nix/namespaces.hh"
#endif
namespace nix {

View file

@ -1,4 +1,4 @@
#include "english.hh"
#include "nix/english.hh"
namespace nix {

View file

@ -1,5 +1,5 @@
#include "util.hh"
#include "environment-variables.hh"
#include "nix/util.hh"
#include "nix/environment-variables.hh"
extern char ** environ __attribute__((weak));

View file

@ -1,14 +1,14 @@
#include <algorithm>
#include "error.hh"
#include "environment-variables.hh"
#include "signals.hh"
#include "terminal.hh"
#include "position.hh"
#include "nix/error.hh"
#include "nix/environment-variables.hh"
#include "nix/signals.hh"
#include "nix/terminal.hh"
#include "nix/position.hh"
#include <iostream>
#include <optional>
#include "serialise.hh"
#include "nix/serialise.hh"
#include <sstream>
namespace nix {

View file

@ -1,8 +1,8 @@
#include "environment-variables.hh"
#include "executable-path.hh"
#include "strings-inline.hh"
#include "util.hh"
#include "file-path-impl.hh"
#include "nix/environment-variables.hh"
#include "nix/executable-path.hh"
#include "nix/strings-inline.hh"
#include "nix/util.hh"
#include "nix/file-path-impl.hh"
namespace nix {

View file

@ -1,4 +1,4 @@
#include "exit.hh"
#include "nix/exit.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#include "experimental-features.hh"
#include "fmt.hh"
#include "util.hh"
#include "nix/experimental-features.hh"
#include "nix/fmt.hh"
#include "nix/util.hh"
#include "nlohmann/json.hpp"
#include <nlohmann/json.hpp>
namespace nix {

View file

@ -1,7 +1,7 @@
#include "file-content-address.hh"
#include "archive.hh"
#include "git.hh"
#include "source-path.hh"
#include "nix/file-content-address.hh"
#include "nix/archive.hh"
#include "nix/git.hh"
#include "nix/source-path.hh"
namespace nix {

View file

@ -1,12 +1,12 @@
#include "serialise.hh"
#include "util.hh"
#include "nix/serialise.hh"
#include "nix/util.hh"
#include <fcntl.h>
#include <unistd.h>
#ifdef _WIN32
# include <winnt.h>
# include <fileapi.h>
# include "windows-error.hh"
# include "nix/windows-error.hh"
#endif
namespace nix {

View file

@ -1,11 +1,11 @@
#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 "nix/environment-variables.hh"
#include "nix/file-system.hh"
#include "nix/file-path.hh"
#include "nix/file-path-impl.hh"
#include "nix/signals.hh"
#include "nix/finally.hh"
#include "nix/serialise.hh"
#include "nix/util.hh"
#include <atomic>
#include <cerrno>
@ -25,7 +25,7 @@
# include <io.h>
#endif
#include "strings-inline.hh"
#include "nix/strings-inline.hh"
namespace nix {

View file

@ -1,13 +1,13 @@
#include <fcntl.h>
#include "error.hh"
#include "config-global.hh"
#include "fs-sink.hh"
#include "nix/error.hh"
#include "nix/config-global.hh"
#include "nix/fs-sink.hh"
#if _WIN32
# include <fileapi.h>
# include "file-path.hh"
# include "windows-error.hh"
# include "nix/file-path.hh"
# include "nix/windows-error.hh"
#endif
namespace nix {

View file

@ -5,12 +5,12 @@
#include <regex>
#include <strings.h> // for strcasecmp
#include "signals.hh"
#include "config.hh"
#include "hash.hh"
#include "nix/signals.hh"
#include "nix/config.hh"
#include "nix/hash.hh"
#include "git.hh"
#include "serialise.hh"
#include "nix/git.hh"
#include "nix/serialise.hh"
namespace nix::git {

View file

@ -6,11 +6,11 @@
#include <openssl/md5.h>
#include <openssl/sha.h>
#include "args.hh"
#include "hash.hh"
#include "archive.hh"
#include "config.hh"
#include "split.hh"
#include "nix/args.hh"
#include "nix/hash.hh"
#include "nix/archive.hh"
#include "nix/config.hh"
#include "nix/split.hh"
#include <sys/types.h>
#include <sys/stat.h>

View file

@ -1,4 +1,4 @@
#include "hilite.hh"
#include "nix/hilite.hh"
namespace nix {

View file

@ -2,8 +2,8 @@
///@file
#include <nlohmann/json.hpp>
#include "config.hh"
#include "json-utils.hh"
#include "nix/config.hh"
#include "nix/json-utils.hh"
namespace nix {
template<typename T>

View file

@ -1,9 +1,9 @@
#pragma once
///@file
#include "types.hh"
#include "serialise.hh"
#include "fs-sink.hh"
#include "nix/types.hh"
#include "nix/serialise.hh"
#include "nix/fs-sink.hh"
namespace nix {

View file

@ -9,9 +9,9 @@
#include <nlohmann/json_fwd.hpp>
#include "types.hh"
#include "experimental-features.hh"
#include "ref.hh"
#include "nix/types.hh"
#include "nix/experimental-features.hh"
#include "nix/ref.hh"
namespace nix {

View file

@ -1,6 +1,6 @@
#pragma once
#include "args.hh"
#include "nix/args.hh"
namespace nix {

View file

@ -6,7 +6,7 @@
#include <vector>
#include <limits>
#include "error.hh"
#include "nix/error.hh"
namespace nix {

View file

@ -3,7 +3,7 @@
#include <set>
#include <future>
#include "sync.hh"
#include "nix/sync.hh"
using std::set;

View file

@ -1,9 +1,9 @@
#pragma once
///@file
#include "ref.hh"
#include "types.hh"
#include "serialise.hh"
#include "nix/ref.hh"
#include "nix/types.hh"
#include "nix/serialise.hh"
#include <string>

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "types.hh"
#include "nix/types.hh"
namespace nix {

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "config.hh"
#include "nix/config.hh"
namespace nix {

View file

@ -12,8 +12,8 @@
* instantiation.
*/
#include "config.hh"
#include "args.hh"
#include "nix/config.hh"
#include "nix/args.hh"
namespace nix {

View file

@ -7,8 +7,8 @@
#include <nlohmann/json_fwd.hpp>
#include "types.hh"
#include "experimental-features.hh"
#include "nix/types.hh"
#include "nix/experimental-features.hh"
namespace nix {

View file

@ -7,7 +7,7 @@
# include <sys/resource.h>
#endif
#include "types.hh"
#include "nix/types.hh"
namespace nix {

View file

@ -8,8 +8,8 @@
#include <optional>
#include "types.hh"
#include "file-path.hh"
#include "nix/types.hh"
#include "nix/file-path.hh"
namespace nix {

View file

@ -15,8 +15,8 @@
* See libutil/tests/logging.cc for usage examples.
*/
#include "suggestions.hh"
#include "fmt.hh"
#include "nix/suggestions.hh"
#include "nix/fmt.hh"
#include <cstring>
#include <list>

View file

@ -1,6 +1,6 @@
#pragma once
#include "os-string.hh"
#include "nix/os-string.hh"
namespace nix {

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "file-system.hh"
#include "nix/file-system.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#pragma once
///@file
#include "error.hh"
#include "types.hh"
#include "nix/error.hh"
#include "nix/types.hh"
#include <nlohmann/json_fwd.hpp>

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "source-accessor.hh"
#include "nix/source-accessor.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#pragma once
///@file
#include "types.hh"
#include "error.hh"
#include "nix/types.hh"
#include "nix/error.hh"
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN

View file

@ -3,8 +3,8 @@
#include <filesystem>
#include "types.hh"
#include "os-string.hh"
#include "nix/types.hh"
#include "nix/os-string.hh"
namespace nix {

View file

@ -5,11 +5,11 @@
* Utilities for working with the file system and file paths.
*/
#include "types.hh"
#include "error.hh"
#include "logging.hh"
#include "file-descriptor.hh"
#include "file-path.hh"
#include "nix/types.hh"
#include "nix/error.hh"
#include "nix/logging.hh"
#include "nix/file-descriptor.hh"
#include "nix/file-path.hh"
#include <sys/types.h>
#include <sys/stat.h>

View file

@ -3,7 +3,7 @@
#include <boost/format.hpp>
#include <string>
#include "ansicolor.hh"
#include "nix/ansicolor.hh"
namespace nix {

View file

@ -1,9 +1,9 @@
#pragma once
///@file
#include "serialise.hh"
#include "source-accessor.hh"
#include "file-system.hh"
#include "nix/serialise.hh"
#include "nix/source-accessor.hh"
#include "nix/file-system.hh"
namespace nix {

View file

@ -5,11 +5,11 @@
#include <string_view>
#include <optional>
#include "types.hh"
#include "serialise.hh"
#include "hash.hh"
#include "source-path.hh"
#include "fs-sink.hh"
#include "nix/types.hh"
#include "nix/serialise.hh"
#include "nix/hash.hh"
#include "nix/source-path.hh"
#include "nix/fs-sink.hh"
namespace nix::git {

View file

@ -1,10 +1,10 @@
#pragma once
///@file
#include "config.hh"
#include "types.hh"
#include "serialise.hh"
#include "file-system.hh"
#include "nix/config.hh"
#include "nix/types.hh"
#include "nix/serialise.hh"
#include "nix/file-system.hh"
namespace nix {

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "nlohmann/json_fwd.hpp"
#include <nlohmann/json_fwd.hpp>
// Following https://github.com/nlohmann/json#how-can-i-use-get-for-non-default-constructiblenon-copyable-types
#define JSON_IMPL(TYPE) \

View file

@ -4,7 +4,7 @@
#include <nlohmann/json.hpp>
#include <list>
#include "types.hh"
#include "nix/types.hh"
namespace nix {

View file

@ -1,10 +1,10 @@
#pragma once
///@file
#include "error.hh"
#include "config.hh"
#include "file-descriptor.hh"
#include "finally.hh"
#include "nix/error.hh"
#include "nix/config.hh"
#include "nix/file-descriptor.hh"
#include "nix/finally.hh"
#include <nlohmann/json_fwd.hpp>

View file

@ -1,6 +1,6 @@
#include "source-path.hh"
#include "fs-sink.hh"
#include "variant-wrapper.hh"
#include "nix/source-path.hh"
#include "nix/fs-sink.hh"
#include "nix/variant-wrapper.hh"
namespace nix {

View file

@ -0,0 +1,87 @@
# Public headers directory
include_dirs = [include_directories('..')]
config_h = configure_file(
configuration : configdata,
output : 'config-util.hh',
)
headers = [config_h] + files(
'abstract-setting-to-json.hh',
'ansicolor.hh',
'archive.hh',
'args.hh',
'args/root.hh',
'callback.hh',
'canon-path.hh',
'checked-arithmetic.hh',
'chunked-vector.hh',
'closure.hh',
'comparator.hh',
'compression.hh',
'compute-levels.hh',
'config-global.hh',
'config-impl.hh',
'config.hh',
'current-process.hh',
'english.hh',
'environment-variables.hh',
'error.hh',
'exec.hh',
'executable-path.hh',
'exit.hh',
'experimental-features.hh',
'file-content-address.hh',
'file-descriptor.hh',
'file-path-impl.hh',
'file-path.hh',
'file-system.hh',
'finally.hh',
'fmt.hh',
'fs-sink.hh',
'git.hh',
'hash.hh',
'hilite.hh',
'json-impls.hh',
'json-utils.hh',
'logging.hh',
'lru-cache.hh',
'memory-source-accessor.hh',
'muxable-pipe.hh',
'os-string.hh',
'pool.hh',
'pos-idx.hh',
'pos-table.hh',
'position.hh',
'posix-source-accessor.hh',
'processes.hh',
'ref.hh',
'references.hh',
'regex-combinators.hh',
'repair-flag.hh',
'serialise.hh',
'signals.hh',
'signature/local-keys.hh',
'signature/signer.hh',
'source-accessor.hh',
'source-path.hh',
'split.hh',
'std-hash.hh',
'strings.hh',
'strings-inline.hh',
'suggestions.hh',
'sync.hh',
'tarfile.hh',
'terminal.hh',
'thread-pool.hh',
'topo-sort.hh',
'types.hh',
'unix-domain-socket.hh',
'url-parts.hh',
'url.hh',
'users.hh',
'util.hh',
'variant-wrapper.hh',
'xml-writer.hh',
)

View file

@ -1,16 +1,16 @@
#pragma once
///@file
#include "file-descriptor.hh"
#include "nix/file-descriptor.hh"
#ifdef _WIN32
# include "windows-async-pipe.hh"
# include "nix/windows-async-pipe.hh"
#endif
#ifndef _WIN32
# include <poll.h>
#else
# include <ioapiset.h>
# include "windows-error.hh"
# include "nix/windows-error.hh"
#endif
namespace nix {

View file

@ -7,8 +7,8 @@
#include <memory>
#include <cassert>
#include "sync.hh"
#include "ref.hh"
#include "nix/sync.hh"
#include "nix/ref.hh"
namespace nix {

View file

@ -4,9 +4,9 @@
#include <cstdint>
#include <vector>
#include "pos-idx.hh"
#include "position.hh"
#include "sync.hh"
#include "nix/pos-idx.hh"
#include "nix/position.hh"
#include "nix/sync.hh"
namespace nix {

View file

@ -9,7 +9,7 @@
#include <string>
#include <variant>
#include "source-path.hh"
#include "nix/source-path.hh"
namespace nix {

View file

@ -1,6 +1,6 @@
#pragma once
#include "source-accessor.hh"
#include "nix/source-accessor.hh"
namespace nix {

View file

@ -1,11 +1,11 @@
#pragma once
///@file
#include "types.hh"
#include "error.hh"
#include "file-descriptor.hh"
#include "logging.hh"
#include "ansicolor.hh"
#include "nix/types.hh"
#include "nix/error.hh"
#include "nix/file-descriptor.hh"
#include "nix/logging.hh"
#include "nix/ansicolor.hh"
#include <sys/types.h>
#include <sys/stat.h>

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "hash.hh"
#include "nix/hash.hh"
namespace nix {

View file

@ -4,9 +4,9 @@
#include <memory>
#include <type_traits>
#include "types.hh"
#include "util.hh"
#include "file-descriptor.hh"
#include "nix/types.hh"
#include "nix/util.hh"
#include "nix/file-descriptor.hh"
namespace boost::context { struct stack_context; }

View file

@ -1,9 +1,9 @@
#pragma once
///@file
#include "types.hh"
#include "error.hh"
#include "logging.hh"
#include "nix/types.hh"
#include "nix/error.hh"
#include "nix/logging.hh"
#include <functional>
@ -62,4 +62,4 @@ struct ReceiveInterrupts;
}
#include "signals-impl.hh"
#include "nix/signals-impl.hh"

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "types.hh"
#include "nix/types.hh"
#include <map>

View file

@ -1,7 +1,7 @@
#pragma once
#include "types.hh"
#include "signature/local-keys.hh"
#include "nix/types.hh"
#include "nix/signature/local-keys.hh"
#include <map>
#include <optional>

View file

@ -2,9 +2,9 @@
#include <filesystem>
#include "canon-path.hh"
#include "hash.hh"
#include "ref.hh"
#include "nix/canon-path.hh"
#include "nix/hash.hh"
#include "nix/ref.hh"
namespace nix {

View file

@ -5,10 +5,10 @@
* @brief SourcePath
*/
#include "ref.hh"
#include "canon-path.hh"
#include "source-accessor.hh"
#include "std-hash.hh"
#include "nix/ref.hh"
#include "nix/canon-path.hh"
#include "nix/source-accessor.hh"
#include "nix/std-hash.hh"
namespace nix {

View file

@ -4,7 +4,7 @@
#include <optional>
#include <string_view>
#include "util.hh"
#include "nix/util.hh"
namespace nix {

View file

@ -1,6 +1,6 @@
#pragma once
#include "strings.hh"
#include "nix/strings.hh"
namespace nix {

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "types.hh"
#include "nix/types.hh"
#include <set>
namespace nix {

View file

@ -7,7 +7,7 @@
#include <condition_variable>
#include <cassert>
#include "error.hh"
#include "nix/error.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#pragma once
///@file
#include "serialise.hh"
#include "fs-sink.hh"
#include "nix/serialise.hh"
#include "nix/fs-sink.hh"
#include <archive.h>
namespace nix {

View file

@ -1,8 +1,8 @@
#pragma once
///@file
#include "error.hh"
#include "sync.hh"
#include "nix/error.hh"
#include "nix/sync.hh"
#include <queue>
#include <functional>

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "error.hh"
#include "nix/error.hh"
namespace nix {

View file

@ -1,8 +1,8 @@
#pragma once
///@file
#include "types.hh"
#include "file-descriptor.hh"
#include "nix/types.hh"
#include "nix/file-descriptor.hh"
#ifdef _WIN32
# include <winsock2.h>

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "error.hh"
#include "nix/error.hh"
namespace nix {

View file

@ -1,7 +1,7 @@
#pragma once
///@file
#include "types.hh"
#include "nix/types.hh"
#ifndef _WIN32
# include <sys/types.h>

View file

@ -1,9 +1,9 @@
#pragma once
///@file
#include "types.hh"
#include "error.hh"
#include "logging.hh"
#include "nix/types.hh"
#include "nix/error.hh"
#include "nix/logging.hh"
#include <functional>
@ -11,7 +11,7 @@
#include <sstream>
#include <optional>
#include "strings.hh"
#include "nix/strings.hh"
namespace nix {

View file

@ -1,6 +1,6 @@
#include "json-utils.hh"
#include "error.hh"
#include "types.hh"
#include "nix/json-utils.hh"
#include "nix/error.hh"
#include "nix/types.hh"
#include <nlohmann/json_fwd.hpp>
#include <iostream>
#include <optional>

View file

@ -1,8 +1,8 @@
#include "cgroup.hh"
#include "signals.hh"
#include "util.hh"
#include "file-system.hh"
#include "finally.hh"
#include "nix/cgroup.hh"
#include "nix/signals.hh"
#include "nix/util.hh"
#include "nix/file-system.hh"
#include "nix/finally.hh"
#include <chrono>
#include <cmath>

Some files were not shown because too many files have changed in this diff Show more