From 83a2cd0c469f02a7d5f8f8f903429702f0059f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikodem=20Rabuli=C5=84ski?= Date: Mon, 6 May 2024 18:13:15 +0200 Subject: [PATCH 1/5] Fix failing darwin tests Some tests were failing on darwin, if the auto-allocate-uids featrure was enabled. This was because AAU on darwin works by setuid-ing as a non-existent user, so the tests that were relying on `whoami` were failing. In the case of trusted-users we fall back to printing the user id, which is already handled gracefully in the daemon code - i.e. when a user does not exist or for some other reason looking up their username is not possible, the daemon falls back to searching for their uid inside the trusted-users list. When whoami is used to print the username for other purpose, we default to printing nixbld. Change-Id: Ib61615677565098cb5fbf5e26a946ef427c58caf --- tests/functional/bash-profile.sh | 2 +- tests/functional/init.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/bash-profile.sh b/tests/functional/bash-profile.sh index 3faeaaba1..01e869202 100644 --- a/tests/functional/bash-profile.sh +++ b/tests/functional/bash-profile.sh @@ -2,7 +2,7 @@ source common.sh sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > $TEST_ROOT/nix-profile.sh -user=$(whoami) +user=$(whoami || echo -n nixbld) rm -rf $TEST_HOME $TEST_ROOT/profile-var mkdir -p $TEST_HOME USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set" diff --git a/tests/functional/init.sh b/tests/functional/init.sh index f5a04f62e..663d04721 100755 --- a/tests/functional/init.sh +++ b/tests/functional/init.sh @@ -28,7 +28,7 @@ substituters = flake-registry = $TEST_ROOT/registry.json show-trace = true include nix.conf.extra -trusted-users = $(whoami) +trusted-users = $(whoami || id -u) EOF cat > "$NIX_CONF_DIR"/nix.conf.extra < Date: Mon, 6 May 2024 18:16:50 +0200 Subject: [PATCH 2/5] Always initialize curl in parent process on darwin Because of an objc quirk[1], calling curl_global_init for the first time after fork() will always result in a crash. Up until now the solution has been to set OBJC_DISABLE_INITIALIZE_FORK_SAFETY for every nix process to ignore that error. This is less than ideal because we were setting it in package.nix, which meant that running nix tests locally would fail because that variable was not set. Instead of working around that error we address it at the core - by calling curl_global_init inside initLibStore, which should mean curl will already have been initialized by the time we try to do so in a forked process. [1] https://github.com/apple-oss-distributions/objc4/blob/01edf1705fbc3ff78a423cd21e03dfc21eb4d780/runtime/objc-initialize.mm#L614-L636 Change-Id: Icf26010a8be655127cc130efb9c77b603a6660d0 --- misc/launchd/org.nixos.nix-daemon.plist.in | 5 ----- package.nix | 4 ---- src/libstore/globals.cc | 14 +++++++++++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/misc/launchd/org.nixos.nix-daemon.plist.in b/misc/launchd/org.nixos.nix-daemon.plist.in index e1470cf99..664608305 100644 --- a/misc/launchd/org.nixos.nix-daemon.plist.in +++ b/misc/launchd/org.nixos.nix-daemon.plist.in @@ -2,11 +2,6 @@ - EnvironmentVariables - - OBJC_DISABLE_INITIALIZE_FORK_SAFETY - YES - Label org.nixos.nix-daemon KeepAlive diff --git a/package.nix b/package.nix index 455e21135..af0a44fee 100644 --- a/package.nix +++ b/package.nix @@ -400,10 +400,6 @@ stdenv.mkDerivation (finalAttrs: { mesonInstallCheckFlags = [ "--suite=installcheck" ]; - preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin '' - export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES - ''; - installCheckPhase = lib.optionalString buildWithMeson '' runHook preInstallCheck flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}") diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index b7397da1a..3308cad1f 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -25,6 +25,7 @@ #include "config-impl.hh" #ifdef __APPLE__ +#include #include #endif @@ -409,10 +410,21 @@ void initLibStore() { preloadNSS(); +#if __APPLE__ + /* Because of an objc quirk[1], calling curl_global_init for the first time + after fork() will always result in a crash. + Up until now the solution has been to set OBJC_DISABLE_INITIALIZE_FORK_SAFETY + for every nix process to ignore that error. + Instead of working around that error we address it at the core - + by calling curl_global_init here, which should mean curl will already + have been initialized by the time we try to do so in a forked process. + + [1] https://github.com/apple-oss-distributions/objc4/blob/01edf1705fbc3ff78a423cd21e03dfc21eb4d780/runtime/objc-initialize.mm#L614-L636 + */ + curl_global_init(CURL_GLOBAL_ALL); /* On macOS, don't use the per-session TMPDIR (as set e.g. by sshd). This breaks build users because they don't have access to the TMPDIR, in particular in ‘nix-store --serve’. */ -#if __APPLE__ if (getEnv("TMPDIR").value_or("/tmp").starts_with("/var/folders/")) unsetenv("TMPDIR"); #endif From 3b923388fa699071cedc775df5ebf913329b8bb1 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Tue, 7 May 2024 13:34:36 -0600 Subject: [PATCH 3/5] remove the autoconf+Make buildsystem We're not using it anymore. Any leftover bugs in the Meson buildsystem are now just bugs. Closes #249. Change-Id: I0465a0c37ae819f94d40e7829f5bff046aa63d73 --- Makefile | 71 -- Makefile.config.in | 52 - configure.ac | 396 -------- doc/internal-api/local.mk | 19 - doc/manual/local.mk | 178 ---- flake.nix | 7 - local.mk | 17 - m4/ax_cxx_compile_stdcxx.m4 | 951 ------------------ m4/ax_cxx_compile_stdcxx_17.m4 | 35 - m4/gcc_bug_80431.m4 | 64 -- misc/bash/local.mk | 1 - misc/fish/local.mk | 1 - misc/launchd/local.mk | 5 - misc/systemd/local.mk | 8 - misc/zsh/local.mk | 2 - mk/build-dir.mk | 10 - mk/clean.mk | 11 - mk/common-test.sh | 15 - mk/cxx-big-literal.mk | 5 - mk/debug-test.sh | 11 - mk/disable-tests.mk | 12 - mk/functions.mk | 14 - mk/install-dirs.mk | 11 - mk/install.mk | 62 -- mk/lib.mk | 168 ---- mk/libraries.mk | 161 --- mk/patterns.mk | 11 - mk/precompiled-headers.mk | 21 - mk/programs.mk | 95 -- mk/run-test.sh | 38 - mk/templates.mk | 19 - mk/tests.mk | 27 - mk/tracing.mk | 16 - package.nix | 86 +- perl/Makefile | 21 - perl/Makefile.config.in | 18 - perl/default.nix | 41 +- perl/local.mk | 43 - scripts/local.mk | 13 - src/libcmd/local.mk | 17 - src/libexpr/local.mk | 50 - src/libfetchers/local.mk | 13 - src/libmain/local.mk | 17 - src/libstore/local.mk | 75 -- src/libutil/local.mk | 18 - src/nix/local.mk | 40 - src/resolve-system-dependencies/local.mk | 13 - tests/functional/ca/local.mk | 29 - tests/functional/dyn-drv/local.mk | 15 - tests/functional/local.mk | 156 --- tests/functional/plugins/local.mk | 27 - .../functional/repl_characterization/local.mk | 15 - .../functional/test-libstoreconsumer/local.mk | 15 - tests/unit/libexpr-support/local.mk | 19 - tests/unit/libexpr/local.mk | 32 - tests/unit/libstore-support/local.mk | 17 - tests/unit/libstore/local.mk | 27 - tests/unit/libutil-support/local.mk | 16 - tests/unit/libutil/local.mk | 23 - 59 files changed, 32 insertions(+), 3338 deletions(-) delete mode 100644 Makefile delete mode 100644 Makefile.config.in delete mode 100644 configure.ac delete mode 100644 doc/internal-api/local.mk delete mode 100644 doc/manual/local.mk delete mode 100644 local.mk delete mode 100644 m4/ax_cxx_compile_stdcxx.m4 delete mode 100644 m4/ax_cxx_compile_stdcxx_17.m4 delete mode 100644 m4/gcc_bug_80431.m4 delete mode 100644 misc/bash/local.mk delete mode 100644 misc/fish/local.mk delete mode 100644 misc/launchd/local.mk delete mode 100644 misc/systemd/local.mk delete mode 100644 misc/zsh/local.mk delete mode 100644 mk/build-dir.mk delete mode 100644 mk/clean.mk delete mode 100644 mk/common-test.sh delete mode 100644 mk/cxx-big-literal.mk delete mode 100755 mk/debug-test.sh delete mode 100644 mk/disable-tests.mk delete mode 100644 mk/functions.mk delete mode 100644 mk/install-dirs.mk delete mode 100644 mk/install.mk delete mode 100644 mk/lib.mk delete mode 100644 mk/libraries.mk delete mode 100644 mk/patterns.mk delete mode 100644 mk/precompiled-headers.mk delete mode 100644 mk/programs.mk delete mode 100755 mk/run-test.sh delete mode 100644 mk/templates.mk delete mode 100644 mk/tests.mk delete mode 100644 mk/tracing.mk delete mode 100644 perl/Makefile delete mode 100644 perl/Makefile.config.in delete mode 100644 perl/local.mk delete mode 100644 scripts/local.mk delete mode 100644 src/libcmd/local.mk delete mode 100644 src/libexpr/local.mk delete mode 100644 src/libfetchers/local.mk delete mode 100644 src/libmain/local.mk delete mode 100644 src/libstore/local.mk delete mode 100644 src/libutil/local.mk delete mode 100644 src/nix/local.mk delete mode 100644 src/resolve-system-dependencies/local.mk delete mode 100644 tests/functional/ca/local.mk delete mode 100644 tests/functional/dyn-drv/local.mk delete mode 100644 tests/functional/local.mk delete mode 100644 tests/functional/plugins/local.mk delete mode 100644 tests/functional/repl_characterization/local.mk delete mode 100644 tests/functional/test-libstoreconsumer/local.mk delete mode 100644 tests/unit/libexpr-support/local.mk delete mode 100644 tests/unit/libexpr/local.mk delete mode 100644 tests/unit/libstore-support/local.mk delete mode 100644 tests/unit/libstore/local.mk delete mode 100644 tests/unit/libutil-support/local.mk delete mode 100644 tests/unit/libutil/local.mk diff --git a/Makefile b/Makefile deleted file mode 100644 index bb1b82bb1..000000000 --- a/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -include mk/build-dir.mk - --include $(buildprefix)Makefile.config -clean-files += $(buildprefix)Makefile.config - -ifeq ($(ENABLE_BUILD), yes) -makefiles = \ - mk/precompiled-headers.mk \ - local.mk \ - src/libutil/local.mk \ - src/libstore/local.mk \ - src/libfetchers/local.mk \ - src/libmain/local.mk \ - src/libexpr/local.mk \ - src/libcmd/local.mk \ - src/nix/local.mk \ - src/resolve-system-dependencies/local.mk \ - scripts/local.mk \ - misc/bash/local.mk \ - misc/fish/local.mk \ - misc/zsh/local.mk \ - misc/systemd/local.mk \ - misc/launchd/local.mk -endif - -ifeq ($(ENABLE_BUILD)_$(ENABLE_TESTS), yes_yes) -UNIT_TEST_ENV = _NIX_TEST_UNIT_DATA=unit-test-data -makefiles += \ - tests/unit/libutil/local.mk \ - tests/unit/libutil-support/local.mk \ - tests/unit/libstore/local.mk -endif - -ifeq ($(ENABLE_TESTS), yes) -makefiles += \ - tests/unit/libstore-support/local.mk \ - tests/unit/libexpr/local.mk \ - tests/unit/libexpr-support/local.mk \ - tests/functional/local.mk \ - tests/functional/ca/local.mk \ - tests/functional/dyn-drv/local.mk \ - tests/functional/test-libstoreconsumer/local.mk \ - tests/functional/repl_characterization/local.mk \ - tests/functional/plugins/local.mk -else -makefiles += \ - mk/disable-tests.mk -endif - -# Some makefiles require access to built programs and must be included late. -makefiles-late = - -ifeq ($(ENABLE_BUILD), yes) -makefiles-late += doc/manual/local.mk -makefiles-late += doc/internal-api/local.mk -endif - -# Miscellaneous global Flags - -OPTIMIZE = 1 - -ifeq ($(OPTIMIZE), 1) - GLOBAL_CXXFLAGS += -O2 $(CXXLTO) - GLOBAL_LDFLAGS += $(CXXLTO) -else - GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE -endif - -include mk/lib.mk - -GLOBAL_CXXFLAGS += -g -Wall -Wimplicit-fallthrough -include $(buildprefix)config.h -std=c++2a -I src diff --git a/Makefile.config.in b/Makefile.config.in deleted file mode 100644 index 7367d0a3f..000000000 --- a/Makefile.config.in +++ /dev/null @@ -1,52 +0,0 @@ -AR = @AR@ -BDW_GC_LIBS = @BDW_GC_LIBS@ -BOOST_LDFLAGS = @BOOST_LDFLAGS@ -BUILD_SHARED_LIBS = @BUILD_SHARED_LIBS@ -CC = @CC@ -CFLAGS = @CFLAGS@ -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -CXXLTO = @CXXLTO@ -EDITLINE_LIBS = @EDITLINE_LIBS@ -ENABLE_S3 = @ENABLE_S3@ -GTEST_LIBS = @GTEST_LIBS@ -HAVE_LIBCPUID = @HAVE_LIBCPUID@ -HAVE_SECCOMP = @HAVE_SECCOMP@ -HOST_OS = @host_os@ -LDFLAGS = @LDFLAGS@ -LIBARCHIVE_LIBS = @LIBARCHIVE_LIBS@ -LIBBROTLI_LIBS = @LIBBROTLI_LIBS@ -LIBCURL_LIBS = @LIBCURL_LIBS@ -LIBSECCOMP_LIBS = @LIBSECCOMP_LIBS@ -LOWDOWN_LIBS = @LOWDOWN_LIBS@ -NIXDOC_LIBS = -llix_doc -OPENSSL_LIBS = @OPENSSL_LIBS@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -RAPIDCHECK_HEADERS = @RAPIDCHECK_HEADERS@ -SHELL = @bash@ -SODIUM_LIBS = @SODIUM_LIBS@ -SQLITE3_LIBS = @SQLITE3_LIBS@ -bash = @bash@ -bindir = @bindir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -doc_generate = @doc_generate@ -docdir = @docdir@ -embedded_sandbox_shell = @embedded_sandbox_shell@ -exec_prefix = @exec_prefix@ -includedir = @includedir@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -lsof = @lsof@ -mandir = @mandir@ -pkglibdir = $(libdir)/$(PACKAGE_NAME) -prefix = @prefix@ -sandbox_shell = @sandbox_shell@ -storedir = @storedir@ -sysconfdir = @sysconfdir@ -system = @system@ -ENABLE_BUILD = @ENABLE_BUILD@ -ENABLE_TESTS = @ENABLE_TESTS@ -internal_api_docs = @internal_api_docs@ diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 12a5873cf..000000000 --- a/configure.ac +++ /dev/null @@ -1,396 +0,0 @@ -AC_INIT([nix],[m4_esyscmd(bash -c "echo -n $(cat ./.version)$VERSION_SUFFIX")]) -AC_CONFIG_MACRO_DIRS([m4]) -AC_CONFIG_SRCDIR(README.md) -AC_CONFIG_AUX_DIR(config) - -AC_PROG_SED - -# Construct a Nix system name (like "i686-linux"): -# https://www.gnu.org/software/autoconf/manual/html_node/Canonicalizing.html#index-AC_005fCANONICAL_005fHOST-1 -# The inital value is produced by the `config/config.guess` script: -# upstream: https://git.savannah.gnu.org/cgit/config.git/tree/config.guess -# It has the following form, which is not documented anywhere: -# --[][-] -# If `./configure` is passed any of the `--host`, `--build`, `--target` options, the value comes from `config/config.sub` instead: -# upstream: https://git.savannah.gnu.org/cgit/config.git/tree/config.sub -AC_CANONICAL_HOST -AC_MSG_CHECKING([for the canonical Nix system name]) - -AC_ARG_WITH(system, AS_HELP_STRING([--with-system=SYSTEM],[Platform identifier (e.g., `i686-linux').]), - [system=$withval], - [case "$host_cpu" in - i*86) - machine_name="i686";; - amd64) - machine_name="x86_64";; - armv6|armv7) - machine_name="${host_cpu}l";; - *) - machine_name="$host_cpu";; - esac - - case "$host_os" in - linux-gnu*|linux-musl*) - # For backward compatibility, strip the `-gnu' part. - system="$machine_name-linux";; - *) - # Strip the version number from names such as `gnu0.3', - # `darwin10.2.0', etc. - system="$machine_name-`echo $host_os | "$SED" -e's/@<:@0-9.@:>@*$//g'`";; - esac]) - -AC_MSG_RESULT($system) -AC_SUBST(system) -AC_DEFINE_UNQUOTED(SYSTEM, ["$system"], [platform identifier ('cpu-os')]) - - -# State should be stored in /nix/var, unless the user overrides it explicitly. -test "$localstatedir" = '${prefix}/var' && localstatedir=/nix/var - -# Assign a default value to C{,XX}FLAGS as the default configure script sets them -# to -O2 otherwise, which we don't want to have hardcoded -CFLAGS=${CFLAGS-""} -CXXFLAGS=${CXXFLAGS-""} - -AC_PROG_CC -AC_PROG_CXX -AC_PROG_CPP - -AC_CHECK_TOOL([AR], [ar]) - -# Use 64-bit file system calls so that we can support files > 2 GiB. -AC_SYS_LARGEFILE - - -# Solaris-specific stuff. -AC_STRUCT_DIRENT_D_TYPE -case "$host_os" in - solaris*) - # Solaris requires -lsocket -lnsl for network functions - LDFLAGS="-lsocket -lnsl $LDFLAGS" - ;; -esac - - -ENSURE_NO_GCC_BUG_80431 - - -# Check for pubsetbuf. -AC_MSG_CHECKING([for pubsetbuf]) -AC_LANG_PUSH(C++) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -using namespace std; -static char buf[1024];]], - [[cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));]])], - [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PUBSETBUF, 1, [Whether pubsetbuf is available.])], - AC_MSG_RESULT(no)) -AC_LANG_POP(C++) - - -AC_CHECK_FUNCS([statvfs pipe2]) - - -# Check for lutimes, optionally used for changing the mtime of -# symlinks. -AC_CHECK_FUNCS([lutimes]) - - -# Check whether the store optimiser can optimise symlinks. -AC_MSG_CHECKING([whether it is possible to create a link to a symlink]) -ln -s bla tmp_link -if ln tmp_link tmp_link2 2> /dev/null; then - AC_MSG_RESULT(yes) - AC_DEFINE(CAN_LINK_SYMLINK, 1, [Whether link() works on symlinks.]) -else - AC_MSG_RESULT(no) -fi -rm -f tmp_link tmp_link2 - - -# Check for . -AC_LANG_PUSH(C++) -AC_CHECK_HEADERS([locale]) -AC_LANG_POP(C++) - - -AC_DEFUN([NEED_PROG], -[ -AC_PATH_PROG($1, $2) -if test -z "$$1"; then - AC_MSG_ERROR([$2 is required]) -fi -]) - -NEED_PROG(bash, bash) -AC_PATH_PROG(flex, flex, false) -AC_PATH_PROG(bison, bison, false) -AC_PATH_PROG(dot, dot) -AC_PATH_PROG(lsof, lsof, lsof) -NEED_PROG(jq, jq) - - -AC_SUBST(coreutils, [$(dirname $(type -p cat))]) - - -AC_ARG_WITH(store-dir, AS_HELP_STRING([--with-store-dir=PATH],[path of the Nix store (defaults to /nix/store)]), - storedir=$withval, storedir='/nix/store') -AC_SUBST(storedir) - - -# Look for boost, a required dependency. -# Note that AX_BOOST_BASE only exports *CPP* BOOST_CPPFLAGS, no CXX flags, -# and CPPFLAGS are not passed to the C++ compiler automatically. -# Thus we append the returned CPPFLAGS to the CXXFLAGS here. -AX_BOOST_BASE([1.66], [CXXFLAGS="$BOOST_CPPFLAGS $CXXFLAGS"], [AC_MSG_ERROR([Nix requires boost.])]) -# For unknown reasons, setting this directly in the ACTION-IF-FOUND above -# ends up with LDFLAGS being empty, so we set it afterwards. -LDFLAGS="$BOOST_LDFLAGS $LDFLAGS" - -# On some platforms, new-style atomics need a helper library -AC_MSG_CHECKING(whether -latomic is needed) -AC_LINK_IFELSE([AC_LANG_SOURCE([[ -#include -uint64_t v; -int main() { - return (int)__atomic_load_n(&v, __ATOMIC_ACQUIRE); -}]])], GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=no, GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=yes) -AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC) -if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then - LDFLAGS="-latomic $LDFLAGS" -fi - -# Running the functional tests without building Nix is useful for testing -# different pre-built versions of Nix against each other. -AC_ARG_ENABLE(build, AS_HELP_STRING([--disable-build],[Do not build nix]), - ENABLE_BUILD=$enableval, ENABLE_BUILD=yes) -AC_SUBST(ENABLE_BUILD) -# Building without tests is useful for bootstrapping with a smaller footprint -# or running the tests in a separate derivation. Otherwise, we do compile and -# run them. -AC_ARG_ENABLE(tests, AS_HELP_STRING([--disable-tests],[Do not build the tests]), - ENABLE_TESTS=$enableval, ENABLE_TESTS=yes) -AC_SUBST(ENABLE_TESTS) - -# Building without API docs is the default as Nix' C++ interfaces are internal and unstable. -AC_ARG_ENABLE(internal_api_docs, AS_HELP_STRING([--enable-internal-api-docs],[Build API docs for Nix's internal unstable C++ interfaces]), - internal_api_docs=$enableval, internal_api_docs=no) -AC_SUBST(internal_api_docs) - -# LTO is currently broken with clang for unknown reasons; ld segfaults in the llvm plugin -AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto],[Enable LTO (only supported with GCC) [default=no]]), - lto=$enableval, lto=no) -if test "$lto" = yes; then - if $CXX --version | grep -q GCC; then - AC_SUBST(CXXLTO, [-flto=jobserver]) - else - echo "error: LTO is only supported with GCC at the moment" >&2 - exit 1 - fi -else - AC_SUBST(CXXLTO, [""]) -fi - -PKG_PROG_PKG_CONFIG - -AC_ARG_ENABLE(shared, AS_HELP_STRING([--enable-shared],[Build shared libraries for Nix [default=yes]]), - shared=$enableval, shared=yes) -if test "$shared" = yes; then - AC_SUBST(BUILD_SHARED_LIBS, 1, [Whether to build shared libraries.]) -else - AC_SUBST(BUILD_SHARED_LIBS, 0, [Whether to build shared libraries.]) - PKG_CONFIG="$PKG_CONFIG --static" -fi - -# Look for OpenSSL, a required dependency. FIXME: this is only (maybe) -# used by S3BinaryCacheStore. -PKG_CHECK_MODULES([OPENSSL], [libcrypto >= 1.1.1], [CXXFLAGS="$OPENSSL_CFLAGS $CXXFLAGS"]) - - -# Look for libarchive. -PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.1.2], [CXXFLAGS="$LIBARCHIVE_CFLAGS $CXXFLAGS"]) -# Workaround until https://github.com/libarchive/libarchive/issues/1446 is fixed -if test "$shared" != yes; then - LIBARCHIVE_LIBS+=' -lz' -fi - -# Look for SQLite, a required dependency. -PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19], [CXXFLAGS="$SQLITE3_CFLAGS $CXXFLAGS"]) - -# Look for libcurl, a required dependency. -PKG_CHECK_MODULES([LIBCURL], [libcurl], [CXXFLAGS="$LIBCURL_CFLAGS $CXXFLAGS"]) - -# Look for editline, a required dependency. -# The the libeditline.pc file was added only in libeditline >= 1.15.2, -# see https://github.com/troglobit/editline/commit/0a8f2ef4203c3a4a4726b9dd1336869cd0da8607, -# but e.g. Ubuntu 16.04 has an older version, so we fall back to searching for -# editline.h when the pkg-config approach fails. -PKG_CHECK_MODULES([EDITLINE], [libeditline], [CXXFLAGS="$EDITLINE_CFLAGS $CXXFLAGS"], [ - AC_CHECK_HEADERS([editline.h], [true], - [AC_MSG_ERROR([Nix requires libeditline; it was found neither via pkg-config nor its normal header.])]) - AC_SEARCH_LIBS([readline read_history], [editline], [], - [AC_MSG_ERROR([Nix requires libeditline; it was not found via pkg-config, but via its header, but required functions do not work. Maybe it is too old? >= 1.14 is required.])]) -]) - -# Look for libsodium. -PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"]) - -# Look for libbrotli{enc,dec}. -PKG_CHECK_MODULES([LIBBROTLI], [libbrotlienc libbrotlidec], [CXXFLAGS="$LIBBROTLI_CFLAGS $CXXFLAGS"]) - -# Look for libcpuid. -have_libcpuid= -if test "$machine_name" = "x86_64"; then - AC_ARG_ENABLE([cpuid], - AS_HELP_STRING([--disable-cpuid], [Do not determine microarchitecture levels with libcpuid (relevant to x86_64 only)])) - if test "x$enable_cpuid" != "xno"; then - PKG_CHECK_MODULES([LIBCPUID], [libcpuid], - [CXXFLAGS="$LIBCPUID_CFLAGS $CXXFLAGS" - have_libcpuid=1 - AC_DEFINE([HAVE_LIBCPUID], [1], [Use libcpuid])] - ) - fi -fi -AC_SUBST(HAVE_LIBCPUID, [$have_libcpuid]) - - -# Look for libseccomp, required for Linux sandboxing. -case "$host_os" in - linux*) - AC_ARG_ENABLE([seccomp-sandboxing], - AS_HELP_STRING([--disable-seccomp-sandboxing],[Don't build support for seccomp sandboxing (only recommended if your arch doesn't support libseccomp yet!) - ])) - if test "x$enable_seccomp_sandboxing" != "xno"; then - PKG_CHECK_MODULES([LIBSECCOMP], [libseccomp], - [CXXFLAGS="$LIBSECCOMP_CFLAGS $CXXFLAGS"]) - have_seccomp=1 - AC_DEFINE([HAVE_SECCOMP], [1], [Whether seccomp is available and should be used for sandboxing.]) - else - have_seccomp= - fi - ;; - *) - have_seccomp= - ;; -esac -AC_SUBST(HAVE_SECCOMP, [$have_seccomp]) - - -# Look for aws-cpp-sdk-s3. -AC_LANG_PUSH(C++) -AC_CHECK_HEADERS([aws/s3/S3Client.h], - [AC_DEFINE([ENABLE_S3], [1], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=1], - [AC_DEFINE([ENABLE_S3], [0], [Whether to enable S3 support via aws-sdk-cpp.]) enable_s3=]) -AC_SUBST(ENABLE_S3, [$enable_s3]) -AC_LANG_POP(C++) - -if test -n "$enable_s3"; then - declare -a aws_version_tokens=($(printf '#include \nAWS_SDK_VERSION_STRING' | $CPP $CPPFLAGS - | grep -v '^#.*' | sed 's/"//g' | tr '.' ' ')) - AC_DEFINE_UNQUOTED([AWS_VERSION_MAJOR], ${aws_version_tokens@<:@0@:>@}, [Major version of aws-sdk-cpp.]) - AC_DEFINE_UNQUOTED([AWS_VERSION_MINOR], ${aws_version_tokens@<:@1@:>@}, [Minor version of aws-sdk-cpp.]) - AC_DEFINE_UNQUOTED([AWS_VERSION_PATCH], ${aws_version_tokens@<:@2@:>@}, [Patch version of aws-sdk-cpp.]) -fi - - -# Whether to use the Boehm garbage collector. -AC_ARG_ENABLE(gc, AS_HELP_STRING([--enable-gc],[enable garbage collection in the Nix expression evaluator (requires Boehm GC) [default=yes]]), - gc=$enableval, gc=yes) -if test "$gc" = yes; then - PKG_CHECK_MODULES([BDW_GC], [bdw-gc]) - CXXFLAGS="$BDW_GC_CFLAGS $CXXFLAGS" - AC_DEFINE(HAVE_BOEHMGC, 1, [Whether to use the Boehm garbage collector.]) -fi - - -if test "$ENABLE_TESTS" = yes; then - -# Look for gtest. -PKG_CHECK_MODULES([GTEST], [gtest_main gmock_main]) - - -# Look for rapidcheck. -AC_ARG_VAR([RAPIDCHECK_HEADERS], [include path of gtest headers shipped by RAPIDCHECK]) -# No pkg-config yet, https://github.com/emil-e/rapidcheck/issues/302 -AC_LANG_PUSH(C++) -AC_SUBST(RAPIDCHECK_HEADERS) -[CXXFLAGS="-I $RAPIDCHECK_HEADERS $CXXFLAGS"] -[LIBS="-lrapidcheck -lgtest $LIBS"] -AC_CHECK_HEADERS([rapidcheck/gtest.h], [], [], [#include ]) -dnl AC_CHECK_LIB doesn't work for C++ libs with mangled symbols -AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[ - #include - #include - ]], [[ - return RUN_ALL_TESTS(); - ]]) - ], - [], - [AC_MSG_ERROR([librapidcheck is not found.])]) -AC_LANG_POP(C++) - -fi - -# Look for nlohmann/json. -PKG_CHECK_MODULES([NLOHMANN_JSON], [nlohmann_json >= 3.9]) - - -# documentation generation switch -AC_ARG_ENABLE(doc-gen, AS_HELP_STRING([--disable-doc-gen],[disable documentation generation]), - doc_generate=$enableval, doc_generate=yes) -AC_SUBST(doc_generate) - -# Look for lowdown library. -PKG_CHECK_MODULES([LOWDOWN], [lowdown >= 0.9.0], [CXXFLAGS="$LOWDOWN_CFLAGS $CXXFLAGS"]) - -# Look for toml11, a required dependency. -AC_ARG_VAR([TOML11_HEADERS], [include path of toml11 headers]) -AC_LANG_PUSH(C++) -[CXXFLAGS="-I $TOML11_HEADERS $CXXFLAGS"] -AC_CHECK_HEADER([toml.hpp], [], [AC_MSG_ERROR([toml11 is not found.])]) -AC_LANG_POP(C++) - -# Setuid installations. -AC_CHECK_FUNCS([setresuid setreuid lchown]) - - -# Nice to have, but not essential. -AC_CHECK_FUNCS([strsignal posix_fallocate sysconf]) - - -AC_ARG_WITH(sandbox-shell, AS_HELP_STRING([--with-sandbox-shell=PATH],[path of a statically-linked shell to use as /bin/sh in sandboxes]), - sandbox_shell=$withval) -AC_SUBST(sandbox_shell) -if test ${cross_compiling:-no} = no && ! test -z ${sandbox_shell+x}; then - AC_MSG_CHECKING([whether sandbox-shell has the standalone feature]) - # busybox shell sometimes allows executing other busybox applets, - # even if they are not in the path, breaking our sandbox - if PATH= $sandbox_shell -c "busybox" 2>&1 | grep -qv "not found"; then - AC_MSG_RESULT(enabled) - AC_MSG_ERROR([Please disable busybox FEATURE_SH_STANDALONE]) - else - AC_MSG_RESULT(disabled) - fi -fi - -AC_ARG_ENABLE(embedded-sandbox-shell, AS_HELP_STRING([--enable-embedded-sandbox-shell],[include the sandbox shell in the Nix binary [default=no]]), - embedded_sandbox_shell=$enableval, embedded_sandbox_shell=no) -AC_SUBST(embedded_sandbox_shell) -if test "$embedded_sandbox_shell" = yes; then - AC_DEFINE(HAVE_EMBEDDED_SANDBOX_SHELL, 1, [Include the sandbox shell in the Nix binary.]) -fi - - -# Expand all variables in config.status. -test "$prefix" = NONE && prefix=$ac_default_prefix -test "$exec_prefix" = NONE && exec_prefix='${prefix}' -for name in $ac_subst_vars; do - declare $name="$(eval echo "${!name}")" - declare $name="$(eval echo "${!name}")" - declare $name="$(eval echo "${!name}")" -done - -rm -f Makefile.config - -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([]) -AC_OUTPUT diff --git a/doc/internal-api/local.mk b/doc/internal-api/local.mk deleted file mode 100644 index 890f341b7..000000000 --- a/doc/internal-api/local.mk +++ /dev/null @@ -1,19 +0,0 @@ -.PHONY: internal-api-html - -ifeq ($(internal_api_docs), yes) - -$(docdir)/internal-api/html/index.html $(docdir)/internal-api/latex: $(d)/doxygen.cfg - mkdir -p $(docdir)/internal-api - { cat $< ; echo "OUTPUT_DIRECTORY=$(docdir)/internal-api" ; } | doxygen - - -# Generate the HTML API docs for Nix's unstable internal interfaces. -internal-api-html: $(docdir)/internal-api/html/index.html - -else - -# Make a nicer error message -internal-api-html: - @echo "Internal API docs are disabled. Configure with '--enable-internal-api-docs', or avoid calling 'make internal-api-html'." - @exit 1 - -endif diff --git a/doc/manual/local.mk b/doc/manual/local.mk deleted file mode 100644 index 50c67b8ae..000000000 --- a/doc/manual/local.mk +++ /dev/null @@ -1,178 +0,0 @@ -ifeq ($(doc_generate),yes) - -# The version of Nix used to generate the doc. Can also be -# `$(nix_INSTALL_PATH)` or just `nix` (to grap ambient from the `PATH`), -# if one prefers. -doc_nix = $(nix_PATH) - -MANUAL_SRCS := \ - $(call rwildcard, $(d)/src, *.md) \ - $(call rwildcard, $(d)/src, */*.md) - -man-pages := $(foreach n, \ - nix-env.1 nix-store.1 \ - nix-build.1 nix-shell.1 nix-instantiate.1 \ - nix-collect-garbage.1 \ - nix-prefetch-url.1 nix-channel.1 \ - nix-hash.1 nix-copy-closure.1 \ - nix.conf.5 nix-daemon.8 \ - nix-profiles.5 \ -, doc/manual/generated/in/$(n)) - -# man pages for subcommands -# convert from `$(d)/src/command-ref/nix-{1}/{2}.md` to `$(d)/nix-{1}-{2}.1` -# FIXME: unify with how nix3-cli man pages are generated -man-pages += $(foreach subcommand, \ - $(filter-out %opt-common.md %env-common.md, $(wildcard $(d)/src/command-ref/nix-*/*.md)), \ - doc/manual/generated/in/$(subst /,-,$(subst $(d)/src/command-ref/,,$(subst .md,.1,$(subcommand))))) - -clean-files += $(d)/*.1 $(d)/*.5 $(d)/*.8 - -# Provide a dummy environment for nix, so that it will not access files outside the macOS sandbox. -# Set cores to 0 because otherwise nix config show resolves the cores based on the current machine -dummy-env = env -i \ - HOME=/dummy \ - NIX_CONF_DIR=/dummy \ - NIX_SSL_CERT_FILE=/dummy/no-ca-bundle.crt \ - NIX_STATE_DIR=/dummy \ - NIX_CONFIG='cores = 0' - -nix-eval = $(dummy-env) $(doc_nix) eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw - -doc/manual/generated/in/nix-env-%.1: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh \ - --out-no-smarty "$(subst nix-env-,nix-env --,$$(basename "$@" .1))" 1 \ - doc/manual/generated/out/markdown/command-ref/nix-env/$*.md \ - $@ - -doc/manual/generated/in/nix-store-%.1: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh \ - --out-no-smarty "$(subst nix-store-,nix-store --,$$(basename "$@" .1))" 1 \ - doc/manual/generated/out/markdown/command-ref/nix-store/$*.md \ - $@ - - -doc/manual/generated/in/%.1: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh "$$(basename $@ .1)" 1 \ - doc/manual/generated/out/markdown/command-ref/$*.md \ - $@ - -doc/manual/generated/in/%.8: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh "$$(basename $@ .8)" 8 \ - doc/manual/generated/out/markdown/command-ref/$*.md \ - $@ - -doc/manual/generated/in/nix.conf.5: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh "$$(basename $@ .5)" 5 \ - doc/manual/generated/out/markdown/command-ref/conf-file.md \ - $@ - -doc/manual/generated/in/nix-profiles.5: doc/manual/generated/out - $(trace-gen) doc/manual/render-manpage.sh "$$(basename $@ .5)" 5 \ - doc/manual/generated/out/markdown/command-ref/files/profiles.md \ - $@ - -doc/manual/generated/in/command-ref/new-cli: doc/manual/generated/in/nix.json $(d)/utils.nix $(d)/generate-manpage.nix $(doc_nix) - @mkdir -p doc/manual/generated/in/command-ref - @rm -rf $@ $@.tmp - $(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-manpage.nix true (builtins.readFile $<)' - @mv $@.tmp $@ - -doc/manual/generated/in/command-ref/conf-file.md: doc/manual/generated/in/conf-file.json $(d)/utils.nix doc/manual/generated/in/command-ref/experimental-features-shortlist.md $(doc_nix) - @mkdir -p doc/manual/generated/in/command-ref - $(trace-gen) $(nix-eval) --expr '(import doc/manual/utils.nix).showSettings { inlineHTML = true; } (builtins.fromJSON (builtins.readFile $<))' >> $@ - -doc/manual/generated/in/nix.json: $(doc_nix) - @mkdir -p doc/manual/generated/in - $(trace-gen) $(dummy-env) $(doc_nix) __dump-cli > $@.tmp - @mv $@.tmp $@ - -doc/manual/generated/in/conf-file.json: $(doc_nix) - @mkdir -p doc/manual/generated/in - $(trace-gen) $(dummy-env) $(doc_nix) config show --json --experimental-features nix-command > $@.tmp - @mv $@.tmp $@ - -doc/manual/generated/in/contributing/experimental-feature-descriptions.md: doc/manual/generated/in/xp-features.json $(d)/utils.nix $(d)/generate-xp-features.nix $(doc_nix) - @mkdir -p doc/manual/generated/in/contributing - @rm -rf $@ $@.tmp - $(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-xp-features.nix (builtins.fromJSON (builtins.readFile $<))' - @mv $@.tmp $@ - -doc/manual/generated/in/command-ref/experimental-features-shortlist.md: doc/manual/generated/in/xp-features.json $(d)/utils.nix $(d)/generate-xp-features-shortlist.nix $(doc_nix) - @mkdir -p doc/manual/generated/in/command-ref - @rm -rf $@ $@.tmp - $(trace-gen) $(nix-eval) --write-to $@.tmp --expr 'import doc/manual/generate-xp-features-shortlist.nix (builtins.fromJSON (builtins.readFile $<))' - @mv $@.tmp $@ - -doc/manual/generated/in/xp-features.json: $(doc_nix) - $(trace-gen) $(dummy-env) NIX_PATH=nix/corepkgs=corepkgs $(doc_nix) __dump-xp-features > $@.tmp - @mv $@.tmp $@ - -doc/manual/generated/in/language/builtins.md: doc/manual/generated/in/language.json $(d)/generate-builtins.nix $(doc_nix) - @mkdir -p doc/manual/generated/in/language - $(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-builtins.nix (builtins.fromJSON (builtins.readFile $<)).builtins' >> $@ - -doc/manual/generated/in/language/builtin-constants.md: doc/manual/generated/in/language.json $(d)/generate-builtin-constants.nix $(doc_nix) - @mkdir -p doc/manual/generated/in/language - $(trace-gen) $(nix-eval) --expr 'import doc/manual/generate-builtin-constants.nix (builtins.fromJSON (builtins.readFile $<)).constants' >> $@ - -doc/manual/generated/in/language.json: $(doc_nix) - @mkdir -p doc/manual/generated/in - $(trace-gen) $(dummy-env) NIX_PATH=nix/corepkgs=corepkgs $(doc_nix) __dump-language > $@.tmp - @mv $@.tmp $@ - -# Generate "Upcoming release" notes (or clear it and remove from menu) -doc/manual/generated/in/release-notes/rl-next-generated.md: $(d)/rl-next $(d)/rl-next/* - @mkdir -p doc/manual/generated/in/release-notes - @if type -p build-release-notes > /dev/null; then \ - echo " GEN " $@; \ - build-release-notes doc/manual/rl-next > $@; \ - else \ - echo " NULL " $@; \ - true > $@; \ - fi - -# Generate the HTML manual. -.PHONY: manual-html -manual-html: $(docdir)/manual/index.html -install: $(docdir)/manual/index.html - -# Generate 'nix' manpages. -install: $(mandir)/man1/nix3-manpages -man: doc/manual/generated/man1/nix3-manpages -all: doc/manual/generated/man1/nix3-manpages - -# FIXME: unify with how the other man pages are generated. -# this one works differently and does not use any of the amenities provided by `/mk/lib.mk`. -$(mandir)/man1/nix3-manpages: doc/manual/generated/man1/nix3-manpages - @mkdir -p $(DESTDIR)$$(dirname $@) - $(trace-install) install -m 0644 $$(dirname $<)/* $(DESTDIR)$$(dirname $@) - -doc/manual/generated/man1/nix3-manpages: doc/manual/generated/out - @mkdir -p $(DESTDIR)$$(dirname $@) - $(trace-gen) for i in doc/manual/generated/out/markdown/command-ref/new-cli/*.md; do \ - name=$$(basename $$i .md); \ - tmpFile=$$(mktemp); \ - if [[ $$name = SUMMARY ]]; then continue; fi; \ - printf "Title: %s\n\n" "$$name" > $$tmpFile; \ - cat $$i >> $$tmpFile; \ - lowdown -sT man --nroff-nolinks -M section=1 $$tmpFile -o $(DESTDIR)$$(dirname $@)/$$name.1; \ - rm $$tmpFile; \ - done - @touch $@ - -doc/manual/generated/out: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/custom.css $(d)/src/SUMMARY.md doc/manual/generated/in/command-ref/new-cli doc/manual/generated/in/command-ref/experimental-features-shortlist.md doc/manual/generated/in/contributing/experimental-feature-descriptions.md doc/manual/generated/in/command-ref/conf-file.md doc/manual/generated/in/language/builtins.md doc/manual/generated/in/language/builtin-constants.md doc/manual/generated/in/release-notes/rl-next-generated.md $(d)/substitute.py - @rm -rf $@ - $(trace-gen) \ - MDBOOK_SUBSTITUTE_SEARCH=doc/manual/generated/in \ - RUST_LOG=warn \ - mdbook build doc/manual -d generated/out 2>&1 \ - | { grep -Fv "because fragment resolution isn't implemented" || :; } - @find $@ -iname meson.build -delete - -$(docdir)/manual/index.html: doc/manual/generated/out - @mkdir -p $(DESTDIR)$(docdir) - @rm -rf $(DESTDIR)$(docdir)/manual - @cp -r $ -# Copyright (c) 2012 Zack Weinberg -# Copyright (c) 2013 Roy Stogner -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov -# Copyright (c) 2015 Paul Norman -# Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016, 2018 Krzesimir Nowak -# Copyright (c) 2019 Enji Cooper -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 11 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], - [$1], [14], [ax_cxx_compile_alternatives="14 1y"], - [$1], [17], [ax_cxx_compile_alternatives="17 1z"], - [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], - [$2], [ext], [], - [$2], [noext], [], - [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], - [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], - [$3], [optional], [ax_cxx_compile_cxx$1_required=false], - [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi]) - - m4_if([$2], [ext], [], [dnl - if test x$ac_success = xno; then - dnl HP's aCC needs +std=c++11 according to: - dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf - dnl Cray's crayCC needs "-h std=c++11" - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - if test x$ac_success = xyes; then - break - fi - done - fi]) - AC_LANG_POP([C++]) - if test x$ax_cxx_compile_cxx$1_required = xtrue; then - if test x$ac_success = xno; then - AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) - fi - fi - if test x$ac_success = xno; then - HAVE_CXX$1=0 - AC_MSG_NOTICE([No compiler with C++$1 support was found]) - else - HAVE_CXX$1=1 - AC_DEFINE(HAVE_CXX$1,1, - [define if the compiler supports basic C++$1 syntax]) - fi - AC_SUBST(HAVE_CXX$1) -]) - - -dnl Test body for checking C++11 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 -) - - -dnl Test body for checking C++14 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 -) - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 -) - -dnl Tests for new features in C++11 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ - -// If the compiler admits that it is not ready for C++11, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201103L - -#error "This is not a C++11 compiler" - -#else - -namespace cxx11 -{ - - namespace test_static_assert - { - - template - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - } - - namespace test_final_override - { - - struct Base - { - virtual ~Base() {} - virtual void f() {} - }; - - struct Derived : public Base - { - virtual ~Derived() override {} - virtual void f() override {} - }; - - } - - namespace test_double_right_angle_brackets - { - - template < typename T > - struct check {}; - - typedef check single_type; - typedef check> double_type; - typedef check>> triple_type; - typedef check>>> quadruple_type; - - } - - namespace test_decltype - { - - int - f() - { - int a = 1; - decltype(a) b = 2; - return a + b; - } - - } - - namespace test_type_deduction - { - - template < typename T1, typename T2 > - struct is_same - { - static const bool value = false; - }; - - template < typename T > - struct is_same - { - static const bool value = true; - }; - - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) - { - return a1 + a2; - } - - int - test(const int c, volatile int v) - { - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == true, ""); - static_assert(is_same::value == false, ""); - static_assert(is_same::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); - } - - } - - namespace test_noexcept - { - - int f() { return 0; } - int g() noexcept { return 0; } - - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); - - } - - namespace test_constexpr - { - - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept - { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; - } - - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept - { - return strlen_c_r(s, 0UL); - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); - - } - - namespace test_rvalue_references - { - - template < int N > - struct answer - { - static constexpr int value = N; - }; - - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } - - void - test() - { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); - } - - } - - namespace test_uniform_initialization - { - - struct test - { - static const int zero {}; - static const int one {1}; - }; - - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); - - } - - namespace test_lambdas - { - - void - test1() - { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); - } - - int - test2() - { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; - } - - int - test3() - { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); - } - - } - - namespace test_variadic_templates - { - - template - struct sum; - - template - struct sum - { - static constexpr auto value = N0 + sum::value; - }; - - template <> - struct sum<> - { - static constexpr auto value = 0; - }; - - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); - - } - - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae - { - - struct foo {}; - - template - using member = typename T::member_type; - - template - void func(...) {} - - template - void func(member*) {} - - void test(); - - void test() { func(0); } - - } - -} // namespace cxx11 - -#endif // __cplusplus >= 201103L - -]]) - - -dnl Tests for new features in C++14 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ - -// If the compiler admits that it is not ready for C++14, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201402L - -#error "This is not a C++14 compiler" - -#else - -namespace cxx14 -{ - - namespace test_polymorphic_lambdas - { - - int - test() - { - const auto lambda = [](auto&&... args){ - const auto istiny = [](auto x){ - return (sizeof(x) == 1UL) ? 1 : 0; - }; - const int aretiny[] = { istiny(args)... }; - return aretiny[0]; - }; - return lambda(1, 1L, 1.0f, '1'); - } - - } - - namespace test_binary_literals - { - - constexpr auto ivii = 0b0000000000101010; - static_assert(ivii == 42, "wrong value"); - - } - - namespace test_generalized_constexpr - { - - template < typename CharT > - constexpr unsigned long - strlen_c(const CharT *const s) noexcept - { - auto length = 0UL; - for (auto p = s; *p; ++p) - ++length; - return length; - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("x") == 1UL, ""); - static_assert(strlen_c("test") == 4UL, ""); - static_assert(strlen_c("another\0test") == 7UL, ""); - - } - - namespace test_lambda_init_capture - { - - int - test() - { - auto x = 0; - const auto lambda1 = [a = x](int b){ return a + b; }; - const auto lambda2 = [a = lambda1(x)](){ return a; }; - return lambda2(); - } - - } - - namespace test_digit_separators - { - - constexpr auto ten_million = 100'000'000; - static_assert(ten_million == 100000000, ""); - - } - - namespace test_return_type_deduction - { - - auto f(int& x) { return x; } - decltype(auto) g(int& x) { return x; } - - template < typename T1, typename T2 > - struct is_same - { - static constexpr auto value = false; - }; - - template < typename T > - struct is_same - { - static constexpr auto value = true; - }; - - int - test() - { - auto x = 0; - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); - return x; - } - - } - -} // namespace cxx14 - -#endif // __cplusplus >= 201402L - -]]) - - -dnl Tests for new features in C++17 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ - -// If the compiler admits that it is not ready for C++17, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201703L - -#error "This is not a C++17 compiler" - -#else - -#include -#include -#include - -namespace cxx17 -{ - - namespace test_constexpr_lambdas - { - - constexpr int foo = [](){return 42;}(); - - } - - namespace test::nested_namespace::definitions - { - - } - - namespace test_fold_expression - { - - template - int multiply(Args... args) - { - return (args * ... * 1); - } - - template - bool all(Args... args) - { - return (args && ...); - } - - } - - namespace test_extended_static_assert - { - - static_assert (true); - - } - - namespace test_auto_brace_init_list - { - - auto foo = {5}; - auto bar {5}; - - static_assert(std::is_same, decltype(foo)>::value); - static_assert(std::is_same::value); - } - - namespace test_typename_in_template_template_parameter - { - - template typename X> struct D; - - } - - namespace test_fallthrough_nodiscard_maybe_unused_attributes - { - - int f1() - { - return 42; - } - - [[nodiscard]] int f2() - { - [[maybe_unused]] auto unused = f1(); - - switch (f1()) - { - case 17: - f1(); - [[fallthrough]]; - case 42: - f1(); - } - return f1(); - } - - } - - namespace test_extended_aggregate_initialization - { - - struct base1 - { - int b1, b2 = 42; - }; - - struct base2 - { - base2() { - b3 = 42; - } - int b3; - }; - - struct derived : base1, base2 - { - int d; - }; - - derived d1 {{1, 2}, {}, 4}; // full initialization - derived d2 {{}, {}, 4}; // value-initialized bases - - } - - namespace test_general_range_based_for_loop - { - - struct iter - { - int i; - - int& operator* () - { - return i; - } - - const int& operator* () const - { - return i; - } - - iter& operator++() - { - ++i; - return *this; - } - }; - - struct sentinel - { - int i; - }; - - bool operator== (const iter& i, const sentinel& s) - { - return i.i == s.i; - } - - bool operator!= (const iter& i, const sentinel& s) - { - return !(i == s); - } - - struct range - { - iter begin() const - { - return {0}; - } - - sentinel end() const - { - return {5}; - } - }; - - void f() - { - range r {}; - - for (auto i : r) - { - [[maybe_unused]] auto v = i; - } - } - - } - - namespace test_lambda_capture_asterisk_this_by_value - { - - struct t - { - int i; - int foo() - { - return [*this]() - { - return i; - }(); - } - }; - - } - - namespace test_enum_class_construction - { - - enum class byte : unsigned char - {}; - - byte foo {42}; - - } - - namespace test_constexpr_if - { - - template - int f () - { - if constexpr(cond) - { - return 13; - } - else - { - return 42; - } - } - - } - - namespace test_selection_statement_with_initializer - { - - int f() - { - return 13; - } - - int f2() - { - if (auto i = f(); i > 0) - { - return 3; - } - - switch (auto i = f(); i + 4) - { - case 17: - return 2; - - default: - return 1; - } - } - - } - - namespace test_template_argument_deduction_for_class_templates - { - - template - struct pair - { - pair (T1 p1, T2 p2) - : m1 {p1}, - m2 {p2} - {} - - T1 m1; - T2 m2; - }; - - void f() - { - [[maybe_unused]] auto p = pair{13, 42u}; - } - - } - - namespace test_non_type_auto_template_parameters - { - - template - struct B - {}; - - B<5> b1; - B<'a'> b2; - - } - - namespace test_structured_bindings - { - - int arr[2] = { 1, 2 }; - std::pair pr = { 1, 2 }; - - auto f1() -> int(&)[2] - { - return arr; - } - - auto f2() -> std::pair& - { - return pr; - } - - struct S - { - int x1 : 2; - volatile double y1; - }; - - S f3() - { - return {}; - } - - auto [ x1, y1 ] = f1(); - auto& [ xr1, yr1 ] = f1(); - auto [ x2, y2 ] = f2(); - auto& [ xr2, yr2 ] = f2(); - const auto [ x3, y3 ] = f3(); - - } - - namespace test_exception_spec_type_system - { - - struct Good {}; - struct Bad {}; - - void g1() noexcept; - void g2(); - - template - Bad - f(T*, T*); - - template - Good - f(T1*, T2*); - - static_assert (std::is_same_v); - - } - - namespace test_inline_variables - { - - template void f(T) - {} - - template inline T g(T) - { - return T{}; - } - - template<> inline void f<>(int) - {} - - template<> int g<>(int) - { - return 5; - } - - } - -} // namespace cxx17 - -#endif // __cplusplus < 201703L - -]]) diff --git a/m4/ax_cxx_compile_stdcxx_17.m4 b/m4/ax_cxx_compile_stdcxx_17.m4 deleted file mode 100644 index a68341717..000000000 --- a/m4/ax_cxx_compile_stdcxx_17.m4 +++ /dev/null @@ -1,35 +0,0 @@ -# ============================================================================= -# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html -# ============================================================================= -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the C++17 -# standard; if necessary, add switches to CXX and CXXCPP to enable -# support. -# -# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX -# macro with the version set to C++17. The two optional arguments are -# forwarded literally as the second and third argument respectively. -# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for -# more information. If you want to use this macro, you also need to -# download the ax_cxx_compile_stdcxx.m4 file. -# -# LICENSE -# -# Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016 Krzesimir Nowak -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 2 - -AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) -AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])]) diff --git a/m4/gcc_bug_80431.m4 b/m4/gcc_bug_80431.m4 deleted file mode 100644 index e42f01956..000000000 --- a/m4/gcc_bug_80431.m4 +++ /dev/null @@ -1,64 +0,0 @@ -# Ensure that this bug is not present in the C++ toolchain we are using. -# -# URL for bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431 -# -# The test program is from that issue, with only a slight modification -# to set an exit status instead of printing strings. -AC_DEFUN([ENSURE_NO_GCC_BUG_80431], -[ - AC_MSG_CHECKING([that GCC bug 80431 is fixed]) - AC_LANG_PUSH(C++) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[ - #include - - static bool a = true; - static bool b = true; - - struct Options { }; - - struct Option - { - Option(Options * options) - { - a = false; - } - - ~Option() - { - b = false; - } - }; - - struct MyOptions : Options { }; - - struct MyOptions2 : virtual MyOptions - { - Option foo{this}; - }; - ]], - [[ - { - MyOptions2 opts; - } - return (a << 1) | b; - ]])], - [status_80431=0], - [status_80431=$?], - [ - # Assume we're bug-free when cross-compiling - ]) - AC_LANG_POP(C++) - AS_CASE([$status_80431], - [0],[ - AC_MSG_RESULT(yes) - ], - [2],[ - AC_MSG_RESULT(no) - AC_MSG_ERROR(Cannot build Nix with C++ compiler with this bug) - ], - [ - AC_MSG_RESULT(unexpected result $status_80431: not expected failure with bug, ignoring) - ]) -]) diff --git a/misc/bash/local.mk b/misc/bash/local.mk deleted file mode 100644 index 66235af05..000000000 --- a/misc/bash/local.mk +++ /dev/null @@ -1 +0,0 @@ -$(eval $(call install-file-as, $(d)/completion.sh, $(datarootdir)/bash-completion/completions/nix, 0644)) diff --git a/misc/fish/local.mk b/misc/fish/local.mk deleted file mode 100644 index ece899fc3..000000000 --- a/misc/fish/local.mk +++ /dev/null @@ -1 +0,0 @@ -$(eval $(call install-file-as, $(d)/completion.fish, $(datarootdir)/fish/vendor_completions.d/nix.fish, 0644)) diff --git a/misc/launchd/local.mk b/misc/launchd/local.mk deleted file mode 100644 index a39188fe6..000000000 --- a/misc/launchd/local.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifdef HOST_DARWIN - - $(eval $(call install-data-in, $(d)/org.nixos.nix-daemon.plist, $(prefix)/Library/LaunchDaemons)) - -endif diff --git a/misc/systemd/local.mk b/misc/systemd/local.mk deleted file mode 100644 index 76121a0f9..000000000 --- a/misc/systemd/local.mk +++ /dev/null @@ -1,8 +0,0 @@ -ifdef HOST_LINUX - - $(foreach n, nix-daemon.socket nix-daemon.service, $(eval $(call install-file-in, $(d)/$(n), $(prefix)/lib/systemd/system, 0644))) - $(foreach n, nix-daemon.conf, $(eval $(call install-file-in, $(d)/$(n), $(prefix)/lib/tmpfiles.d, 0644))) - - clean-files += $(d)/nix-daemon.socket $(d)/nix-daemon.service $(d)/nix-daemon.conf - -endif diff --git a/misc/zsh/local.mk b/misc/zsh/local.mk deleted file mode 100644 index 0b4e294fb..000000000 --- a/misc/zsh/local.mk +++ /dev/null @@ -1,2 +0,0 @@ -$(eval $(call install-file-as, $(d)/completion.zsh, $(datarootdir)/zsh/site-functions/_nix, 0644)) -$(eval $(call install-file-as, $(d)/run-help-nix, $(datarootdir)/zsh/site-functions/run-help-nix, 0644)) diff --git a/mk/build-dir.mk b/mk/build-dir.mk deleted file mode 100644 index 02f4cae60..000000000 --- a/mk/build-dir.mk +++ /dev/null @@ -1,10 +0,0 @@ -# Initialise support for build directories. -builddir ?= - -ifdef builddir - buildprefix = $(builddir)/ - buildprefixrel = $(builddir) -else - buildprefix = - buildprefixrel = . -endif diff --git a/mk/clean.mk b/mk/clean.mk deleted file mode 100644 index ce9afb3b0..000000000 --- a/mk/clean.mk +++ /dev/null @@ -1,11 +0,0 @@ -clean-files := - -clean: - $(suppress) rm -fv -- $(clean-files) - -dryclean: - @for i in $(clean-files); do if [ -e $$i ]; then echo $$i; fi; done | sort - -print-top-help += \ - echo " clean: Delete generated files"; \ - echo " dryclean: Show what files would be deleted by 'make clean'"; diff --git a/mk/common-test.sh b/mk/common-test.sh deleted file mode 100644 index 7ab25febf..000000000 --- a/mk/common-test.sh +++ /dev/null @@ -1,15 +0,0 @@ -test_dir=tests/functional - -test=$(echo -n "$test" | sed -e "s|^$test_dir/||") - -TESTS_ENVIRONMENT=("TEST_NAME=${test%.*}" 'NIX_REMOTE=') - -: ${BASH:=/usr/bin/env bash} - -init_test () { - cd "$test_dir" && env "${TESTS_ENVIRONMENT[@]}" $BASH -e init.sh 2>/dev/null > /dev/null -} - -run_test_proper () { - cd "$test_dir/$(dirname $test)" && env "${TESTS_ENVIRONMENT[@]}" $BASH -e $(basename $test) -} diff --git a/mk/cxx-big-literal.mk b/mk/cxx-big-literal.mk deleted file mode 100644 index d64a171c8..000000000 --- a/mk/cxx-big-literal.mk +++ /dev/null @@ -1,5 +0,0 @@ -%.gen.hh: % - @echo 'R"__NIX_STR(' >> $@.tmp - $(trace-gen) cat $< >> $@.tmp - @echo ')__NIX_STR"' >> $@.tmp - @mv $@.tmp $@ diff --git a/mk/debug-test.sh b/mk/debug-test.sh deleted file mode 100755 index b5b628ecd..000000000 --- a/mk/debug-test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -test=$1 - -dir="$(dirname "${BASH_SOURCE[0]}")" -source "$dir/common-test.sh" - -(init_test) -run_test_proper diff --git a/mk/disable-tests.mk b/mk/disable-tests.mk deleted file mode 100644 index f72f84412..000000000 --- a/mk/disable-tests.mk +++ /dev/null @@ -1,12 +0,0 @@ -# This file is only active for `./configure --disable-tests`. -# Running `make check` or `make installcheck` would indicate a mistake in the -# caller. - -installcheck: - @echo "Tests are disabled. Configure without '--disable-tests', or avoid calling 'make installcheck'." - @exit 1 - -# This currently has little effect. -check: - @echo "Tests are disabled. Configure without '--disable-tests', or avoid calling 'make check'." - @exit 1 diff --git a/mk/functions.mk b/mk/functions.mk deleted file mode 100644 index c48775db8..000000000 --- a/mk/functions.mk +++ /dev/null @@ -1,14 +0,0 @@ -# Utility function for recursively finding files, e.g. -# ‘$(call rwildcard, path/to/dir, *.c *.h)’. -rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) - -# Given a file name, produce the corresponding dependency file -# (e.g. ‘foo/bar.o’ becomes ‘foo/.bar.o.dep’). -filename-to-dep = $(dir $1).$(notdir $1).dep - -# Return the full path to a program by looking it up in $PATH, or the -# empty string if not found. -find-program = $(shell for i in $$(IFS=: ; echo $$PATH); do p=$$i/$(strip $1); if [ -e $$p ]; then echo $$p; break; fi; done) - -# Ensure that the given string ends in a single slash. -add-trailing-slash = $(patsubst %/,%,$(1))/ diff --git a/mk/install-dirs.mk b/mk/install-dirs.mk deleted file mode 100644 index 732b0d6fc..000000000 --- a/mk/install-dirs.mk +++ /dev/null @@ -1,11 +0,0 @@ -# Default installation paths. -prefix ?= /usr/local -libdir ?= $(prefix)/lib -bindir ?= $(prefix)/bin -libexecdir ?= $(prefix)/libexec -datadir ?= $(prefix)/share -localstatedir ?= $(prefix)/var -sysconfdir ?= $(prefix)/etc -mandir ?= $(prefix)/share/man - -DESTDIR ?= diff --git a/mk/install.mk b/mk/install.mk deleted file mode 100644 index dad0fd853..000000000 --- a/mk/install.mk +++ /dev/null @@ -1,62 +0,0 @@ -# Add a rule for creating $(1) as a directory. This template may be -# called multiple times for the same directory. -define create-dir - _i := $$(call add-trailing-slash, $(DESTDIR)$$(strip $(1))) - ifndef $$(_i)_SEEN - $$(_i)_SEEN = 1 - $$(_i): - $$(trace-mkdir) install -d "$$@" - endif -endef - - -# Add a rule for installing file $(1) as file $(2) with mode $(3). -# The directory containing $(2) will be created automatically. -define install-file-as - - _i := $(DESTDIR)$$(strip $(2)) - - install: $$(_i) - - $$(_i): $(1) | $$(dir $$(_i)) - $$(trace-install) install -m $(3) $(1) "$$@" - - $$(eval $$(call create-dir, $$(dir $(2)))) - -endef - - -# Add a rule for installing file $(1) in directory $(2) with mode -# $(3). The directory will be created automatically. -define install-file-in - $$(eval $$(call install-file-as,$(1),$(2)/$$(notdir $(1)),$(3))) -endef - - -define install-program-in - $$(eval $$(call install-file-in,$(1),$(2),0755)) -endef - - -define install-data-in - $$(eval $$(call install-file-in,$(1),$(2),0644)) -endef - - -# Install a symlink from $(2) to $(1). Note that $(1) need not exist. -define install-symlink - - _i := $(DESTDIR)$$(strip $(2)) - - install: $$(_i) - - $$(_i): | $$(dir $$(_i)) - $$(trace-install) ln -sfn $(1) "$$@" - - $$(eval $$(call create-dir, $$(dir $(2)))) - -endef - - -print-top-help += \ - echo " install: Install into \$$(prefix) (currently set to '$(prefix)')"; diff --git a/mk/lib.mk b/mk/lib.mk deleted file mode 100644 index 920f5ca8e..000000000 --- a/mk/lib.mk +++ /dev/null @@ -1,168 +0,0 @@ -default: all - - -# Get rid of default suffixes. FIXME: is this a good idea? -.SUFFIXES: - - -# Initialise some variables. -bin-scripts := -noinst-scripts := -man-pages := -install-tests := -install-tests-groups := - -ifdef HOST_OS - HOST_KERNEL = $(firstword $(subst -, ,$(HOST_OS))) - ifeq ($(HOST_KERNEL), cygwin) - HOST_CYGWIN = 1 - endif - ifeq ($(patsubst darwin%,,$(HOST_KERNEL)),) - HOST_DARWIN = 1 - endif - ifeq ($(patsubst freebsd%,,$(HOST_KERNEL)),) - HOST_FREEBSD = 1 - endif - ifeq ($(HOST_KERNEL), linux) - HOST_LINUX = 1 - endif - ifeq ($(patsubst solaris%,,$(HOST_KERNEL)),) - HOST_SOLARIS = 1 - endif -endif - -# Hack to define a literal space. -space := -space += - - -# Hack to define a literal newline. -define newline - - -endef - - -# Pass -fPIC if we're building dynamic libraries. -BUILD_SHARED_LIBS ?= 1 - -ifeq ($(BUILD_SHARED_LIBS), 1) - ifdef HOST_CYGWIN - GLOBAL_CFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE - GLOBAL_CXXFLAGS += -U__STRICT_ANSI__ -D_GNU_SOURCE - else - GLOBAL_CFLAGS += -fPIC - GLOBAL_CXXFLAGS += -fPIC - endif - ifndef HOST_DARWIN - ifndef HOST_SOLARIS - ifndef HOST_FREEBSD - GLOBAL_LDFLAGS += -Wl,--no-copy-dt-needed-entries - endif - endif - endif - SET_RPATH_TO_LIBS ?= 1 -endif - -# Pass -g if we want debug info. -BUILD_DEBUG ?= 1 - -ifeq ($(BUILD_DEBUG), 1) - GLOBAL_CFLAGS += -g - GLOBAL_CXXFLAGS += -g -endif - - -include mk/build-dir.mk -include mk/install-dirs.mk -include mk/functions.mk -include mk/tracing.mk -include mk/clean.mk -include mk/install.mk -include mk/libraries.mk -include mk/programs.mk -include mk/patterns.mk -include mk/templates.mk -include mk/cxx-big-literal.mk -include mk/tests.mk - - -# Include all sub-Makefiles. -define include-sub-makefile - d := $$(patsubst %/,%,$$(dir $(1))) - include $(1) -endef - -$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile,$(mf)))) - - -# Instantiate stuff. -$(foreach lib, $(libraries), $(eval $(call build-library,$(lib)))) -$(foreach prog, $(programs), $(eval $(call build-program,$(prog)))) -$(foreach script, $(bin-scripts), $(eval $(call install-program-in,$(script),$(bindir)))) -$(foreach script, $(bin-scripts), $(eval programs-list += $(script))) -$(foreach script, $(noinst-scripts), $(eval programs-list += $(script))) -$(foreach template, $(template-files), $(eval $(call instantiate-template,$(template)))) -$(foreach test, $(install-tests), \ - $(eval $(call run-install-test,$(test))) \ - $(eval installcheck: $(test).test)) -$(foreach test-group, $(install-tests-groups), \ - $(eval $(call run-install-test-group,$(test-group))) \ - $(eval installcheck: $(test-group).test-group) \ - $(foreach test, $($(test-group)-tests), \ - $(eval $(call run-install-test,$(test))) \ - $(eval $(test-group).test-group: $(test).test))) - -# Include makefiles requiring built programs. -$(foreach mf, $(makefiles-late), $(eval $(call include-sub-makefile,$(mf)))) - - -$(foreach file, $(man-pages), $(eval $(call install-data-in, $(file), $(mandir)/man$(patsubst .%,%,$(suffix $(file)))))) - - -.PHONY: default all man help - -all: $(programs-list) $(libs-list) $(man-pages) - -man: $(man-pages) - - -help: - @echo "The following targets are available:" - @echo "" - @echo " default: Build default targets" -ifdef man-pages - @echo " man: Generate manual pages" -endif - @$(print-top-help) -ifdef programs-list - @echo "" - @echo "The following programs can be built:" - @echo "" - @for i in $(programs-list); do echo " $$i"; done -endif -ifdef libs-list - @echo "" - @echo "The following libraries can be built:" - @echo "" - @for i in $(libs-list); do echo " $$i"; done -endif -ifdef install-tests-groups - @echo "" - @echo "The following groups of functional tests can be run:" - @echo "" - @for i in $(install-tests-groups); do echo " $$i.test-group"; done - @echo "" - @echo "(installcheck includes tests in test groups too.)" -endif - @echo "" - @echo "The following variables control the build:" - @echo "" - @echo " BUILD_SHARED_LIBS ($(BUILD_SHARED_LIBS)): Whether to build shared libraries" - @echo " BUILD_DEBUG ($(BUILD_DEBUG)): Whether to include debug symbols" - @echo " CC ($(CC)): C compiler to be used" - @echo " CFLAGS: Flags for the C compiler" - @echo " CXX ($(CXX)): C++ compiler to be used" - @echo " CXXFLAGS: Flags for the C++ compiler" - @echo " CPPFLAGS: C preprocessor flags, used for both CC and CXX" - @$(print-var-help) diff --git a/mk/libraries.mk b/mk/libraries.mk deleted file mode 100644 index f9d427b10..000000000 --- a/mk/libraries.mk +++ /dev/null @@ -1,161 +0,0 @@ -libs-list := - -ifdef HOST_DARWIN - SO_EXT = dylib -else - ifdef HOST_CYGWIN - SO_EXT = dll - else - SO_EXT = so - endif -endif - -# Build a library with symbolic name $(1). The library is defined by -# various variables prefixed by ‘$(1)_’: -# -# - $(1)_NAME: the name of the library (e.g. ‘libfoo’); defaults to -# $(1). -# -# - $(1)_DIR: the directory where the (non-installed) library will be -# placed. -# -# - $(1)_SOURCES: the source files of the library. -# -# - $(1)_CFLAGS: additional C compiler flags. -# -# - $(1)_CXXFLAGS: additional C++ compiler flags. -# -# - $(1)_ORDER_AFTER: a set of targets on which the object files of -# this libraries will have an order-only dependency. -# -# - $(1)_LIBS: the symbolic names of other libraries on which this -# library depends. -# -# - $(1)_ALLOW_UNDEFINED: if set, the library is allowed to have -# undefined symbols. Has no effect for static libraries. -# -# - $(1)_LDFLAGS: additional linker flags. -# -# - $(1)_LDFLAGS_PROPAGATED: additional linker flags, also propagated -# to the linking of programs/libraries that use this library. -# -# - $(1)_FORCE_INSTALL: if defined, the library will be installed even -# if it's not needed (i.e. dynamically linked) by a program. -# -# - $(1)_INSTALL_DIR: the directory where the library will be -# installed. Defaults to $(libdir). -# -# - $(1)_EXCLUDE_FROM_LIBRARY_LIST: if defined, the library will not -# be automatically marked as a dependency of the top-level all -# target andwill not be listed in the make help output. This is -# useful for libraries built solely for testing, for example. -# -# - BUILD_SHARED_LIBS: if equal to ‘1’, a dynamic library will be -# built, otherwise a static library. -define build-library - $(1)_NAME ?= $(1) - _d := $(buildprefix)$$(strip $$($(1)_DIR)) - _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) - $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs)))) - _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) - - ifdef HOST_CYGWIN - $(1)_INSTALL_DIR ?= $$(bindir) - else - $(1)_INSTALL_DIR ?= $$(libdir) - endif - - $(1)_LDFLAGS_USE := - $(1)_LDFLAGS_USE_INSTALLED := - $(1)_LIB_CLOSURE := $(1) - - $$(eval $$(call create-dir, $$(_d))) - - ifeq ($(BUILD_SHARED_LIBS), 1) - - ifdef $(1)_ALLOW_UNDEFINED - ifdef HOST_DARWIN - $(1)_LDFLAGS += -undefined suppress -flat_namespace - endif - else - # -Wl,-z,defs is broken with sanitizers on Linux/clang at least. - endif - - ifndef HOST_DARWIN - $(1)_LDFLAGS += -Wl,-soname=$$($(1)_NAME).$(SO_EXT) - endif - - $(1)_PATH := $$(_d)/$$($(1)_NAME).$(SO_EXT) - - $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/ - +$$(trace-ld) $(CXX) -o $$(abspath $$@) -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) $$($(1)_LDFLAGS_UNINSTALLED) - - ifndef HOST_DARWIN - $(1)_LDFLAGS_USE += -Wl,-rpath,$$(abspath $$(_d)) - endif - $(1)_LDFLAGS_USE += -L$$(_d) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) - - $(1)_INSTALL_PATH := $(DESTDIR)$$($(1)_INSTALL_DIR)/$$($(1)_NAME).$(SO_EXT) - - _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) - - $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR))) - - $$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/ - +$$(trace-ld) $(CXX) -o $$@ -shared $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$($(1)_LDFLAGS_PROPAGATED) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) - - $(1)_LDFLAGS_USE_INSTALLED += -L$$(DESTDIR)$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) - ifndef HOST_DARWIN - ifeq ($(SET_RPATH_TO_LIBS), 1) - $(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath,$$($(1)_INSTALL_DIR) - else - $(1)_LDFLAGS_USE_INSTALLED += -Wl,-rpath-link,$$($(1)_INSTALL_DIR) - endif - endif - - ifdef $(1)_FORCE_INSTALL - install: $$($(1)_INSTALL_PATH) - endif - - else - - $(1)_PATH := $$(_d)/$$($(1)_NAME).a - - $$($(1)_PATH): $$($(1)_OBJS) | $$(_d)/ - $$(trace-ld) $(LD) $$(ifndef $(HOST_DARWIN),-U) -r -o $$(_d)/$$($(1)_NAME).o $$^ - $$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o - - $(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) - - $(1)_INSTALL_PATH := $$(libdir)/$$($(1)_NAME).a - - $(1)_LIB_CLOSURE += $$($(1)_LIBS) - - endif - - $(1)_LDFLAGS_USE += $$($(1)_LDFLAGS_PROPAGATED) - $(1)_LDFLAGS_USE_INSTALLED += $$($(1)_LDFLAGS_PROPAGATED) - - # Propagate CFLAGS and CXXFLAGS to the individual object files. - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CFLAGS=$$($(1)_CFLAGS))) - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) - - # Make each object file depend on the common dependencies. - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS) $$(GLOBAL_COMMON_DEPS))) - - # Make each object file have order-only dependencies on the common - # order-only dependencies. This includes the order-only dependencies - # of libraries we're depending on. - $(1)_ORDER_AFTER_CLOSED = $$($(1)_ORDER_AFTER) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_ORDER_AFTER_CLOSED)) - - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): | $$($(1)_ORDER_AFTER_CLOSED) $$(GLOBAL_ORDER_AFTER))) - - # Include .dep files, if they exist. - $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) - -include $$($(1)_DEPS) - - ifndef $(1)_EXCLUDE_FROM_LIBRARY_LIST - libs-list += $$($(1)_PATH) - endif - clean-files += $$(_d)/*.a $$(_d)/*.$(SO_EXT) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) -endef diff --git a/mk/patterns.mk b/mk/patterns.mk deleted file mode 100644 index c81150260..000000000 --- a/mk/patterns.mk +++ /dev/null @@ -1,11 +0,0 @@ -$(buildprefix)%.o: %.cc - @mkdir -p "$(dir $@)" - $(trace-cxx) $(CXX) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) $(ERROR_SWITCH_ENUM) -MMD -MF $(call filename-to-dep, $@) -MP - -$(buildprefix)%.o: %.cpp - @mkdir -p "$(dir $@)" - $(trace-cxx) $(CXX) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CXXFLAGS_PCH) $(GLOBAL_CXXFLAGS) $(CXXFLAGS) $($@_CXXFLAGS) $(ERROR_SWITCH_ENUM) -MMD -MF $(call filename-to-dep, $@) -MP - -$(buildprefix)%.o: %.c - @mkdir -p "$(dir $@)" - $(trace-cc) $(CC) -o $@ -c $< $(CPPFLAGS) $(GLOBAL_CFLAGS) $(CFLAGS) $($@_CFLAGS) -MMD -MF $(call filename-to-dep, $@) -MP diff --git a/mk/precompiled-headers.mk b/mk/precompiled-headers.mk deleted file mode 100644 index cdd3daecd..000000000 --- a/mk/precompiled-headers.mk +++ /dev/null @@ -1,21 +0,0 @@ -PRECOMPILE_HEADERS ?= 0 - -print-var-help += \ - echo " PRECOMPILE_HEADERS ($(PRECOMPILE_HEADERS)): Whether to use precompiled headers to speed up the build"; - -GCH = $(buildprefix)precompiled-headers.h.gch - -$(GCH): precompiled-headers.h - @rm -f $@ - @mkdir -p "$(dir $@)" - $(trace-gen) $(CXX) -x c++-header -o $@ $< $(GLOBAL_CXXFLAGS) $(GCH_CXXFLAGS) - -clean-files += $(GCH) - -ifeq ($(PRECOMPILE_HEADERS), 1) - - GLOBAL_CXXFLAGS_PCH += -include $(buildprefix)precompiled-headers.h -Winvalid-pch - - GLOBAL_ORDER_AFTER += $(GCH) - -endif diff --git a/mk/programs.mk b/mk/programs.mk deleted file mode 100644 index 7768ef3eb..000000000 --- a/mk/programs.mk +++ /dev/null @@ -1,95 +0,0 @@ -programs-list := - -# Build a program with symbolic name $(1). The program is defined by -# various variables prefixed by ‘$(1)_’: -# -# - $(1)_NAME: the name of the program (e.g. ‘foo’); defaults to -# $(1). -# -# - $(1)_ENV: environment variables to set when running the program -# from the Makefile using the $(1)_RUN target. -# -# - $(1)_DIR: the directory where the (non-installed) program will be -# placed. -# -# - $(1)_SOURCES: the source files of the program. -# -# - $(1)_CFLAGS: additional C compiler flags. -# -# - $(1)_CXXFLAGS: additional C++ compiler flags. -# -# - $(1)_ORDER_AFTER: a set of targets on which the object files of -# this program will have an order-only dependency. -# -# - $(1)_LIBS: the symbolic names of libraries on which this program -# depends. -# -# - $(1)_LDFLAGS: additional linker flags. -# -# - $(1)_INSTALL_DIR: the directory where the program will be -# installed; defaults to $(bindir). -define build-program - $(1)_NAME ?= $(1) - _d := $(buildprefix)$$($(1)_DIR) - _srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src))) - $(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs)))) - _libs := $$(foreach lib, $$($(1)_LIBS), $$(foreach lib2, $$($$(lib)_LIB_CLOSURE), $$($$(lib2)_PATH))) - $(1)_PATH := $$(_d)/$$($(1)_NAME) - - $$(eval $$(call create-dir, $$(_d))) - - $$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/ - +$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) - - $(1)_INSTALL_DIR ?= $$(bindir) - - ifdef $(1)_INSTALL_DIR - - $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME) - - $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR))) - - install: $(DESTDIR)$$($(1)_INSTALL_PATH) - - ifeq ($(BUILD_SHARED_LIBS), 1) - - _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) - - $(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final) | $(DESTDIR)$$($(1)_INSTALL_DIR)/ - +$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED)) - - else - - $(DESTDIR)$$($(1)_INSTALL_PATH): $$($(1)_PATH) | $(DESTDIR)$$($(1)_INSTALL_DIR)/ - +$$(trace-install) install -t $(DESTDIR)$$($(1)_INSTALL_DIR) $$< - - endif - endif - - # Propagate CFLAGS and CXXFLAGS to the individual object files. - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CFLAGS=$$($(1)_CFLAGS))) - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS))) - - # Make each object file depend on the common dependencies. - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): $$($(1)_COMMON_DEPS) $$(GLOBAL_COMMON_DEPS))) - - # Make each object file have order-only dependencies on the common - # order-only dependencies. This includes the order-only dependencies - # of libraries we're depending on. - $(1)_ORDER_AFTER_CLOSED = $$($(1)_ORDER_AFTER) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_ORDER_AFTER_CLOSED)) - - $$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj): | $$($(1)_ORDER_AFTER_CLOSED) $$(GLOBAL_ORDER_AFTER))) - - # Include .dep files, if they exist. - $(1)_DEPS := $$(foreach fn, $$($(1)_OBJS), $$(call filename-to-dep, $$(fn))) - -include $$($(1)_DEPS) - - programs-list += $$($(1)_PATH) - clean-files += $$($(1)_PATH) $$(_d)/*.o $$(_d)/.*.dep $$($(1)_DEPS) $$($(1)_OBJS) - - # Phony target to run this program (typically as a dependency of 'check'). - .PHONY: $(1)_RUN - $(1)_RUN: $$($(1)_PATH) - $(trace-test) $$($(1)_ENV) $$($(1)_PATH) - -endef diff --git a/mk/run-test.sh b/mk/run-test.sh deleted file mode 100755 index 1a1d65930..000000000 --- a/mk/run-test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -red="" -green="" -yellow="" -normal="" - -test=$1 - -dir="$(dirname "${BASH_SOURCE[0]}")" -source "$dir/common-test.sh" - -post_run_msg="ran test $test..." -if [ -t 1 ]; then - red="" - green="" - yellow="" - normal="" -fi - -run_test () { - (init_test 2>/dev/null > /dev/null) - log="$(run_test_proper 2>&1)" && status=0 || status=$? -} - -run_test - -if [ $status -eq 0 ]; then - echo "$post_run_msg [${green}PASS$normal]" -elif [ $status -eq 99 ]; then - echo "$post_run_msg [${yellow}SKIP$normal]" -else - echo "$post_run_msg [${red}FAIL$normal]" - echo "$log" | sed 's/^/ /' - exit "$status" -fi diff --git a/mk/templates.mk b/mk/templates.mk deleted file mode 100644 index 866bdc17f..000000000 --- a/mk/templates.mk +++ /dev/null @@ -1,19 +0,0 @@ -template-files := - -# Create the file $(1) from $(1).in by running config.status (which -# substitutes all ‘@var@’ variables set by the configure script). -define instantiate-template - - clean-files += $(1) - -endef - -ifneq ($(MAKECMDGOALS), clean) - -$(buildprefix)%.h: %.h.in - $(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --header=$(@:$(buildprefix)%=%) - -$(buildprefix)%: %.in - $(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --file=$(@:$(buildprefix)%=%) - -endif diff --git a/mk/tests.mk b/mk/tests.mk deleted file mode 100644 index ec8128bdf..000000000 --- a/mk/tests.mk +++ /dev/null @@ -1,27 +0,0 @@ -# Run program $1 as part of ‘make installcheck’. - -test-deps = - -define run-install-test - - .PHONY: $1.test - $1.test: $1 $(test-deps) - @env BASH=$(bash) $(bash) mk/run-test.sh $1 < /dev/null - - .PHONY: $1.test-debug - $1.test-debug: $1 $(test-deps) - @env BASH=$(bash) $(bash) mk/debug-test.sh $1 < /dev/null - -endef - -define run-install-test-group - - .PHONY: $1.test-group - -endef - -.PHONY: check installcheck - -print-top-help += \ - echo " check: Run unit tests"; \ - echo " installcheck: Run functional tests"; diff --git a/mk/tracing.mk b/mk/tracing.mk deleted file mode 100644 index 1fc5573d7..000000000 --- a/mk/tracing.mk +++ /dev/null @@ -1,16 +0,0 @@ -V ?= 0 - -ifeq ($(V), 0) - - trace-gen = @echo " GEN " $@; - trace-cc = @echo " CC " $@; - trace-cxx = @echo " CXX " $@; - trace-ld = @echo " LD " $@; - trace-ar = @echo " AR " $@; - trace-install = @echo " INST " $@; - trace-mkdir = @echo " MKDIR " $@; - trace-test = @echo " TEST " $@; - - suppress = @ - -endif diff --git a/package.nix b/package.nix index 4abce3aad..579b33f3e 100644 --- a/package.nix +++ b/package.nix @@ -2,8 +2,6 @@ pkgs, lib, stdenv, - autoconf-archive, - autoreconfHook, aws-sdk-cpp, # If the patched version of Boehm isn't passed, then patch it based off of # pkgs.boehmgc. This allows `callPackage`ing this file without needing to @@ -62,10 +60,6 @@ # Avoid setting things that would interfere with a functioning devShell forDevShell ? false, - # FIXME(Qyriad): build Lix using Meson instead of autoconf and make. - # This flag will be removed when the migration to Meson is complete. - buildWithMeson ? true, - # Not a real argument, just the only way to approximate let-binding some # stuff for argument defaults. __forDefaults ? { @@ -109,8 +103,6 @@ let customMemoryManagement = false; }; - testConfigureFlags = [ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ]; - # Reimplementation of Nixpkgs' Meson cross file, with some additions to make # it actually work. mesonCrossFile = @@ -151,26 +143,14 @@ let # that would interfere with repo semantics. baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.; - configureFiles = fileset.unions [ - ./.version - ./configure.ac - ./m4 - ]; + configureFiles = fileset.unions [ ./.version ]; - topLevelBuildFiles = fileset.unions ( - [ - ./local.mk - ./Makefile - ./Makefile.config.in - ./mk - ] - ++ lib.optionals buildWithMeson [ - ./meson.build - ./meson.options - ./meson - ./scripts/meson.build - ] - ); + topLevelBuildFiles = fileset.unions ([ + ./meson.build + ./meson.options + ./meson + ./scripts/meson.build + ]); functionalTestFiles = fileset.unions [ ./tests/functional @@ -197,7 +177,6 @@ stdenv.mkDerivation (finalAttrs: { ./precompiled-headers.h ./src ./COPYING - ./scripts/local.mk ] ) ); @@ -214,10 +193,12 @@ stdenv.mkDerivation (finalAttrs: { dontBuild = false; - # FIXME(Qyriad): see if this is still needed once the migration to Meson is completed. mesonFlags = - lib.optionals (buildWithMeson && stdenv.hostPlatform.isLinux) [ - "-Dsandbox-shell=${lib.getBin busybox-sandbox-shell}/bin/busybox" + lib.optionals stdenv.hostPlatform.isLinux [ + # You'd think meson could just find this in PATH, but busybox is in buildInputs, + # which don't actually get added to PATH. And buildInputs is correct over + # nativeBuildInputs since this should be a busybox executable on the host. + "-Dsandbox-shell=${lib.getExe' busybox-sandbox-shell "busybox"}" ] ++ lib.optional stdenv.hostPlatform.isStatic "-Denable-embedded-sandbox-shell=true" ++ lib.optional (finalAttrs.dontBuild) "-Denable-build=false" @@ -239,14 +220,15 @@ stdenv.mkDerivation (finalAttrs: { bison flex python3 + meson + ninja + cmake ] ++ [ (lib.getBin lowdown) mdbook mdbook-linkcheck - autoconf-archive ] - ++ lib.optional (!buildWithMeson) autoreconfHook ++ [ pkg-config @@ -258,12 +240,7 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal ++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes - ++ lib.optional (internalApiDocs || forDevShell) doxygen - ++ lib.optionals buildWithMeson [ - meson - ninja - cmake - ]; + ++ lib.optional (internalApiDocs || forDevShell) doxygen; buildInputs = [ @@ -302,7 +279,7 @@ stdenv.mkDerivation (finalAttrs: { # Needed for Meson to find Boost. # https://github.com/NixOS/nixpkgs/issues/86131. - env = lib.optionalAttrs (buildWithMeson || forDevShell) { + env = { BOOST_INCLUDEDIR = "${lib.getDev boost}/include"; BOOST_LIBRARYDIR = "${lib.getLib boost}/lib"; }; @@ -336,37 +313,20 @@ stdenv.mkDerivation (finalAttrs: { fi ''; - configureFlags = - [ "--with-boost=${boost}/lib" ] - ++ lib.optionals stdenv.isLinux [ "--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox" ] - ++ lib.optionals ( - stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux") - ) [ "LDFLAGS=-fuse-ld=gold" ] - ++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" - ++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags - ++ lib.optional (!canRunInstalled) "--disable-doc-gen" - ++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ] - ++ lib.optional (!forDevShell) "--sysconfdir=/etc" - ++ [ "TOML11_HEADERS=${lib.getDev toml11}/include" ]; - - mesonBuildType = lib.optional (buildWithMeson || forDevShell) "debugoptimized"; + mesonBuildType = "debugoptimized"; installTargets = lib.optional internalApiDocs "internal-api-html"; enableParallelBuilding = true; - makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1"; - doCheck = canRunInstalled; - mesonCheckFlags = lib.optionals (buildWithMeson || forDevShell) [ "--suite=check" ]; - - installFlags = "sysconfdir=$(out)/etc"; + mesonCheckFlags = [ "--suite=check" ]; # Make sure the internal API docs are already built, because mesonInstallPhase # won't let us build them there. They would normally be built in buildPhase, # but the internal API docs are conventionally built with doBuild = false. - preInstall = lib.optional (buildWithMeson && internalApiDocs) '' + preInstall = lib.optional internalApiDocs '' meson ''${mesonBuildFlags:-} compile "$installTargets" ''; @@ -393,12 +353,10 @@ stdenv.mkDerivation (finalAttrs: { ''; doInstallCheck = finalAttrs.doCheck; - installCheckFlags = "sysconfdir=$(out)/etc"; - installCheckTarget = "installcheck"; # work around buggy detection in stdenv mesonInstallCheckFlags = [ "--suite=installcheck" ]; - installCheckPhase = lib.optionalString buildWithMeson '' + installCheckPhase = '' runHook preInstallCheck flagsArray=($mesonInstallCheckFlags "''${mesonInstallCheckFlagsArray[@]}") meson test --no-rebuild "''${flagsArray[@]}" @@ -414,7 +372,7 @@ stdenv.mkDerivation (finalAttrs: { meta.platforms = lib.platforms.unix; - passthru.perl-bindings = pkgs.callPackage ./perl { inherit fileset stdenv buildWithMeson; }; + passthru.perl-bindings = pkgs.callPackage ./perl { inherit fileset stdenv; }; # Export the patched version of boehmgc & libseccomp. # flake.nix exports that into its overlay. diff --git a/perl/Makefile b/perl/Makefile deleted file mode 100644 index 832668dd1..000000000 --- a/perl/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -makefiles = local.mk - -GLOBAL_CXXFLAGS += -g -Wall -std=c++2a - -# A convenience for concurrent development of Nix and its Perl bindings. -# Not needed in a standalone build of the Perl bindings. -ifneq ("$(wildcard ../src)", "") - GLOBAL_CXXFLAGS += -I ../src -endif - --include Makefile.config - -OPTIMIZE = 1 - -ifeq ($(OPTIMIZE), 1) - GLOBAL_CXXFLAGS += -O3 -else - GLOBAL_CXXFLAGS += -O0 -endif - -include mk/lib.mk diff --git a/perl/Makefile.config.in b/perl/Makefile.config.in deleted file mode 100644 index d856de3ad..000000000 --- a/perl/Makefile.config.in +++ /dev/null @@ -1,18 +0,0 @@ -HOST_OS = @host_os@ -CC = @CC@ -CFLAGS = @CFLAGS@ -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -SODIUM_LIBS = @SODIUM_LIBS@ -NIX_CFLAGS = @NIX_CFLAGS@ -NIX_LIBS = @NIX_LIBS@ -nixbindir = @nixbindir@ -curl = @curl@ -nixlibexecdir = @nixlibexecdir@ -nixlocalstatedir = @nixlocalstatedir@ -perl = @perl@ -perllibdir = @perllibdir@ -nixstoredir = @nixstoredir@ -nixsysconfdir = @nixsysconfdir@ diff --git a/perl/default.nix b/perl/default.nix index af700eabe..7ce418402 100644 --- a/perl/default.nix +++ b/perl/default.nix @@ -4,8 +4,6 @@ stdenv, perl, perlPackages, - autoconf-archive, - autoreconfHook, pkg-config, nix, curl, @@ -16,7 +14,6 @@ darwin, meson, ninja, - buildWithMeson ? false, }: perl.pkgs.toPerlModule ( @@ -25,36 +22,18 @@ perl.pkgs.toPerlModule ( src = fileset.toSource { root = ../.; - fileset = fileset.unions ( - [ - ../.version - ./lib - ] - ++ lib.optionals (!buildWithMeson) [ - # FIXME(Qyriad): What the hell is this? - # What is it used for and do we still need it? - ./MANIFEST - ../m4 - ../mk - ./Makefile - ./Makefile.config.in - ./configure.ac - ./local.mk - ] - ++ lib.optionals buildWithMeson [ ./meson.build ] - ); + fileset = fileset.unions ([ + ../.version + ./lib + ./meson.build + ]); }; - nativeBuildInputs = - [ pkg-config ] - ++ lib.optionals (!buildWithMeson) [ - autoconf-archive - autoreconfHook - ] - ++ lib.optionals buildWithMeson [ - meson - ninja - ]; + nativeBuildInputs = [ + pkg-config + meson + ninja + ]; buildInputs = [ diff --git a/perl/local.mk b/perl/local.mk deleted file mode 100644 index 0eae651d8..000000000 --- a/perl/local.mk +++ /dev/null @@ -1,43 +0,0 @@ -nix_perl_sources := \ - lib/Nix/Store.pm \ - lib/Nix/Manifest.pm \ - lib/Nix/SSH.pm \ - lib/Nix/CopyClosure.pm \ - lib/Nix/Config.pm.in \ - lib/Nix/Utils.pm - -nix_perl_modules := $(nix_perl_sources:.in=) - -$(foreach x, $(nix_perl_modules), $(eval $(call install-data-in, $(x), $(perllibdir)/Nix))) - -lib/Nix/Store.cc: lib/Nix/Store.xs - $(trace-gen) xsubpp $^ -output $@ - -libraries += Store - -Store_DIR := lib/Nix - -Store_SOURCES := $(Store_DIR)/Store.cc - -Store_CXXFLAGS = \ - $(NIX_CFLAGS) \ - -I$(shell perl -e 'use Config; print $$Config{archlibexp};')/CORE \ - -D_FILE_OFFSET_BITS=64 \ - -Wno-unknown-warning-option -Wno-unused-variable -Wno-literal-suffix \ - -Wno-reserved-user-defined-literal -Wno-duplicate-decl-specifier -Wno-pointer-bool-conversion - -Store_LDFLAGS := $(SODIUM_LIBS) $(NIX_LIBS) - -ifdef HOST_CYGWIN - archlib = $(shell perl -E 'use Config; print $$Config{archlib};') - libperl = $(shell perl -E 'use Config; print $$Config{libperl};') - Store_LDFLAGS += $(shell find ${archlib} -name ${libperl}) -endif - -Store_ALLOW_UNDEFINED = 1 - -Store_FORCE_INSTALL = 1 - -Store_INSTALL_DIR = $(perllibdir)/auto/Nix/Store - -clean-files += lib/Nix/Config.pm lib/Nix/Store.cc Makefile.config diff --git a/scripts/local.mk b/scripts/local.mk deleted file mode 100644 index 46255e432..000000000 --- a/scripts/local.mk +++ /dev/null @@ -1,13 +0,0 @@ -nix_noinst_scripts := \ - $(d)/nix-profile.sh - -noinst-scripts += $(nix_noinst_scripts) - -profiledir = $(sysconfdir)/profile.d - -$(eval $(call install-file-as, $(d)/nix-profile.sh, $(profiledir)/nix.sh, 0644)) -$(eval $(call install-file-as, $(d)/nix-profile.fish, $(profiledir)/nix.fish, 0644)) -$(eval $(call install-file-as, $(d)/nix-profile-daemon.sh, $(profiledir)/nix-daemon.sh, 0644)) -$(eval $(call install-file-as, $(d)/nix-profile-daemon.fish, $(profiledir)/nix-daemon.fish, 0644)) - -clean-files += $(nix_noinst_scripts) diff --git a/src/libcmd/local.mk b/src/libcmd/local.mk deleted file mode 100644 index 5d0e3ed7e..000000000 --- a/src/libcmd/local.mk +++ /dev/null @@ -1,17 +0,0 @@ -libraries += libcmd - -libcmd_NAME = libnixcmd - -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 - -libcmd_LDFLAGS = $(EDITLINE_LIBS) $(LOWDOWN_LIBS) $(NIXDOC_LIBS) -pthread - -libcmd_LIBS = libstore libutil libexpr libmain libfetchers - -$(eval $(call install-file-in, $(buildprefix)$(d)/nix-cmd.pc, $(libdir)/pkgconfig, 0644)) - -$(d)/repl.cc: $(d)/repl-overlays.nix.gen.hh diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk deleted file mode 100644 index ed6bc761a..000000000 --- a/src/libexpr/local.mk +++ /dev/null @@ -1,50 +0,0 @@ -libraries += libexpr - -libexpr_NAME = libnixexpr - -libexpr_DIR := $(d) - -libexpr_SOURCES := \ - $(wildcard $(d)/*.cc) \ - $(wildcard $(d)/value/*.cc) \ - $(wildcard $(d)/primops/*.cc) \ - $(wildcard $(d)/flake/*.cc) \ - $(d)/lexer-tab.cc \ - $(d)/parser-tab.cc - -libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libmain -I src/libexpr - -libexpr_LIBS = libutil libstore libfetchers - -libexpr_LDFLAGS += -lboost_context -pthread -ifdef HOST_LINUX - libexpr_LDFLAGS += -ldl -endif - -# The dependency on libgc must be propagated (i.e. meaning that -# programs/libraries that use libexpr must explicitly pass -lgc), -# because inline functions in libexpr's header files call libgc. -libexpr_LDFLAGS_PROPAGATED = $(BDW_GC_LIBS) - -libexpr_ORDER_AFTER := $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh - -$(d)/parser-tab.cc $(d)/parser-tab.hh: $(d)/parser.y - $(trace-gen) bison -v -o $(libexpr_DIR)/parser-tab.cc $< -d - -$(d)/lexer-tab.cc $(d)/lexer-tab.hh: $(d)/lexer.l - $(trace-gen) flex --outfile $(libexpr_DIR)/lexer-tab.cc --header-file=$(libexpr_DIR)/lexer-tab.hh $< - -clean-files += $(d)/parser-tab.cc $(d)/parser-tab.hh $(d)/lexer-tab.cc $(d)/lexer-tab.hh - -$(eval $(call install-file-in, $(buildprefix)$(d)/nix-expr.pc, $(libdir)/pkgconfig, 0644)) - -$(foreach i, $(wildcard src/libexpr/value/*.hh), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/value, 0644))) -$(foreach i, $(wildcard src/libexpr/flake/*.hh), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/flake, 0644))) - -$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh - -$(d)/eval.cc: $(d)/primops/derivation.nix.gen.hh $(d)/fetchurl.nix.gen.hh $(d)/flake/call-flake.nix.gen.hh - -$(buildprefix)src/libexpr/primops/fromTOML.o: ERROR_SWITCH_ENUM = diff --git a/src/libfetchers/local.mk b/src/libfetchers/local.mk deleted file mode 100644 index 2e8869d83..000000000 --- a/src/libfetchers/local.mk +++ /dev/null @@ -1,13 +0,0 @@ -libraries += libfetchers - -libfetchers_NAME = libnixfetchers - -libfetchers_DIR := $(d) - -libfetchers_SOURCES := $(wildcard $(d)/*.cc) - -libfetchers_CXXFLAGS += -I src/libutil -I src/libstore - -libfetchers_LDFLAGS += -pthread - -libfetchers_LIBS = libutil libstore diff --git a/src/libmain/local.mk b/src/libmain/local.mk deleted file mode 100644 index 5c7061863..000000000 --- a/src/libmain/local.mk +++ /dev/null @@ -1,17 +0,0 @@ -libraries += libmain - -libmain_NAME = libnixmain - -libmain_DIR := $(d) - -libmain_SOURCES := $(wildcard $(d)/*.cc) - -libmain_CXXFLAGS += -I src/libutil -I src/libstore - -libmain_LDFLAGS += $(OPENSSL_LIBS) - -libmain_LIBS = libstore libutil - -libmain_ALLOW_UNDEFINED = 1 - -$(eval $(call install-file-in, $(buildprefix)$(d)/nix-main.pc, $(libdir)/pkgconfig, 0644)) diff --git a/src/libstore/local.mk b/src/libstore/local.mk deleted file mode 100644 index 078a63c83..000000000 --- a/src/libstore/local.mk +++ /dev/null @@ -1,75 +0,0 @@ -libraries += libstore - -libstore_NAME = libnixstore - -libstore_DIR := $(d) - -libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc $(d)/build/*.cc) -ifdef HOST_LINUX -libstore_SOURCES += $(d)/platform/linux.cc -else ifdef HOST_DARWIN -libstore_SOURCES += $(d)/platform/darwin.cc -else -libstore_SOURCES += $(d)/platform/fallback.cc -endif - -libstore_LIBS = libutil - -libstore_LDFLAGS += $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread -ifdef HOST_LINUX - libstore_LDFLAGS += -ldl -endif - -$(foreach file,$(libstore_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/sandbox))) - -ifeq ($(ENABLE_S3), 1) - libstore_LDFLAGS += -laws-cpp-sdk-transfer -laws-cpp-sdk-s3 -laws-cpp-sdk-core -laws-crt-cpp -endif - -ifdef HOST_SOLARIS - libstore_LDFLAGS += -lsocket -endif - -ifeq ($(HAVE_SECCOMP), 1) - libstore_LDFLAGS += $(LIBSECCOMP_LIBS) -endif - -libstore_CXXFLAGS += \ - -I src/libutil -I src/libstore -I src/libstore/build \ - -DNIX_PREFIX=\"$(prefix)\" \ - -DNIX_STORE_DIR=\"$(storedir)\" \ - -DNIX_DATA_DIR=\"$(datadir)\" \ - -DNIX_STATE_DIR=\"$(localstatedir)/nix\" \ - -DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \ - -DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \ - -DNIX_BIN_DIR=\"$(bindir)\" \ - -DNIX_MAN_DIR=\"$(mandir)\" \ - -DLSOF=\"$(lsof)\" - -ifeq ($(embedded_sandbox_shell),yes) -libstore_CXXFLAGS += -DSANDBOX_SHELL=\"__embedded_sandbox_shell__\" - -$(d)/build/local-derivation-goal.cc: $(d)/embedded-sandbox-shell.gen.hh - -$(d)/embedded-sandbox-shell.gen.hh: $(sandbox_shell) - $(trace-gen) hexdump -v -e '1/1 "0x%x," "\n"' < $< > $@.tmp - @mv $@.tmp $@ -else -ifneq ($(sandbox_shell),) -libstore_CXXFLAGS += -DSANDBOX_SHELL="\"$(sandbox_shell)\"" -endif -endif - -$(d)/local-store.cc: $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh - -$(d)/build.cc: - -clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh - -$(eval $(call install-file-in, $(buildprefix)$(d)/nix-store.pc, $(libdir)/pkgconfig, 0644)) - -$(foreach i, $(wildcard src/libstore/builtins/*.hh), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/builtins, 0644))) - -$(foreach i, $(wildcard src/libstore/build/*.hh), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/build, 0644))) diff --git a/src/libutil/local.mk b/src/libutil/local.mk deleted file mode 100644 index 81efaafec..000000000 --- a/src/libutil/local.mk +++ /dev/null @@ -1,18 +0,0 @@ -libraries += libutil - -libutil_NAME = libnixutil - -libutil_DIR := $(d) - -libutil_SOURCES := $(wildcard $(d)/*.cc) - -libutil_CXXFLAGS += -I src/libutil - -libutil_LDFLAGS += -pthread $(OPENSSL_LIBS) $(LIBBROTLI_LIBS) $(LIBARCHIVE_LIBS) $(BOOST_LDFLAGS) -lboost_context - -$(foreach i, $(wildcard $(d)/args/*.hh), \ - $(eval $(call install-file-in, $(i), $(includedir)/nix/args, 0644))) - -ifeq ($(HAVE_LIBCPUID), 1) - libutil_LDFLAGS += -lcpuid -endif diff --git a/src/nix/local.mk b/src/nix/local.mk deleted file mode 100644 index 20ea29d10..000000000 --- a/src/nix/local.mk +++ /dev/null @@ -1,40 +0,0 @@ -programs += nix - -nix_DIR := $(d) - -nix_SOURCES := \ - $(wildcard $(d)/*.cc) \ - $(wildcard src/build-remote/*.cc) \ - $(wildcard src/nix-build/*.cc) \ - $(wildcard src/nix-channel/*.cc) \ - $(wildcard src/nix-collect-garbage/*.cc) \ - $(wildcard src/nix-copy-closure/*.cc) \ - $(wildcard src/nix-daemon/*.cc) \ - $(wildcard src/nix-env/*.cc) \ - $(wildcard src/nix-instantiate/*.cc) \ - $(wildcard src/nix-store/*.cc) \ - -nix_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libexpr -I src/libmain -I src/libcmd -I doc/manual - -nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd - -nix_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS) - -$(foreach name, \ - nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \ - $(eval $(call install-symlink, nix, $(bindir)/$(name)))) -$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote)) - -src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh - -src/nix/develop.cc: src/nix/get-env.sh.gen.hh - -src/nix-channel/nix-channel.cc: src/nix-channel/unpack-channel.nix.gen.hh - -src/nix/main.cc: doc/manual/generate-manpage.nix.gen.hh doc/manual/utils.nix.gen.hh - -src/nix/doc/files/%.md: doc/manual/src/command-ref/files/%.md - @mkdir -p $$(dirname $@) - @cp $< $@ - -src/nix/profile.cc: src/nix/profile.md src/nix/doc/files/profiles.md.gen.hh diff --git a/src/resolve-system-dependencies/local.mk b/src/resolve-system-dependencies/local.mk deleted file mode 100644 index fc48a8417..000000000 --- a/src/resolve-system-dependencies/local.mk +++ /dev/null @@ -1,13 +0,0 @@ -ifdef HOST_DARWIN - programs += resolve-system-dependencies -endif - -resolve-system-dependencies_DIR := $(d) - -resolve-system-dependencies_INSTALL_DIR := $(libexecdir)/nix - -resolve-system-dependencies_CXXFLAGS += -I src/libutil -I src/libstore -I src/libmain - -resolve-system-dependencies_LIBS := libstore libmain libutil - -resolve-system-dependencies_SOURCES := $(d)/resolve-system-dependencies.cc diff --git a/tests/functional/ca/local.mk b/tests/functional/ca/local.mk deleted file mode 100644 index 4f86b268f..000000000 --- a/tests/functional/ca/local.mk +++ /dev/null @@ -1,29 +0,0 @@ -ca-tests := \ - $(d)/build-with-garbage-path.sh \ - $(d)/build.sh \ - $(d)/build-cache.sh \ - $(d)/concurrent-builds.sh \ - $(d)/derivation-json.sh \ - $(d)/duplicate-realisation-in-closure.sh \ - $(d)/eval-store.sh \ - $(d)/gc.sh \ - $(d)/import-derivation.sh \ - $(d)/new-build-cmd.sh \ - $(d)/nix-copy.sh \ - $(d)/nix-run.sh \ - $(d)/nix-shell.sh \ - $(d)/post-hook.sh \ - $(d)/recursive.sh \ - $(d)/repl.sh \ - $(d)/selfref-gc.sh \ - $(d)/signatures.sh \ - $(d)/substitute.sh \ - $(d)/why-depends.sh - -install-tests-groups += ca - -clean-files += \ - $(d)/config.nix - -test-deps += \ - tests/functional/ca/config.nix diff --git a/tests/functional/dyn-drv/local.mk b/tests/functional/dyn-drv/local.mk deleted file mode 100644 index c87534944..000000000 --- a/tests/functional/dyn-drv/local.mk +++ /dev/null @@ -1,15 +0,0 @@ -dyn-drv-tests := \ - $(d)/text-hashed-output.sh \ - $(d)/recursive-mod-json.sh \ - $(d)/build-built-drv.sh \ - $(d)/eval-outputOf.sh \ - $(d)/dep-built-drv.sh \ - $(d)/old-daemon-error-hack.sh - -install-tests-groups += dyn-drv - -clean-files += \ - $(d)/config.nix - -test-deps += \ - tests/functional/dyn-drv/config.nix diff --git a/tests/functional/local.mk b/tests/functional/local.mk deleted file mode 100644 index 417c78509..000000000 --- a/tests/functional/local.mk +++ /dev/null @@ -1,156 +0,0 @@ -nix_tests = \ - test-infra.sh \ - init.sh \ - flakes/flakes.sh \ - flakes/develop.sh \ - flakes/develop-r8854.sh \ - flakes/run.sh \ - flakes/mercurial.sh \ - flakes/circular.sh \ - flakes/init.sh \ - flakes/inputs.sh \ - flakes/follow-paths.sh \ - flakes/bundle.sh \ - flakes/check.sh \ - flakes/unlocked-override.sh \ - flakes/absolute-paths.sh \ - flakes/build-paths.sh \ - flakes/flake-in-submodule.sh \ - gc.sh \ - nix-collect-garbage-d.sh \ - remote-store.sh \ - legacy-ssh-store.sh \ - lang.sh \ - lang-test-infra.sh \ - experimental-features.sh \ - fetchMercurial.sh \ - gc-auto.sh \ - user-envs.sh \ - user-envs-migration.sh \ - binary-cache.sh \ - multiple-outputs.sh \ - nix-build.sh \ - gc-concurrent.sh \ - repair.sh \ - fixed.sh \ - export-graph.sh \ - timeout.sh \ - fetchGitRefs.sh \ - gc-runtime.sh \ - tarball.sh \ - fetchGit.sh \ - fetchurl.sh \ - fetchPath.sh \ - fetchTree-file.sh \ - simple.sh \ - referrers.sh \ - optimise-store.sh \ - substitute-with-invalid-ca.sh \ - signing.sh \ - hash.sh \ - gc-non-blocking.sh \ - check.sh \ - nix-shell.sh \ - check-refs.sh \ - build-remote-input-addressed.sh \ - secure-drv-outputs.sh \ - restricted.sh \ - fetchGitSubmodules.sh \ - flakes/search-root.sh \ - readfile-context.sh \ - nix-channel.sh \ - recursive.sh \ - dependencies.sh \ - check-reqs.sh \ - build-remote-content-addressed-fixed.sh \ - build-remote-content-addressed-floating.sh \ - build-remote-trustless-should-pass-0.sh \ - build-remote-trustless-should-pass-1.sh \ - build-remote-trustless-should-pass-2.sh \ - build-remote-trustless-should-pass-3.sh \ - build-remote-trustless-should-fail-0.sh \ - nar-access.sh \ - impure-eval.sh \ - pure-eval.sh \ - eval.sh \ - repl.sh \ - binary-cache-build-remote.sh \ - search.sh \ - logging.sh \ - export.sh \ - config.sh \ - add.sh \ - local-store.sh \ - filter-source.sh \ - misc.sh \ - dump-db.sh \ - linux-sandbox.sh \ - supplementary-groups.sh \ - build-dry.sh \ - structured-attrs.sh \ - shell.sh \ - brotli.sh \ - zstd.sh \ - compression-levels.sh \ - nix-copy-ssh.sh \ - nix-copy-ssh-ng.sh \ - post-hook.sh \ - function-trace.sh \ - flakes/config.sh \ - fmt.sh \ - eval-store.sh \ - why-depends.sh \ - derivation-json.sh \ - import-derivation.sh \ - nix_path.sh \ - case-hack.sh \ - placeholders.sh \ - ssh-relay.sh \ - build.sh \ - build-delete.sh \ - output-normalization.sh \ - selfref-gc.sh \ - db-migration.sh \ - bash-profile.sh \ - pass-as-file.sh \ - nix-profile.sh \ - suggestions.sh \ - store-ping.sh \ - fetchClosure.sh \ - completions.sh \ - flakes/show.sh \ - impure-derivations.sh \ - path-from-hash-part.sh \ - toString-path.sh \ - read-only-store.sh \ - nested-sandboxing.sh \ - debugger.sh - -ifeq ($(HAVE_LIBCPUID), 1) - nix_tests += compute-levels.sh -endif - -ifeq ($(ENABLE_BUILD), yes) - nix_tests += test-libstoreconsumer.sh test-repl-characterization.sh - - ifeq ($(BUILD_SHARED_LIBS), 1) - nix_tests += plugins.sh - endif -endif - -$(d)/test-libstoreconsumer.sh.test $(d)/test-libstoreconsumer.sh.test-debug: \ - $(buildprefix)$(d)/test-libstoreconsumer/test-libstoreconsumer -$(d)/plugins.sh.test $(d)/plugins.sh.test-debug: \ - $(buildprefix)$(d)/plugins/libplugintest.$(SO_EXT) \ - $(buildprefix)$(d)/plugins/libplugintestfail.$(SO_EXT) -$(d)/test-repl-characterization.sh.test $(d)/test-repl-characterization.sh.test-debug: \ - $(buildprefix)$(d)/repl_characterization/test-repl-characterization - -install-tests += $(foreach x, $(nix_tests), $(d)/$(x)) - -test-clean-files := \ - $(d)/common/vars-and-functions.sh \ - $(d)/config.nix - -clean-files += $(test-clean-files) -test-deps += $(test-clean-files) diff --git a/tests/functional/plugins/local.mk b/tests/functional/plugins/local.mk deleted file mode 100644 index 77339d4c6..000000000 --- a/tests/functional/plugins/local.mk +++ /dev/null @@ -1,27 +0,0 @@ -libraries += libplugintest libplugintestfail - -libplugintest_DIR := $(d) - -libplugintest_SOURCES := $(d)/plugintest.cc - -libplugintest_ALLOW_UNDEFINED := 1 - -libplugintest_EXCLUDE_FROM_LIBRARY_LIST := 1 - -libplugintest_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr -I src/libfetchers - -libplugintestfail_DIR := $(d) - -libplugintestfail_SOURCES := $(d)/plugintestfail.cc - -libplugintestfail_ALLOW_UNDEFINED := 1 - -libplugintestfail_EXCLUDE_FROM_LIBRARY_LIST := 1 - -libplugintestfail_CXXFLAGS := -I src/libutil -I src/libstore -I src/libexpr -I src/libfetchers -DMISSING_REFERENCE - -# Make sure that the linker strictly evaluates all symbols on .so load on Linux -# so it will definitely fail to load as expected. -ifdef HOST_LINUX - libplugintestfail_LDFLAGS += -z now -endif diff --git a/tests/functional/repl_characterization/local.mk b/tests/functional/repl_characterization/local.mk deleted file mode 100644 index aa0cf3615..000000000 --- a/tests/functional/repl_characterization/local.mk +++ /dev/null @@ -1,15 +0,0 @@ -programs += test-repl-characterization - -test-repl-characterization_DIR := $(d) - -# do not install -test-repl-characterization_INSTALL_DIR := - -test-repl-characterization_SOURCES := \ - $(wildcard $(d)/*.cc) \ - -test-repl-characterization_CXXFLAGS += -I src/libutil -I tests/unit/libutil-support -DNIX_BIN_DIR="\"$(bindir)\"" - -test-repl-characterization_LIBS = libutil libutil-test-support - -test-repl-characterization_LDFLAGS = $(THREAD_LDFLAGS) $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS) $(GTEST_LIBS) diff --git a/tests/functional/test-libstoreconsumer/local.mk b/tests/functional/test-libstoreconsumer/local.mk deleted file mode 100644 index edc140723..000000000 --- a/tests/functional/test-libstoreconsumer/local.mk +++ /dev/null @@ -1,15 +0,0 @@ -programs += test-libstoreconsumer - -test-libstoreconsumer_DIR := $(d) - -# do not install -test-libstoreconsumer_INSTALL_DIR := - -test-libstoreconsumer_SOURCES := \ - $(wildcard $(d)/*.cc) \ - -test-libstoreconsumer_CXXFLAGS += -I src/libutil -I src/libstore - -test-libstoreconsumer_LIBS = libstore libutil - -test-libstoreconsumer_LDFLAGS = -pthread $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS) diff --git a/tests/unit/libexpr-support/local.mk b/tests/unit/libexpr-support/local.mk deleted file mode 100644 index ce0d9950c..000000000 --- a/tests/unit/libexpr-support/local.mk +++ /dev/null @@ -1,19 +0,0 @@ -libraries += libexpr-test-support - -libexpr-test-support_NAME = libnixexpr-test-support - -libexpr-test-support_DIR := $(d) - -libexpr-test-support_INSTALL_DIR := - -libexpr-test-support_SOURCES := \ - $(wildcard $(d)/tests/*.cc) \ - $(wildcard $(d)/tests/value/*.cc) - -libexpr-test-support_CXXFLAGS += $(libexpr-tests_EXTRA_INCLUDES) - -libexpr-test-support_LIBS = \ - libstore-test-support libutil-test-support \ - libexpr libstore libutil - -libexpr-test-support_LDFLAGS := -pthread -lrapidcheck diff --git a/tests/unit/libexpr/local.mk b/tests/unit/libexpr/local.mk deleted file mode 100644 index 068dd7a17..000000000 --- a/tests/unit/libexpr/local.mk +++ /dev/null @@ -1,32 +0,0 @@ -check: libexpr-tests_RUN - -programs += libexpr-tests - -libexpr-tests_NAME := libnixexpr-tests - -libexpr-tests_ENV := _NIX_TEST_UNIT_DATA=$(d)/data - -libexpr-tests_DIR := $(d) - -libexpr-tests_INSTALL_DIR := - -libexpr-tests_SOURCES := \ - $(wildcard $(d)/*.cc) \ - $(wildcard $(d)/value/*.cc) - -libexpr-tests_EXTRA_INCLUDES = \ - -I tests/unit/libexpr-support \ - -I tests/unit/libstore-support \ - -I tests/unit/libutil-support \ - -I src/libexpr \ - -I src/libfetchers \ - -I src/libstore \ - -I src/libutil - -libexpr-tests_CXXFLAGS += $(libexpr-tests_EXTRA_INCLUDES) - -libexpr-tests_LIBS = \ - libexpr-test-support libstore-test-support libutils-test-support \ - libexpr libfetchers libstore libutil - -libexpr-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) -lgmock diff --git a/tests/unit/libstore-support/local.mk b/tests/unit/libstore-support/local.mk deleted file mode 100644 index 59c3e09ca..000000000 --- a/tests/unit/libstore-support/local.mk +++ /dev/null @@ -1,17 +0,0 @@ -libraries += libstore-test-support - -libstore-test-support_NAME = libnixstore-test-support - -libstore-test-support_DIR := $(d) - -libstore-test-support_INSTALL_DIR := - -libstore-test-support_SOURCES := $(wildcard $(d)/tests/*.cc) - -libstore-test-support_CXXFLAGS += $(libstore-tests_EXTRA_INCLUDES) - -libstore-test-support_LIBS = \ - libutil-test-support \ - libstore libutil - -libstore-test-support_LDFLAGS := -pthread -lrapidcheck diff --git a/tests/unit/libstore/local.mk b/tests/unit/libstore/local.mk deleted file mode 100644 index fb7385ec1..000000000 --- a/tests/unit/libstore/local.mk +++ /dev/null @@ -1,27 +0,0 @@ -check: libstore-tests_RUN - -programs += libstore-tests - -libstore-tests_NAME = libnixstore-tests - -libstore-tests_ENV := _NIX_TEST_UNIT_DATA=$(d)/data - -libstore-tests_DIR := $(d) - -libstore-tests_INSTALL_DIR := - -libstore-tests_SOURCES := $(wildcard $(d)/*.cc) - -libstore-tests_EXTRA_INCLUDES = \ - -I tests/unit/libstore-support \ - -I tests/unit/libutil-support \ - -I src/libstore \ - -I src/libutil - -libstore-tests_CXXFLAGS += $(libstore-tests_EXTRA_INCLUDES) - -libstore-tests_LIBS = \ - libstore-test-support libutil-test-support \ - libstore libutil - -libstore-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) diff --git a/tests/unit/libutil-support/local.mk b/tests/unit/libutil-support/local.mk deleted file mode 100644 index 67fd92d77..000000000 --- a/tests/unit/libutil-support/local.mk +++ /dev/null @@ -1,16 +0,0 @@ -libraries += libutil-test-support - -libutil-test-support_NAME = libnixutil-test-support - -libutil-test-support_DIR := $(d) - -libutil-test-support_INSTALL_DIR := - -libutil-test-support_SOURCES := $(wildcard $(d)/tests/*.cc) - -libutil-test-support_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES) -I src/libutil - -# libexpr so we can steal their string printer from print.cc -libutil-test-support_LIBS = libutil libexpr - -libutil-test-support_LDFLAGS := -pthread -lrapidcheck diff --git a/tests/unit/libutil/local.mk b/tests/unit/libutil/local.mk deleted file mode 100644 index 6de96c0dc..000000000 --- a/tests/unit/libutil/local.mk +++ /dev/null @@ -1,23 +0,0 @@ -check: libutil-tests_RUN - -programs += libutil-tests - -libutil-tests_NAME = libnixutil-tests - -libutil-tests_ENV := _NIX_TEST_UNIT_DATA=$(d)/data - -libutil-tests_DIR := $(d) - -libutil-tests_INSTALL_DIR := - -libutil-tests_SOURCES := $(wildcard $(d)/*.cc) - -libutil-tests_EXTRA_INCLUDES = \ - -I tests/unit/libutil-support \ - -I src/libutil - -libutil-tests_CXXFLAGS += $(libutil-tests_EXTRA_INCLUDES) - -libutil-tests_LIBS = libutil-test-support libutil - -libutil-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) From 55ade699dcf64c092d7e37eff23bf59a977e5c0c Mon Sep 17 00:00:00 2001 From: Qyriad Date: Tue, 7 May 2024 14:40:18 -0600 Subject: [PATCH 4/5] package: default the build-release-notes arg like we do with lix-doc Change-Id: I0e2df55efc1cd6ea0a3252b9f26676e84612fdb6 --- package.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.nix b/package.nix index 579b33f3e..6f9fe81b4 100644 --- a/package.nix +++ b/package.nix @@ -11,7 +11,7 @@ boehmgc, nlohmann_json, bison, - build-release-notes, + build-release-notes ? __forDefaults.build-release-notes, boost, brotli, bzip2, @@ -78,6 +78,7 @@ }; lix-doc = pkgs.callPackage ./lix-doc/package.nix { }; + build-release-notes = pkgs.callPackage ./maintainers/build-release-notes { }; # FIXME remove when we have libsecomp 2.5.5 (currently in staging-23.11) libseccomp-nix = libseccomp.overrideAttrs (_: rec { From a17acaae148f057f672b99bfa86b81a9609c459d Mon Sep 17 00:00:00 2001 From: Qyriad Date: Tue, 7 May 2024 15:25:08 -0600 Subject: [PATCH 5/5] flake: refactor devShell creation Now instead of a derivation overridden from Lix, we use a mkShell derivation parameterized on an already called package.nix. This also lets callPackage take care of the buildPackages distinction for the devShell. Change-Id: I5ddfec40d83fa6136032da7606fe6d3d5014ef42 --- flake.nix | 65 ++--------------------------------------------------- package.nix | 55 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 66 deletions(-) diff --git a/flake.nix b/flake.nix index c03ec35ce..747723ff2 100644 --- a/flake.nix +++ b/flake.nix @@ -365,72 +365,11 @@ nix = pkgs.callPackage ./package.nix { inherit stdenv versionSuffix; busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox; - forDevShell = true; + internalApiDocs = true; }; pre-commit = self.hydraJobs.pre-commit.${pkgs.system} or { }; in - (nix.override { - buildUnreleasedNotes = true; - officialRelease = false; - }).overrideAttrs - ( - prev: - { - # Required for clang-tidy checks - buildInputs = - prev.buildInputs - ++ [ - pkgs.just - pkgs.nixfmt - ] - ++ lib.optional (pre-commit ? enabledPackages) pre-commit.enabledPackages - ++ lib.optionals (stdenv.cc.isClang) [ - pkgs.llvmPackages.llvm - pkgs.llvmPackages.clang-unwrapped.dev - ]; - nativeBuildInputs = - prev.nativeBuildInputs - ++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear - # Required for clang-tidy checks - ++ lib.optionals (stdenv.cc.isClang) [ - pkgs.buildPackages.cmake - pkgs.buildPackages.ninja - pkgs.buildPackages.llvmPackages.llvm.dev - ] - ++ - lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) - # for some reason that seems accidental and was changed in - # NixOS 24.05-pre, clang-tools is pinned to LLVM 14 when - # default LLVM is newer. - (pkgs.buildPackages.clang-tools.override { inherit (pkgs.buildPackages) llvmPackages; }) - ++ - lib.optionals (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.buildPackages.clangbuildanalyzer) - [ pkgs.buildPackages.clangbuildanalyzer ]; - - src = null; - - strictDeps = false; - - shellHook = '' - PATH=$prefix/bin:$PATH - unset PYTHONPATH - export MANPATH=$out/share/man:$MANPATH - - # Make bash completion work. - XDG_DATA_DIRS+=:$out/share - - ${lib.optionalString (pre-commit ? shellHook) pre-commit.shellHook} - # Allow `touch .nocontribmsg` to turn this notice off. - if ! [[ -f .nocontribmsg ]]; then - cat ${contribNotice} - fi - ''; - } - // lib.optionalAttrs (stdenv.buildPlatform.isLinux && pkgs.glibcLocales != null) { - # Required to make non-NixOS Linux not complain about missing locale files during configure in a dev shell - LOCALE_ARCHIVE = "${lib.getLib pkgs.glibcLocales}/lib/locale/locale-archive"; - } - ); + pkgs.callPackage nix.mkDevShell { pre-commit-checks = pre-commit; }; in forAllSystems ( system: diff --git a/package.nix b/package.nix index 6f9fe81b4..cfb538f1d 100644 --- a/package.nix +++ b/package.nix @@ -57,8 +57,6 @@ # Set to true to build the release notes for the next release. buildUnreleasedNotes ? false, internalApiDocs ? false, - # Avoid setting things that would interfere with a functioning devShell - forDevShell ? false, # Not a real argument, just the only way to approximate let-binding some # stuff for argument defaults. @@ -241,7 +239,7 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal ++ lib.optional (!officialRelease && buildUnreleasedNotes) build-release-notes - ++ lib.optional (internalApiDocs || forDevShell) doxygen; + ++ lib.optional internalApiDocs doxygen; buildInputs = [ @@ -379,5 +377,56 @@ stdenv.mkDerivation (finalAttrs: { # flake.nix exports that into its overlay. passthru = { inherit (__forDefaults) boehmgc-nix libseccomp-nix; + + # The collection of dependency logic for this derivation is complicated enough that + # it's easier to parameterize the devShell off an already called package.nix. + mkDevShell = + { + mkShell, + just, + nixfmt, + glibcLocales, + bear, + pre-commit-checks, + clang-tools, + llvmPackages, + clangbuildanalyzer, + }: + let + glibcFix = lib.optionalAttrs (stdenv.buildPlatform.isLinux && glibcLocales != null) { + # Required to make non-NixOS Linux not complain about missing locale files during configure in a dev shell + LOCALE_ARCHIVE = "${lib.getLib pkgs.glibcLocales}/lib/locale/locale-archive"; + }; + # for some reason that seems accidental and was changed in + # NixOS 24.05-pre, clang-tools is pinned to LLVM 14 when + # default LLVM is newer. + clang-tools_llvm = clang-tools.override { inherit llvmPackages; }; + in + mkShell ( + glibcFix + // { + + inputsFrom = [ finalAttrs ]; + + # For Meson to find Boost. + env = finalAttrs.env; + + packages = + [ + just + nixfmt + ] + ++ lib.optionals stdenv.cc.isClang [ + # Required for clang-tidy checks. + llvmPackages.llvm + llvmPackages.clang-unwrapped.dev + ] + ++ lib.optional (pre-commit-checks ? enabledPackages) pre-commit-checks.enabledPackages + ++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) bear + ++ lib.optional (stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform) clang-tools_llvm + ++ lib.optional (lib.meta.availableOn stdenv.buildPlatform clangbuildanalyzer) clangbuildanalyzer + ++ finalAttrs.checkInputs; + } + ); }; })