Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganise include files #7847

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,6 @@ compile_commands.json
nix-rust/target

result
result-*

.vscode/
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([nix],[m4_esyscmd(bash -c "echo -n $(cat ./.version)$VERSION_SUFFIX")])
AC_INIT([nix],m4_esyscmd(bash -c "echo -n $(cat ./.version)$VERSION_SUFFIX"))
andreabedini marked this conversation as resolved.
Show resolved Hide resolved
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_SRCDIR(README.md)
AC_CONFIG_AUX_DIR(config)
Expand Down
7 changes: 3 additions & 4 deletions local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ clean-files += Makefile.config

GLOBAL_CXXFLAGS += -Wno-deprecated-declarations

$(foreach i, config.h $(wildcard src/lib*/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
$(eval $(call install-file-in, config.h, $(includedir)/nix, 0644))

$(GCH): src/libutil/util.hh config.h
$(GCH): src/libutil/include/nix/util/util.hh config.h

GCH_CXXFLAGS = -I src/libutil
GCH_CXXFLAGS = -Isrc/libutil/include/nix/util
2 changes: 1 addition & 1 deletion perl/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
makefiles = local.mk

GLOBAL_CXXFLAGS += -g -Wall -std=c++2a -I ../src
GLOBAL_CXXFLAGS += -g -Wall -std=c++2a

-include Makefile.config

Expand Down
12 changes: 6 additions & 6 deletions perl/lib/Nix/Store.xs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "config.h"
#include "nix/config.h"

#include "EXTERN.h"
#include "perl.h"
Expand All @@ -8,11 +8,11 @@
#undef do_open
#undef do_close

#include "derivations.hh"
#include "globals.hh"
#include "store-api.hh"
#include "util.hh"
#include "crypto.hh"
#include "nix/store/crypto.hh"
#include "nix/store/derivations.hh"
#include "nix/store/globals.hh"
#include "nix/store/store-api.hh"
#include "nix/util/util.hh"

#include <sodium.h>
#include <nlohmann/json.hpp>
Expand Down
22 changes: 11 additions & 11 deletions src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
#include <sys/time.h>
#endif

#include "machines.hh"
#include "shared.hh"
#include "pathlocks.hh"
#include "globals.hh"
#include "serialise.hh"
#include "build-result.hh"
#include "store-api.hh"
#include "derivations.hh"
#include "local-store.hh"
#include "legacy.hh"
#include "experimental-features.hh"
#include "nix/store/machines.hh"
#include "nix/main/shared.hh"
#include "nix/store/pathlocks.hh"
#include "nix/store/globals.hh"
#include "nix/util/serialise.hh"
#include "nix/store/build-result.hh"
#include "nix/store/store-api.hh"
#include "nix/store/derivations.hh"
#include "nix/store/local-store.hh"
#include "nix/cmd/legacy.hh"
#include "nix/util/experimental-features.hh"

using namespace nix;
using std::cin;
Expand Down
12 changes: 6 additions & 6 deletions src/libcmd/command.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "command.hh"
#include "store-api.hh"
#include "local-fs-store.hh"
#include "derivations.hh"
#include "nixexpr.hh"
#include "profiles.hh"
#include "nix/cmd/command.hh"
#include "nix/store/store-api.hh"
#include "nix/store/local-fs-store.hh"
#include "nix/store/derivations.hh"
#include "nix/expr/nixexpr.hh"
#include "nix/store/profiles.hh"

#include <nlohmann/json.hpp>

Expand Down
20 changes: 10 additions & 10 deletions src/libcmd/common-eval-args.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "common-eval-args.hh"
#include "shared.hh"
#include "filetransfer.hh"
#include "util.hh"
#include "eval.hh"
#include "fetchers.hh"
#include "registry.hh"
#include "flake/flakeref.hh"
#include "store-api.hh"
#include "command.hh"
#include "nix/cmd/common-eval-args.hh"
#include "nix/main/shared.hh"
#include "nix/store/filetransfer.hh"
#include "nix/util/util.hh"
#include "nix/expr/eval.hh"
#include "nix/fetchers/fetchers.hh"
#include "nix/fetchers/registry.hh"
#include "nix/expr/flake/flakeref.hh"
#include "nix/store/store-api.hh"
#include "nix/cmd/command.hh"

namespace nix {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include "installables.hh"
#include "args.hh"
#include "common-eval-args.hh"
#include "path.hh"
#include "flake/lockfile.hh"
#include "nix/cmd/installables.hh"
#include "nix/util/args.hh"
#include "nix/cmd/common-eval-args.hh"
#include "nix/store/path.hh"
#include "nix/expr/flake/lockfile.hh"

#include <optional>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "args.hh"
#include "nix/util/args.hh"

namespace nix {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "installables.hh"
#include "nix/cmd/installables.hh"

namespace nix {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "util.hh"
#include "path.hh"
#include "outputs-spec.hh"
#include "derived-path.hh"
#include "eval.hh"
#include "store-api.hh"
#include "flake/flake.hh"
#include "build-result.hh"
#include "nix/util/util.hh"
#include "nix/store/path.hh"
#include "nix/store/outputs-spec.hh"
#include "nix/store/derived-path.hh"
#include "nix/expr/eval.hh"
#include "nix/store/store-api.hh"
#include "nix/expr/flake/flake.hh"
#include "nix/store/build-result.hh"

#include <optional>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "types.hh"
#include "nix/util/types.hh"

namespace nix {

Expand Down
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/command.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/command.hh is deprecated. Include nix/cmd/command.hh instead."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to generate these files on-the-fly rather than checking them out?

(they aren't big nor anything, but I imagine them being a bit confusing and very annoying when browsing the codebase with a fuzzy-finder)

Copy link
Member

@Ericson2314 Ericson2314 Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't think these stub files are worth the trouble. It's not too hard to do the bulk rename with a small script to see which library it was moved to. This stuff is explicitly unstable/internal, so breakage is not so much of an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a maintainer of a package that uses the headers headers, I will have to add a version check conditional around my imports anyway.

Automating this guidance is probably not worth the effort for our limited ecosystem of library consumers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the consensus, I am happy to remove the shims. @roberth do you see any way we can make the transition easier for downstream consumers?

I think the worst part is figuring out where each include file went, and the shims addressed this by mentioning the location of the new file. I could make a awk script to migrate to the new locations but it won't help if you need to support both.

#include "nix/cmd/command.hh"
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/common-eval-args.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/common-eval-args.hh is deprecated. Include nix/cmd/common-eval-args.hh instead."
#include "nix/cmd/common-eval-args.hh"
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/installable-derived-path.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/installable-derived-path.hh is deprecated. Include nix/cmd/installable-derived-path.hh instead."
#include "nix/cmd/installable-derived-path.hh"
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/installables.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/installables.hh is deprecated. Include nix/cmd/installables.hh instead."
#include "nix/cmd/installables.hh"
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/legacy.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/legacy.hh is deprecated. Include nix/cmd/legacy.hh instead."
#include "nix/cmd/legacy.hh"
2 changes: 2 additions & 0 deletions src/libcmd/include/nix/markdown.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#warning "Including nix/markdown.hh is deprecated. Include nix/cmd/markdown.hh instead."
#include "nix/cmd/markdown.hh"
4 changes: 2 additions & 2 deletions src/libcmd/installable-derived-path.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "installable-derived-path.hh"
#include "derivations.hh"
#include "nix/cmd/installable-derived-path.hh"
#include "nix/store/derivations.hh"

namespace nix {

Expand Down
38 changes: 19 additions & 19 deletions src/libcmd/installables.cc
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#include "globals.hh"
#include "installables.hh"
#include "installable-derived-path.hh"
#include "outputs-spec.hh"
#include "util.hh"
#include "command.hh"
#include "attr-path.hh"
#include "common-eval-args.hh"
#include "derivations.hh"
#include "eval-inline.hh"
#include "eval.hh"
#include "get-drvs.hh"
#include "store-api.hh"
#include "shared.hh"
#include "flake/flake.hh"
#include "eval-cache.hh"
#include "url.hh"
#include "registry.hh"
#include "build-result.hh"
#include "nix/store/globals.hh"
#include "nix/cmd/installables.hh"
#include "nix/cmd/installable-derived-path.hh"
#include "nix/store/outputs-spec.hh"
#include "nix/util/util.hh"
#include "nix/cmd/command.hh"
#include "nix/expr/attr-path.hh"
#include "nix/cmd/common-eval-args.hh"
#include "nix/store/derivations.hh"
#include "nix/expr/eval-inline.hh"
#include "nix/expr/eval.hh"
#include "nix/expr/get-drvs.hh"
#include "nix/store/store-api.hh"
#include "nix/main/shared.hh"
#include "nix/expr/flake/flake.hh"
#include "nix/expr/eval-cache.hh"
#include "nix/util/url.hh"
#include "nix/fetchers/registry.hh"
#include "nix/store/build-result.hh"

#include <regex>
#include <queue>
Expand Down
2 changes: 1 addition & 1 deletion src/libcmd/legacy.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "legacy.hh"
#include "nix/cmd/legacy.hh"

namespace nix {

Expand Down
19 changes: 18 additions & 1 deletion src/libcmd/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ libcmd_DIR := $(d)

libcmd_SOURCES := $(wildcard $(d)/*.cc)

libcmd_CXXFLAGS += -I src/libutil -I src/libstore -I src/libexpr -I src/libmain -I src/libfetchers -I src/nix
libcmd_CXXFLAGS += \
-Isrc/libcmd/include \
-Isrc/libexpr/include \
-Isrc/libfetchers/include \
-Isrc/libmain/include \
-Isrc/libstore/include \
-Isrc/libutil/include \
-Isrc/nix

libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) -pthread

libcmd_LIBS = libstore libutil libexpr libmain libfetchers

$(eval $(call install-file-in, $(d)/nix-cmd.pc, $(libdir)/pkgconfig, 0644))

# old include paths

$(foreach i, $(wildcard src/libcmd/include/nix/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))

# new include paths

$(foreach i, $(wildcard src/libcmd/include/nix/cmd/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/cmd, 0644)))
6 changes: 3 additions & 3 deletions src/libcmd/markdown.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "markdown.hh"
#include "util.hh"
#include "finally.hh"
#include "nix/cmd/markdown.hh"
#include "nix/util/util.hh"
#include "nix/util/finally.hh"

#include <sys/queue.h>
#include <lowdown.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libcmd/nix-cmd.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Name: Nix
Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lnixcmd
Cflags: -I${includedir}/nix -std=c++2a
Cflags: -I${includedir} -std=c++2a
34 changes: 17 additions & 17 deletions src/libcmd/repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ extern "C" {
}
#endif

#include "ansicolor.hh"
#include "shared.hh"
#include "eval.hh"
#include "eval-cache.hh"
#include "eval-inline.hh"
#include "attr-path.hh"
#include "store-api.hh"
#include "log-store.hh"
#include "common-eval-args.hh"
#include "get-drvs.hh"
#include "derivations.hh"
#include "globals.hh"
#include "command.hh"
#include "finally.hh"
#include "markdown.hh"
#include "local-fs-store.hh"
#include "progress-bar.hh"
#include "nix/util/ansicolor.hh"
#include "nix/main/shared.hh"
#include "nix/expr/eval.hh"
#include "nix/expr/eval-cache.hh"
#include "nix/expr/eval-inline.hh"
#include "nix/expr/attr-path.hh"
#include "nix/store/store-api.hh"
#include "nix/store/log-store.hh"
#include "nix/cmd/common-eval-args.hh"
#include "nix/expr/get-drvs.hh"
#include "nix/store/derivations.hh"
#include "nix/store/globals.hh"
#include "nix/cmd/command.hh"
#include "nix/util/finally.hh"
#include "nix/cmd/markdown.hh"
#include "nix/store/local-fs-store.hh"
#include "nix/main/progress-bar.hh"

#if HAVE_BOEHMGC
#define GC_INCLUDE_NEW
Expand Down
6 changes: 3 additions & 3 deletions src/libexpr/attr-path.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "attr-path.hh"
#include "eval-inline.hh"
#include "util.hh"
#include "nix/expr/attr-path.hh"
#include "nix/expr/eval-inline.hh"
#include "nix/util/util.hh"


namespace nix {
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/attr-set.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "attr-set.hh"
#include "eval-inline.hh"
#include "nix/expr/attr-set.hh"
#include "nix/expr/eval-inline.hh"

#include <algorithm>

Expand Down
10 changes: 5 additions & 5 deletions src/libexpr/eval-cache.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "eval-cache.hh"
#include "sqlite.hh"
#include "eval.hh"
#include "eval-inline.hh"
#include "store-api.hh"
#include "nix/expr/eval-cache.hh"
#include "nix/store/sqlite.hh"
#include "nix/expr/eval.hh"
#include "nix/expr/eval-inline.hh"
#include "nix/store/store-api.hh"

namespace nix::eval_cache {

Expand Down
Loading