feat(3p/nix): added meson support

(cherry picked from commit 086a81b7a5bbe1fc022efb5935ff68f6ad71ddaf)
This commit is contained in:
p01arst0rm 2019-10-21 17:57:38 +01:00 committed by Vincent Ambo
parent c455f7a987
commit 055139ac6a
27 changed files with 2045 additions and 4 deletions

View file

@ -9,6 +9,7 @@ perl/Makefile.config
/nix.spec /nix.spec
/stamp-h1 /stamp-h1
/svn-revision /svn-revision
/build-gcc
/libtool /libtool
/corepkgs/config.nix /corepkgs/config.nix

4
third_party/nix/bootstrap-ac.sh vendored Executable file
View file

@ -0,0 +1,4 @@
#! /bin/sh -e
rm -f aclocal.m4
mkdir -p config
exec autoreconf -vfi

8
third_party/nix/bootstrap-meson.sh vendored Executable file
View file

@ -0,0 +1,8 @@
#! /usr/bin/env bash
rm -rf build*
meson build-gcc
cd build-gcc
ninja -j2

58
third_party/nix/corepkgs/meson.build vendored Normal file
View file

@ -0,0 +1,58 @@
# Nix corepkgs build file
#============================================================================
# src files
#============================================================================
corepkgs_data = files(
join_paths(meson.source_root(), 'corepkgs/buildenv.nix'),
join_paths(meson.source_root(), 'corepkgs/derivation.nix'),
join_paths(meson.source_root(), 'corepkgs/fetchurl.nix'),
join_paths(meson.source_root(), 'corepkgs/imported-drv-to-derivation.nix'),
join_paths(meson.source_root(), 'corepkgs/unpack-channel.nix'))
# targets
#============================================================================
config_nix = configuration_data()
config_nix.set('bash', bash.path())
config_nix.set('coreutils', coreutils)
config_nix.set('bzip2', bzip2.path())
config_nix.set('gzip', gzip.path())
config_nix.set('xz', xz.path())
config_nix.set('tar', tar.path())
config_nix.set('tarFlags', '')
config_nix.set('tr', tr.path())
config_nix.set('bindir', bindir)
config_nix.set('prefix', prefix)
config_nix.set('libexecdir', libexecdir)
config_nix.set('localstatedir', localstatedir)
config_nix.set('sysconfdir', sysconfdir)
config_nix.set('storedir', nixstoredir)
# build
#============================================================================
corepkgs_data += configure_file(
input : 'config.nix.in',
output : 'config.nix',
configuration : config_nix)
install_data(
corepkgs_data,
install_mode : 'rwxr-xr-x',
install_dir : join_paths(datadir, 'nix/corepkgs'))

View file

@ -0,0 +1,5 @@
# nix manual build file
#============================================================================
# TODO: generate the manual

13
third_party/nix/doc/meson.build vendored Normal file
View file

@ -0,0 +1,13 @@
# nix doc build file
#============================================================================
doc_dirs = [
'manual'
]
if (not get_option('disable_doc_gen'))
xsltproc = find_program('xsltproc', required : true)
foreach dir : doc_dirs
subdir(dir)
endforeach
endif

302
third_party/nix/m4/ax_boost_base.m4 vendored Normal file
View file

@ -0,0 +1,302 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_boost_base.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
# Test for the Boost C++ libraries of a particular version (or newer)
#
# If no path to the installed boost library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $BOOST_ROOT environment variable. Further documentation is available at
# <http://randspringer.de/boost/index.html>.
#
# This macro calls:
#
# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
#
# And sets:
#
# HAVE_BOOST
#
# LICENSE
#
# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
# Copyright (c) 2009 Peter Adolphs
#
# 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 47
# example boost program (need to pass version)
m4_define([_AX_BOOST_BASE_PROGRAM],
[AC_LANG_PROGRAM([[
#include <boost/version.hpp>
]],[[
(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))]));
]])])
AC_DEFUN([AX_BOOST_BASE],
[
AC_ARG_WITH([boost],
[AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
[use Boost library from a standard location (ARG=yes),
from the specified location (ARG=<path>),
or disable it (ARG=no)
@<:@ARG=yes@:>@ ])],
[
AS_CASE([$withval],
[no],[want_boost="no";_AX_BOOST_BASE_boost_path=""],
[yes],[want_boost="yes";_AX_BOOST_BASE_boost_path=""],
[want_boost="yes";_AX_BOOST_BASE_boost_path="$withval"])
],
[want_boost="yes"])
AC_ARG_WITH([boost-libdir],
[AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
[Force given directory for boost libraries.
Note that this will override library path detection,
so use this parameter only if default library detection fails
and you know exactly where your boost libraries are located.])],
[
AS_IF([test -d "$withval"],
[_AX_BOOST_BASE_boost_lib_path="$withval"],
[AC_MSG_ERROR([--with-boost-libdir expected directory name])])
],
[_AX_BOOST_BASE_boost_lib_path=""])
BOOST_LDFLAGS=""
BOOST_CPPFLAGS=""
AS_IF([test "x$want_boost" = "xyes"],
[_AX_BOOST_BASE_RUNDETECT([$1],[$2],[$3])])
AC_SUBST(BOOST_CPPFLAGS)
AC_SUBST(BOOST_LDFLAGS)
])
# convert a version string in $2 to numeric and affect to polymorphic var $1
AC_DEFUN([_AX_BOOST_BASE_TONUMERICVERSION],[
AS_IF([test "x$2" = "x"],[_AX_BOOST_BASE_TONUMERICVERSION_req="1.20.0"],[_AX_BOOST_BASE_TONUMERICVERSION_req="$2"])
_AX_BOOST_BASE_TONUMERICVERSION_req_shorten=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\.[[0-9]]*\)'`
_AX_BOOST_BASE_TONUMERICVERSION_req_major=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\)'`
AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_major" = "x"],
[AC_MSG_ERROR([You should at least specify libboost major version])])
_AX_BOOST_BASE_TONUMERICVERSION_req_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.\([[0-9]]*\)'`
AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_minor" = "x"],
[_AX_BOOST_BASE_TONUMERICVERSION_req_minor="0"])
_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
AS_IF([test "X$_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor" = "X"],
[_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor="0"])
_AX_BOOST_BASE_TONUMERICVERSION_RET=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req_major \* 100000 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_minor \* 100 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor`
AS_VAR_SET($1,$_AX_BOOST_BASE_TONUMERICVERSION_RET)
])
dnl Run the detection of boost should be run only if $want_boost
AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
_AX_BOOST_BASE_TONUMERICVERSION(WANT_BOOST_VERSION,[$1])
succeeded=no
AC_REQUIRE([AC_CANONICAL_HOST])
dnl On 64-bit systems check for system libraries in both lib64 and lib.
dnl The former is specified by FHS, but e.g. Debian does not adhere to
dnl this (as it rises problems for generic multi-arch support).
dnl The last entry in the list is chosen by default when no libraries
dnl are found, e.g. when only header-only libraries are installed!
AS_CASE([${host_cpu}],
[x86_64],[libsubdirs="lib64 libx32 lib lib64"],
[mips*64*],[libsubdirs="lib64 lib32 lib lib64"],
[ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"],
[libsubdirs="lib"]
)
dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
dnl them priority over the other paths since, if libs are found there, they
dnl are almost assuredly the ones desired.
AS_CASE([${host_cpu}],
[i?86],[multiarch_libsubdir="lib/i386-${host_os}"],
[multiarch_libsubdir="lib/${host_cpu}-${host_os}"]
)
dnl first we check the system location for boost libraries
dnl this location ist chosen if boost libraries are installed with the --layout=system option
dnl or if you install boost with RPM
AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"])
AS_IF([test -d "$_AX_BOOST_BASE_boost_path/include" && test -r "$_AX_BOOST_BASE_boost_path/include"],[
AC_MSG_RESULT([yes])
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include"
for _AX_BOOST_BASE_boost_path_tmp in $multiarch_libsubdir $libsubdirs; do
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) lib path in "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"])
AS_IF([test -d "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" && test -r "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" ],[
AC_MSG_RESULT([yes])
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp";
break;
],
[AC_MSG_RESULT([no])])
done],[
AC_MSG_RESULT([no])])
],[
if test X"$cross_compiling" = Xyes; then
search_libsubdirs=$multiarch_libsubdir
else
search_libsubdirs="$multiarch_libsubdir $libsubdirs"
fi
for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then
for libsubdir in $search_libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path_tmp/$libsubdir"
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path_tmp/include"
break;
fi
done
])
dnl overwrite ld flags if we have required special directory with
dnl --with-boost-libdir parameter
AS_IF([test "x$_AX_BOOST_BASE_boost_lib_path" != "x"],
[BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_lib_path"])
AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION)])
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_REQUIRE([AC_PROG_CXX])
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
dnl if we found no boost with system layout we search for boost libraries
dnl built and installed without the --layout=system option or for a staged(not installed) version
if test "x$succeeded" != "xyes" ; then
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
BOOST_CPPFLAGS=
if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
BOOST_LDFLAGS=
fi
_version=0
if test -n "$_AX_BOOST_BASE_boost_path" ; then
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path"; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "x$V_CHECK" = "x1" ; then
_version=$_version_tmp
fi
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include/boost-$VERSION_UNDERSCORE"
done
dnl if nothing found search for layout used in Windows distributions
if test -z "$BOOST_CPPFLAGS"; then
if test -d "$_AX_BOOST_BASE_boost_path/boost" && test -r "$_AX_BOOST_BASE_boost_path/boost"; then
BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path"
fi
fi
dnl if we found something and BOOST_LDFLAGS was unset before
dnl (because "$_AX_BOOST_BASE_boost_lib_path" = ""), set it here.
if test -n "$BOOST_CPPFLAGS" && test -z "$BOOST_LDFLAGS"; then
for libsubdir in $libsubdirs ; do
if ls "$_AX_BOOST_BASE_boost_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$libsubdir"
fi
fi
else
if test "x$cross_compiling" != "xyes" ; then
for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do
if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then
for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do
_version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
V_CHECK=`expr $_version_tmp \> $_version`
if test "x$V_CHECK" = "x1" ; then
_version=$_version_tmp
best_path=$_AX_BOOST_BASE_boost_path
fi
done
fi
done
VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
for libsubdir in $libsubdirs ; do
if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
BOOST_LDFLAGS="-L$best_path/$libsubdir"
fi
fi
if test -n "$BOOST_ROOT" ; then
for libsubdir in $libsubdirs ; do
if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
done
if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
V_CHECK=`expr $stage_version_shorten \>\= $_version`
if test "x$V_CHECK" = "x1" && test -z "$_AX_BOOST_BASE_boost_lib_path" ; then
AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
BOOST_CPPFLAGS="-I$BOOST_ROOT"
BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
fi
fi
fi
fi
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
export LDFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
fi
if test "x$succeeded" != "xyes" ; then
if test "x$_version" = "x0" ; then
AC_MSG_NOTICE([[We could not detect the boost libraries (version $1 or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
else
AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
fi
# execute ACTION-IF-NOT-FOUND (if present):
ifelse([$3], , :, [$3])
else
AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
# execute ACTION-IF-FOUND (if present):
ifelse([$2], , :, [$2])
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
])

541
third_party/nix/meson.build vendored Normal file
View file

@ -0,0 +1,541 @@
# Nix project build file
#============================================================================
# init
#============================================================================
# init project
#-------------------------------------------------
project(
'nix',
'cpp',
default_options : [
'cpp_std=c++17',
'warning_level=3'
],
version : run_command('cat', './.version').stdout().strip(),
license : 'MIT'
)
# init compiler
#-------------------------------------------------
cpp = meson.get_compiler('cpp')
add_project_arguments('-g', '-Wdeprecated', '-Wno-non-virtual-dtor', '-include', 'config.h', language : 'cpp')
add_project_link_arguments(get_option('ldflags'), language: 'cpp')
cmake = import('cmake')
pkg = import('pkgconfig')
# init configuration
#-------------------------------------------------
config_h = configuration_data()
config_h.set(
'HAVE_CXX17', 1,
description : 'define if the compiler supports basic C++17 syntax')
package_name = meson.project_name()
config_h.set_quoted(
'PACKAGE_NAME', package_name,
description : 'Define to the full name of this package.'
)
package_tarname = meson.project_name()
config_h.set_quoted(
'PACKAGE_TARNAME', package_tarname,
description : 'Define to the one symbol short name of this package.')
package_version = meson.project_version()
config_h.set_quoted(
'PACKAGE_VERSION', package_version,
description : 'Define to the version of this package.')
package_string = '@0@ @1@'.format(package_name, package_version)
config_h.set_quoted(
'PACKAGE_STRING', package_string,
description : 'Define to the full name and version of this package.')
package_url = 'https://nixos.org/nix/'
config_h.set_quoted(
'PACKAGE_URL', package_url,
description : 'Define to the home page for this package.')
package_bug_url = 'https://github.com/nixos/nix/issues'
config_h.set_quoted(
'PACKAGE_BUGREPORT', package_bug_url,
description : 'Define to the address where bug reports for this package should be sent.')
# env
#============================================================================
# set install directories
#-------------------------------------------------
prefix = get_option('prefix')
libdir = join_paths(prefix, get_option('libdir'))
bindir = join_paths(prefix, get_option('bindir'))
datadir = join_paths(prefix, get_option('datadir'))
sysconfdir = join_paths(prefix, get_option('sysconfdir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
mandir = join_paths(prefix, get_option('mandir'))
includedir = join_paths(prefix, get_option('includedir'))
# set nix directories
#-------------------------------------------------
# State should be stored in /nix/var, unless the user overrides it explicitly.
if get_option('normal_var')
localstatedir = '/nix/var'
else
localstatedir = join_paths(prefix, get_option('localstatedir'))
endif
nixstoredir = get_option('nixstoredir')
profiledir = join_paths(sysconfdir, 'profile.d')
# Construct a Nix system name (like "i686-linux").
#-------------------------------------------------
machine_name = host_machine.cpu()
sys_name = host_machine.system().to_lower()
cpu_archs = ['x86_64', 'armv6', 'armv7', '']
foreach cpu : cpu_archs
if (host_machine.cpu().contains(cpu))
if cpu.contains('armv')
machine_name = cpu + '1'
else
machine_name = cpu
endif
break
endif
endforeach
system= '"' + machine_name + '-' + sys_name + '"'
message('system name: ' + system)
config_h.set(
'SYSTEM', system,
description : 'platform identifier (`cpu-os`)')
# Check whether the store optimiser can optimise symlinks.
#-------------------------------------------------
gen_header = '''
ln -s bla tmp_link
if ln tmp_link tmp_link2 2> /dev/null; then
echo 1
else
echo 0
fi
'''
run_command('sh', '-c', 'rm tmp_link*')
can_link_symlink = run_command('sh', '-c', gen_header).stdout().strip()
if can_link_symlink.to_int() == 1
run_command('sh', '-c', 'rm tmp_link*')
endif
config_h.set('CAN_LINK_SYMLINK', can_link_symlink,
description : 'Whether link() works on symlinks')
# checking headers
#============================================================================
if (cpp.has_header('sys/stat.h'))
config_h.set(
'HAVE_SYS_STAT_H', 1,
description : 'Define to 1 if you have the <sys/stat.h> header file.')
endif
if (cpp.has_header('sys/types.h'))
config_h.set(
'HAVE_SYS_TYPES_H', 1,
description : 'Define to 1 if you have the <sys/types.h> header file.')
endif
if (cpp.has_header('sys/dir.h'))
config_h.set(
'HAVE_DIR_H', 1,
description : 'Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR`')
endif
if (cpp.has_header('sys/ndir.h'))
config_h.set(
'HAVE_NDIR_H', 1,
description : 'Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR`')
endif
if (cpp.has_header('dirent.h'))
config_h.set(
'HAVE_DIRENT_H', 1,
description : 'Define to 1 if you have the <dirent.h> header file, and it defines `DIR`')
endif
if (cpp.has_header('locale.h'))
config_h.set(
'HAVE_LOCALE', 1,
description : 'Define to 1 if you have the <locale.h> header file.')
endif
if (cpp.has_header('unistd.h'))
config_h.set(
'HAVE_UNISTD_H', 1,
description: 'Define to 1 if you have the <unistd.h> header file.')
endif
if (cpp.has_header('stdint.h'))
config_h.set(
'HAVE_STDINT_H', 1,
description: 'Define to 1 if you have the <stdint.h> header file.')
endif
if (cpp.has_header('stdlib.h'))
config_h.set(
'HAVE_STDLIB_H', 1,
description: 'Define to 1 if you have the <stdlib.h> header file.')
endif
if (cpp.has_header('strings.h'))
config_h.set(
'HAVE_STRINGS_H', 1,
description: 'Define to 1 if you have the <strings.h> header file.')
endif
if (cpp.has_header('string.h'))
config_h.set(
'HAVE_STRING_H', 1,
description: 'Define to 1 if you have the <strings.h> header file.')
endif
if (cpp.has_header('bzlib.h'))
config_h.set(
'HAVE_BZLIB_H', 1,
description : 'Define to 1 if you have the <bzlib.h> header file.')
endif
if (cpp.has_header('inttypes.h'))
config_h.set(
'HAVE_INTTYPES_H', 1,
description : 'Define to 1 if you have the <inttypes.h> header file.')
endif
if (cpp.has_header('memory.h'))
config_h.set(
'HAVE_MEMORY_H', 1,
description : 'Define to 1 if you have the <memory.h> header file.')
endif
if (cpp.has_header('editline.h'))
config_h.set(
'HAVE_EDITLINE_H', 1,
description : 'Define to 1 if you have the <editline.h> header file.')
else
error('Nix requires editline.h; however the header was not found.')
endif
# checking functions
#============================================================================
if (cpp.has_function('lutimes'))
config_h.set(
'HAVE_LUTIMES', 1,
description : 'Define to 1 if you have the `lutimes` function.')
endif
if (cpp.has_function('lchown'))
config_h.set(
'HAVE_LCHOWN', 1,
description : 'Define to 1 if you have the `lchown` function.')
endif
if (cpp.has_function('pipe2'))
config_h.set(
'HAVE_PIPE2', 1,
description : 'Define to 1 if you have the `pipe2` function.')
endif
if (cpp.has_function('posix_fallocate'))
config_h.set(
'HAVE_POSIX_FALLOCATE', 1,
description : 'Define to 1 if you have the `posix_fallocate` function.')
endif
if (cpp.has_function('setresuid'))
config_h.set(
'HAVE_SETRESUID', 1,
description : 'Define to 1 if you have the `setresuid` function.')
endif
if (cpp.has_function('setreuid'))
config_h.set(
'HAVE_SETREUID', 1,
description : 'Define to 1 if you have the `setreuid` function.')
endif
if (cpp.has_function('statvfs'))
config_h.set(
'HAVE_STATVFS', 1,
description : 'Define to 1 if you have the `statvfs` function.')
endif
if (cpp.has_function('strsignal'))
config_h.set(
'HAVE_STRSIGNAL', 1,
description : 'Define to 1 if you have the `strsignal` function.')
endif
if (cpp.has_function('sysconf'))
config_h.set(
'HAVE_SYSCONF', 1,
description : 'Define to 1 if you have the `sysconf` function.')
endif
pubsetbuff_c = '''
#include <iostream>
using namespace std;
static char buf[1024];
void func() {
cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
}'''
if meson.get_compiler('cpp').compiles(
pubsetbuff_c,
name : 'pubsetbuf'
)
config_h.set(
'HAVE_PUBSETBUF', 1,
description : 'Define to 1 if you have the `pubsetbuf` function.')
endif
# required dependancies
#============================================================================
# look for required programs
#--------------------------------------------------
cat = find_program('cat', required : true)
bash = find_program('bash', required : true)
echo = find_program('echo', required : true)
patch = find_program('patch', required : true)
xmllint = find_program('xmllint', required : true)
flex = find_program('flex', required : true)
bison = find_program('bison', required : true)
sed = find_program('sed', required : true)
tar = find_program('tar', required : true)
bzip2 = find_program('bzip2', required : true)
gzip = find_program('gzip', required : true)
xz = find_program('xz', required : true)
dot = find_program('dot', required : true)
lsof = find_program('lsof', required : true)
tr = find_program('tr', required : true)
coreutils = run_command('dirname', cat.path()).stdout().strip()
# Look for boost, a required dependency.
#--------------------------------------------------
boost_dep = declare_dependency(
dependencies : [
cpp.find_library('libboost_system', dirs : libdir),
cpp.find_library('libboost_context', dirs : libdir),
cpp.find_library('libboost_thread', dirs : libdir)],
link_args : get_option('boost_link_args'))
if (boost_dep.found())
config_h.set('HAVE_BOOST', 1, description : 'define if the Boost library is available.')
endif
# Look for liblzma, a required dependency.
#--------------------------------------------------
liblzma_dep = declare_dependency(
dependencies: dependency('liblzma'),
link_args : get_option('lzma_link_args'))
# Look for libbrotli{enc,dec}.
#--------------------------------------------------
libbrotli_dep = declare_dependency(
dependencies: [
dependency('libbrotlienc'),
dependency('libbrotlidec')],
link_args : get_option('brotli_link_args'))
# Look for OpenSSL, a required dependency.
#--------------------------------------------------
openssl_dep = declare_dependency(
dependencies: cpp.find_library('libssl', dirs : libdir),
link_args : get_option('openssl_link_args'))
# Look for SQLite, a required dependency.
#--------------------------------------------------
sqlite3_dep = declare_dependency(
dependencies : dependency('sqlite3', version : '>= 3.6.19'),
link_args : get_option('sqlite3_link_args'))
# Look for libcurl, a required dependency.
#--------------------------------------------------
libcurl_dep = declare_dependency(
dependencies : dependency('libcurl'),
link_args : get_option('curl_link_args'))
# Look for pthread, a required dependency.
#--------------------------------------------------
pthread_dep = declare_dependency(
dependencies : dependency('threads'),
link_args : get_option('pthread_link_args'))
# Look for libdl, a required dependency.
#--------------------------------------------------
libdl_dep = declare_dependency(
dependencies : cpp.find_library('dl', dirs : libdir),
link_args : get_option('dl_link_args'))
# Look for libbz2, a required dependency.
#--------------------------------------------------
libbz2_dep = declare_dependency(
dependencies : cpp.find_library('bz2', dirs : libdir),
link_args : get_option('bz2_link_args'))
# Look for editline, a required dependency.
#--------------------------------------------------
# NOTE: 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.
editline_dep = declare_dependency(
dependencies : cpp.find_library('libeditline'),
link_args : get_option('editline_link_args'))
if not (
cpp.has_function(
'read_history',
prefix : '#include <stdio.h>\n#include "editline.h"',
args : '-lreadline'))
warning('Nix requires libeditline; However, required functions do not work. Maybe ' +\
'it is too old? >= 1.14 is required.')
endif
# Optional dependancies
#============================================================================
# Look for libsodium, an optional dependency.
#--------------------------------------------------
if (get_option('with_libsodium'))
libsodium_dep = declare_dependency(
dependencies : cpp.find_library('libsodium', dirs : libdir),
link_args : get_option('sodium_link_args'))
config_h.set('HAVE_SODIUM', 1, description : 'Whether to use libsodium for cryptography.')
else
libsodium_dep = declare_dependency()
endif
# Look for Boehm garbage collector, an optional dependency.
#--------------------------------------------------
if (get_option('with_gc'))
gc_dep = declare_dependency(
dependencies : dependency('bdw-gc'),
link_args : get_option('sodium_link_args'))
config_h.set(
'HAVE_BOEHMGC', 1,
description : 'Whether to use the Boehm garbage collector.')
else
gc_dep = declare_dependency()
endif
# Look for aws-cpp-sdk-s3.
#--------------------------------------------------
if (get_option('with_s3'))
enable_s3 = meson.get_compiler('cpp').check_header('aws/s3/S3Client.h')
aws_version = meson.get_compiler('cpp').get_define(
'AWS_SDK_VERSION_STRING',
prefix : '#include <aws/core/VersionConfig.h>'
).strip('"').split('.')
conf_data.set('ENABLE_S3', 1, description : 'Whether to enable S3 support via aws-sdk-cpp.')
conf_data.set('AWS_VERSION_MAJOR', aws_version[0], description : 'Major version of aws-sdk-cpp.')
conf_data.set('AWS_VERSION_MINOR', aws_version[1], description : 'Minor version of aws-sdk-cpp.')
endif
# OS Specific checks
#============================================================================
# Look for libsecppomp, required for Linux sandboxing.
libseccomp_dep = ''
if sys_name.contains('linux')
libseccomp_dep = dependency('libseccomp', version : '>= 2.3.1', required: false)
if not (libseccomp_dep.found())
error('Nix requires libseccomp on a linux host system')
endif
config_h.set(
'HAVE_SECCOMP', 1,
description : 'Whether seccomp is available and should be used for sandboxing.')
endif
if (sys_name.contains('freebsd'))
add_project_arguments('-D_GNU_SOURCE', language : 'cpp')
config_h.set('_GNU_SOURCE', 1)
endif
if (sys_name.contains('sunos'))
# Solaris requires -lsocket -lnsl for network functions
endif
# build
#============================================================================
conf = configure_file(
output : 'config.h',
configuration : config_h)
install_headers(
conf,
install_dir : join_paths(includedir, 'nix'))
src_inc = [include_directories('.', 'src')]
subdir('src')
subdir('scripts')
subdir('corepkgs')
subdir('misc')
subdir('doc')
subdir('tests')

192
third_party/nix/meson_options.txt vendored Normal file
View file

@ -0,0 +1,192 @@
# Nix project build options
#============================================================================
# dirs
#============================================================================
option(
'nixstoredir',
type : 'string',
value : '/nix/store',
description : 'path of the Nix store (defaults to /nix/store)')
# compiler args
#============================================================================
option(
'ldflags',
type : 'array',
value : [
'-L/usr/local/lib',
'-L/usr/lib',
'-L/lib'],
description : 'Link flags')
option(
'cflags',
type : 'array',
value : [
'-O3'],
description : 'C build flags')
option(
'cxxflags',
type : 'array',
value : [
'-O3'],
description : 'CXX build flags')
# link args
#============================================================================
option(
'boost_link_args',
type : 'array',
value : [
'-L/usr/lib64',
'-lboost_system',
'-lboost_context',
'-lboost_thread'],
description : 'link args for boost')
option(
'brotli_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lbrotlienc',
'-lbrotlidec'],
description : 'link args for libbrotli')
option(
'bz2_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lbz2'],
description : 'link args for libbz2')
option(
'curl_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lcurl'],
description : 'link args for libcurl')
option(
'dl_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-ldl'],
description : 'link args for libdl')
option(
'editline_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-leditline'],
description : 'link args for editline_link_args')
option(
'lzma_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-llzma'],
description : 'link args for liblzma')
option(
'openssl_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lcrypto'],
description : 'link args for openssl')
option(
'pthread_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-pthread'],
description : 'link args for pthread')
option(
'sodium_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lsodium'],
description : 'link args for libsodium')
option(
'sqlite3_link_args',
type : 'array',
value : [
'-L/usr/local/lib',
'-lsqlite3'],
description : 'link args for sqlite3')
# optional dependancies
#============================================================================
option(
'with_gc',
type : 'boolean',
value : 'false',
description : 'build nix with Boehm garbage collector')
option(
'with_libsodium',
type : 'boolean',
value : 'true',
description : 'build nix with shared libs')
option(
'with_s3',
type : 'boolean',
value : 'false',
description : 'build nix with s3')
option(
'with_coreutils_bin',
type : 'string',
description : 'path of cat, mkdir, etc.')
# misc
#============================================================================
option(
'disable_doc_gen',
type : 'boolean',
value : 'false',
description : 'disable documentation generation')
option(
'build_shared_libs',
type : 'boolean',
value : 'false',
description : 'build nix with shared libs')
option(
'sandbox_shell',
type : 'string',
value : '/usr/bin/busybox',
description : 'path of a statically-linked shell to use as /bin/sh in sandboxes')
option(
'normal_var',
type : 'boolean',
value : 'true',
description : 'Whether to use `/nix/var` or the user-overridable `localstatedir`.')

View file

@ -0,0 +1,19 @@
# nix launchd build file
#============================================================================
if (sys_name.contains('darwin'))
launchd_data = []
org_nixos_nix_dameon_plist = configuration_data()
org_nixos_nix_dameon_plist.set('bindir', bindir)
launchd_data += configure_file(
input : 'org.nixos.nix-daemon.plist.in',
output : 'org.nixos.nix-daemon.plist',
configuration : org_nixos_nix_dameon_plist)
install_data(
corepkgs_data,
install_dir : join_paths(prefix, 'Library/LaunchDaemons'))
endif

13
third_party/nix/misc/meson.build vendored Normal file
View file

@ -0,0 +1,13 @@
# nix src build file
#============================================================================
misc_dirs = [
'launchd',
'systemd',
'systemv',
'upstart'
]
foreach dir : misc_dirs
subdir(dir)
endforeach

View file

@ -0,0 +1,26 @@
# nix systemd build file
#============================================================================
if (sys_name.contains('linux'))
systemd_data = []
systemd_nix_daemon = configuration_data()
systemd_nix_daemon.set('bindir', bindir)
systemd_nix_daemon.set('storedir', nixstoredir)
systemd_nix_daemon.set('localstatedir', localstatedir)
systemd_data += configure_file(
input : 'nix-daemon.socket.in',
output : 'nix-daemon.socket',
configuration : systemd_nix_daemon)
systemd_data += configure_file(
input : 'nix-daemon.service.in',
output : 'nix-daemon.service',
configuration : systemd_nix_daemon)
install_data(
systemd_data,
install_dir : join_paths(prefix, 'lib/systemd/system'))
endif

View file

@ -0,0 +1,8 @@
# nix systemd build file
#============================================================================
systemv_data = []
# install_data(
# systemv_data,
# install_dir : join_paths(prefix, 'lib/systemd/system'))

View file

@ -0,0 +1,26 @@
# ifeq ($(OS), Linux)
# $(foreach n, nix-daemon.conf, $(eval $(call install-file-in, $(d)/$(n), $(sysconfdir)/init, 0644)))
# endif
# nix systemd build file
#============================================================================
if (sys_name.contains('linux'))
upstart_data = []
upstart_nix_daemon = configuration_data()
upstart_nix_daemon.set('bindir', bindir)
upstart_data += configure_file(
input : 'nix-daemon.conf.in',
output : 'nix-daemon.conf',
configuration : upstart_nix_daemon)
install_data(
upstart_data,
install_dir : join_paths(sysconfdir, 'init'))
endif

74
third_party/nix/scripts/meson.build vendored Normal file
View file

@ -0,0 +1,74 @@
# Nix corepkgs build file
#============================================================================
# src files
#============================================================================
scripts_data = files(
join_paths(meson.source_root(), 'scripts/install-darwin-multi-user.sh'),
join_paths(meson.source_root(), 'scripts/install-multi-user.sh'))
# targets
#============================================================================
nix_profile_sh = configuration_data()
nix_profile_sh.set('localstatedir', localstatedir)
nix_profile_sh.set('coreutils', coreutils)
nix_http_export_cgi = configuration_data()
nix_http_export_cgi.set('bindir', bindir)
nix_http_export_cgi.set('localstatedir', localstatedir)
nix_http_export_cgi.set('coreutils', coreutils)
nix_http_export_cgi.set('gzip', gzip.path())
nix_reduce_build = configuration_data()
nix_reduce_build.set('bash', bash.path())
nix_reduce_build.set('bindir', bindir)
nix_reduce_build.set('localstatedir', localstatedir)
# TODO: make these work
nix_install = configuration_data()
nix_install.set('nixVersion', package_version)
nix_install.set('binaryTarball_x86_64-linux', '')
nix_install.set('binaryTarball_i686-linux', '')
nix_install.set('binaryTarball_aarch64-linux', '')
nix_install.set('binaryTarball_x86_64-darwin', '')
# build
#============================================================================
scripts_data += configure_file(
input : 'nix-profile.sh.in',
output : 'nix.sh',
configuration : nix_profile_sh)
scripts_data += configure_file(
input : 'nix-profile-daemon.sh.in',
output : 'nix-daemon.sh',
configuration : nix_profile_sh)
scripts_data += configure_file(
input : 'nix-http-export.cgi.in',
output : 'nix-http-export.cgi',
configuration : nix_http_export_cgi)
scripts_data += configure_file(
input : 'nix-reduce-build.in',
output : 'nix-reduce-build',
configuration : nix_reduce_build)
install_data(
scripts_data,
install_mode : 'rwxr-xr-x',
install_dir : profiledir)

130
third_party/nix/src/libexpr/meson.build vendored Normal file
View file

@ -0,0 +1,130 @@
# Nix lib expr build file
#============================================================================
# src files
#============================================================================
src_inc += include_directories('.', 'primops')
libexpr_src = files(
join_paths(meson.source_root(), 'src/libexpr/primops/context.cc'),
join_paths(meson.source_root(), 'src/libexpr/primops/fetchGit.cc'),
join_paths(meson.source_root(), 'src/libexpr/primops/fetchMercurial.cc'),
join_paths(meson.source_root(), 'src/libexpr/primops/fromTOML.cc'),
join_paths(meson.source_root(), 'src/libexpr/attr-path.cc'),
join_paths(meson.source_root(), 'src/libexpr/attr-set.cc'),
join_paths(meson.source_root(), 'src/libexpr/common-eval-args.cc'),
join_paths(meson.source_root(), 'src/libexpr/eval.cc'),
join_paths(meson.source_root(), 'src/libexpr/get-drvs.cc'),
join_paths(meson.source_root(), 'src/libexpr/json-to-value.cc'),
join_paths(meson.source_root(), 'src/libexpr/names.cc'),
join_paths(meson.source_root(), 'src/libexpr/nixexpr.cc'),
join_paths(meson.source_root(), 'src/libexpr/primops.cc'),
join_paths(meson.source_root(), 'src/libexpr/value-to-json.cc'),
join_paths(meson.source_root(), 'src/libexpr/value-to-xml.cc'))
libexpr_headers = files(
join_paths(meson.source_root(), 'src/libexpr/attr-path.hh'),
join_paths(meson.source_root(), 'src/libexpr/attr-set.hh'),
join_paths(meson.source_root(), 'src/libexpr/common-eval-args.hh'),
join_paths(meson.source_root(), 'src/libexpr/eval.hh'),
join_paths(meson.source_root(), 'src/libexpr/eval-inline.hh'),
join_paths(meson.source_root(), 'src/libexpr/function-trace.hh'),
join_paths(meson.source_root(), 'src/libexpr/get-drvs.hh'),
join_paths(meson.source_root(), 'src/libexpr/json-to-value.hh'),
join_paths(meson.source_root(), 'src/libexpr/names.hh'),
join_paths(meson.source_root(), 'src/libexpr/nixexpr.hh'),
join_paths(meson.source_root(), 'src/libexpr/primops.hh'),
join_paths(meson.source_root(), 'src/libexpr/symbol-table.hh'),
join_paths(meson.source_root(), 'src/libexpr/value.hh'),
join_paths(meson.source_root(), 'src/libexpr/value-to-json.hh'),
join_paths(meson.source_root(), 'src/libexpr/value-to-xml.hh'))
# dependancies
#============================================================================
libexpr_dep_list = [
libdl_dep,
libsodium_dep]
if sys_name == 'freebsd'
libexpr_dep_list += libdl_dep
endif
# Link args
#============================================================================
libexpr_link_list = [
libutil_lib,
libstore_lib,
libmain_lib]
libexpr_link_args = []
# compiler args
#============================================================================
libexpr_cxx_args = []
# targets
#============================================================================
libexpr_src += custom_target(
'parser_tab.[cchh]',
output : [
'parser-tab.cc',
'parser-tab.hh'],
input : 'parser.y',
command : [
bison,
'-v',
'--output=@OUTPUT0@',
'@INPUT@',
'-d'])
libexpr_src += custom_target(
'lexer_tab.[cchh]',
output : ['lexer-tab.cc', 'lexer-tab.hh'],
input : 'lexer.l',
command : [
flex,
'--outfile=@OUTPUT0@',
'--header-file=@OUTPUT1@',
'@INPUT@'])
# build
#============================================================================
libexpr_lib = library(
'nixexpr',
install : true,
install_mode : 'rwxr-xr-x',
install_dir : libdir,
include_directories : src_inc,
link_with : libexpr_link_list,
sources : libexpr_src,
link_args : libexpr_link_args,
dependencies : libexpr_dep_list)
install_headers(
libexpr_headers,
install_dir : join_paths(includedir, 'nix'))

79
third_party/nix/src/libmain/meson.build vendored Normal file
View file

@ -0,0 +1,79 @@
# Nix lib store build file
#============================================================================
# src files
#============================================================================
src_inc += include_directories('.')
libmain_src = files(
join_paths(meson.source_root(), 'src/libmain/common-args.cc'),
join_paths(meson.source_root(), 'src/libmain/shared.cc'),
join_paths(meson.source_root(), 'src/libmain/stack.cc'))
libmain_headers = files(
join_paths(meson.source_root(), 'src/libmain/common-args.hh'),
join_paths(meson.source_root(), 'src/libmain/shared.hh'))
# dependancies
#============================================================================
libmain_dep_list = [
pthread_dep,
openssl_dep,
libsodium_dep]
# Link args
#============================================================================
libmain_link_list = [
libutil_lib,
libstore_lib
]
libmain_link_args = []
# compiler args
#============================================================================
libstore_cxx_args = []
# targets
#============================================================================
# build
#============================================================================
libmain_lib = library(
'nixmain',
install : true,
install_mode : 'rwxr-xr-x',
install_dir : libdir,
include_directories : src_inc,
link_with : libmain_link_list,
sources : libmain_src,
link_args : libmain_link_args,
dependencies : libmain_dep_list)
install_headers(
libmain_headers,
install_dir : join_paths(includedir, 'nix'))

170
third_party/nix/src/libstore/meson.build vendored Normal file
View file

@ -0,0 +1,170 @@
# Nix lib store build file
#============================================================================
# src files
#============================================================================
src_inc += include_directories('.')
libstore_src = files(
join_paths(meson.source_root(), 'src/libstore/binary-cache-store.cc'),
join_paths(meson.source_root(), 'src/libstore/build.cc'),
join_paths(meson.source_root(), 'src/libstore/crypto.cc'),
join_paths(meson.source_root(), 'src/libstore/derivations.cc'),
join_paths(meson.source_root(), 'src/libstore/download.cc'),
join_paths(meson.source_root(), 'src/libstore/export-import.cc'),
join_paths(meson.source_root(), 'src/libstore/gc.cc'),
join_paths(meson.source_root(), 'src/libstore/globals.cc'),
join_paths(meson.source_root(), 'src/libstore/http-binary-cache-store.cc'),
join_paths(meson.source_root(), 'src/libstore/legacy-ssh-store.cc'),
join_paths(meson.source_root(), 'src/libstore/local-binary-cache-store.cc'),
join_paths(meson.source_root(), 'src/libstore/local-fs-store.cc'),
join_paths(meson.source_root(), 'src/libstore/local-store.cc'),
join_paths(meson.source_root(), 'src/libstore/machines.cc'),
join_paths(meson.source_root(), 'src/libstore/misc.cc'),
join_paths(meson.source_root(), 'src/libstore/nar-accessor.cc'),
join_paths(meson.source_root(), 'src/libstore/nar-info.cc'),
join_paths(meson.source_root(), 'src/libstore/nar-info-disk-cache.cc'),
join_paths(meson.source_root(), 'src/libstore/optimise-store.cc'),
join_paths(meson.source_root(), 'src/libstore/parsed-derivations.cc'),
join_paths(meson.source_root(), 'src/libstore/pathlocks.cc'),
join_paths(meson.source_root(), 'src/libstore/profiles.cc'),
join_paths(meson.source_root(), 'src/libstore/references.cc'),
join_paths(meson.source_root(), 'src/libstore/remote-fs-accessor.cc'),
join_paths(meson.source_root(), 'src/libstore/remote-store.cc'),
join_paths(meson.source_root(), 'src/libstore/s3-binary-cache-store.cc'),
join_paths(meson.source_root(), 'src/libstore/sqlite.cc'),
join_paths(meson.source_root(), 'src/libstore/ssh.cc'),
join_paths(meson.source_root(), 'src/libstore/ssh-store.cc'),
join_paths(meson.source_root(), 'src/libstore/store-api.cc'),
join_paths(meson.source_root(), 'src/libstore/builtins/buildenv.cc'),
join_paths(meson.source_root(), 'src/libstore/builtins/fetchurl.cc'))
libstore_headers = files(
join_paths(meson.source_root(), 'src/libstore/binary-cache-store.hh'),
join_paths(meson.source_root(), 'src/libstore/builtins.hh'),
join_paths(meson.source_root(), 'src/libstore/crypto.hh'),
join_paths(meson.source_root(), 'src/libstore/derivations.hh'),
join_paths(meson.source_root(), 'src/libstore/download.hh'),
join_paths(meson.source_root(), 'src/libstore/fs-accessor.hh'),
join_paths(meson.source_root(), 'src/libstore/globals.hh'),
join_paths(meson.source_root(), 'src/libstore/local-store.hh'),
join_paths(meson.source_root(), 'src/libstore/machines.hh'),
join_paths(meson.source_root(), 'src/libstore/nar-accessor.hh'),
join_paths(meson.source_root(), 'src/libstore/nar-info-disk-cache.hh'),
join_paths(meson.source_root(), 'src/libstore/nar-info.hh'),
join_paths(meson.source_root(), 'src/libstore/parsed-derivations.hh'),
join_paths(meson.source_root(), 'src/libstore/pathlocks.hh'),
join_paths(meson.source_root(), 'src/libstore/profiles.hh'),
join_paths(meson.source_root(), 'src/libstore/references.hh'),
join_paths(meson.source_root(), 'src/libstore/remote-fs-accessor.hh'),
join_paths(meson.source_root(), 'src/libstore/remote-store.hh'),
join_paths(meson.source_root(), 'src/libstore/s3-binary-cache-store.hh'),
join_paths(meson.source_root(), 'src/libstore/s3.hh'),
join_paths(meson.source_root(), 'src/libstore/serve-protocol.hh'),
join_paths(meson.source_root(), 'src/libstore/sqlite.hh'),
join_paths(meson.source_root(), 'src/libstore/ssh.hh'),
join_paths(meson.source_root(), 'src/libstore/store-api.hh'),
join_paths(meson.source_root(), 'src/libstore/worker-protocol.hh'))
libstore_data = files(
join_paths(meson.source_root(), 'src/libstore/sandbox-defaults.sb'),
join_paths(meson.source_root(), 'src/libstore/sandbox-minimal.sb'),
join_paths(meson.source_root(), 'src/libstore/sandbox-network.sb'))
# dependancies
#============================================================================
libstore_dep_list = [
libbz2_dep,
libcurl_dep,
libdl_dep,
pthread_dep,
sqlite3_dep,
libsodium_dep
]
if sys_name.contains('linux')
libstore_dep_list += libseccomp_dep
endif
if sys_name.contains('freebsd')
libstore_dep_list += libdl_dep
endif
# Link args
#============================================================================
libstore_link_list = [
libutil_lib]
libstore_link_args = []
# compiler args
#============================================================================
libstore_cxx_args = [
'-DNIX_PREFIX="@0@" '.format(prefix),
'-DNIX_STORE_DIR="@0@" '.format(nixstoredir),
'-DNIX_DATA_DIR="@0@" '.format(datadir),
'-DNIX_STATE_DIR="@0@" '.format(join_paths(localstatedir, 'nix')),
'-DNIX_LOG_DIR="@0@" '.format(join_paths(localstatedir, 'log/nix')),
'-DNIX_CONF_DIR="@0@" '.format(join_paths(sysconfdir, 'nix')),
'-DNIX_LIBEXEC_DIR="@0@" '.format(libexecdir),
'-DNIX_BIN_DIR="@0@" '.format(bindir),
'-DNIX_MAN_DIR="@0@" '.format(mandir),
'-DSANDBOX_SHELL="@0@" '.format(get_option('sandbox_shell')),
'-DLSOF="@0@" '.format(lsof)]
# targets
#============================================================================
gen_header = '''
echo 'R"foo(' >> "$1"
cat @INPUT@ >> "$1"
echo ')foo"' >> "$1"
'''
libstore_src += custom_target(
'schema.sql.gen.hh',
output : 'schema.sql.gen.hh',
input : 'schema.sql',
command : [bash, '-c', gen_header, 'sh', '@OUTPUT@'])
# build
#============================================================================
libstore_lib = library(
'nixstore',
install : true,
install_mode : 'rwxr-xr-x',
install_dir : libdir,
include_directories : src_inc,
link_with : libstore_link_list,
sources : libstore_src,
cpp_args : libstore_cxx_args,
link_args : libstore_link_args,
dependencies : libstore_dep_list)
install_headers(
libstore_headers,
install_dir : join_paths(includedir, 'nix'))
install_data(
libstore_data,
install_dir : join_paths(datadir, 'nix/sandbox'))

View file

@ -229,7 +229,7 @@ struct ConnectionHandle
~ConnectionHandle() ~ConnectionHandle()
{ {
if (!daemonException && std::uncaught_exception()) { if (!daemonException && std::uncaught_exceptions()) {
handle.markBad(); handle.markBad();
debug("closing daemon connection because of an exception"); debug("closing daemon connection because of an exception");
} }

106
third_party/nix/src/libutil/meson.build vendored Normal file
View file

@ -0,0 +1,106 @@
# Nix lib store build file
#============================================================================
# src files
#============================================================================
src_inc += include_directories('.')
libutil_src = files(
join_paths(meson.source_root(), 'src/libutil/affinity.cc'),
join_paths(meson.source_root(), 'src/libutil/archive.cc'),
join_paths(meson.source_root(), 'src/libutil/args.cc'),
join_paths(meson.source_root(), 'src/libutil/compression.cc'),
join_paths(meson.source_root(), 'src/libutil/config.cc'),
join_paths(meson.source_root(), 'src/libutil/hash.cc'),
join_paths(meson.source_root(), 'src/libutil/json.cc'),
join_paths(meson.source_root(), 'src/libutil/logging.cc'),
join_paths(meson.source_root(), 'src/libutil/serialise.cc'),
join_paths(meson.source_root(), 'src/libutil/thread-pool.cc'),
join_paths(meson.source_root(), 'src/libutil/util.cc'),
join_paths(meson.source_root(), 'src/libutil/xml-writer.cc'))
libutil_headers = files(
join_paths(meson.source_root(), 'src/libutil/affinity.hh'),
join_paths(meson.source_root(), 'src/libutil/archive.hh'),
join_paths(meson.source_root(), 'src/libutil/args.hh'),
join_paths(meson.source_root(), 'src/libutil/compression.hh'),
join_paths(meson.source_root(), 'src/libutil/config.hh'),
join_paths(meson.source_root(), 'src/libutil/finally.hh'),
join_paths(meson.source_root(), 'src/libutil/hash.hh'),
join_paths(meson.source_root(), 'src/libutil/istringstream_nocopy.hh'),
join_paths(meson.source_root(), 'src/libutil/json.hh'),
join_paths(meson.source_root(), 'src/libutil/lazy.hh'),
join_paths(meson.source_root(), 'src/libutil/logging.hh'),
join_paths(meson.source_root(), 'src/libutil/lru-cache.hh'),
join_paths(meson.source_root(), 'src/libutil/monitor-fd.hh'),
join_paths(meson.source_root(), 'src/libutil/pool.hh'),
join_paths(meson.source_root(), 'src/libutil/ref.hh'),
join_paths(meson.source_root(), 'src/libutil/serialise.hh'),
join_paths(meson.source_root(), 'src/libutil/sync.hh'),
join_paths(meson.source_root(), 'src/libutil/thread-pool.hh'),
join_paths(meson.source_root(), 'src/libutil/types.hh'),
join_paths(meson.source_root(), 'src/libutil/util.hh'),
join_paths(meson.source_root(), 'src/libutil/xml-writer.hh')
)
# dependancies
#============================================================================
libutil_dep_list = [
boost_dep,
libbz2_dep,
liblzma_dep,
libbrotli_dep,
openssl_dep,
pthread_dep,
libsodium_dep]
# Link args
#============================================================================
libutil_link_list = []
libutil_link_args = []
# compiler args
#============================================================================
libutil_cxx_args = []
# targets
#============================================================================
# build
#============================================================================
libutil_lib = library(
'nixutil',
install : true,
install_mode : 'rwxr-xr-x',
install_dir : libdir,
include_directories : src_inc,
sources : libutil_src,
link_args : libutil_link_args,
dependencies : libutil_dep_list)
install_headers(
libutil_headers,
install_dir : join_paths(includedir, 'nix'))

View file

@ -33,7 +33,7 @@
#endif #endif
extern char * * environ; extern char * * environ __attribute__((weak));
namespace nix { namespace nix {
@ -1179,7 +1179,7 @@ void _interrupted()
/* Block user interrupts while an exception is being handled. /* Block user interrupts while an exception is being handled.
Throwing an exception while another exception is being handled Throwing an exception while another exception is being handled
kills the program! */ kills the program! */
if (!interruptThrown && !std::uncaught_exception()) { if (!interruptThrown && !std::uncaught_exceptions()) {
interruptThrown = true; interruptThrown = true;
throw Interrupted("interrupted by the user"); throw Interrupted("interrupted by the user");
} }

48
third_party/nix/src/meson.build vendored Normal file
View file

@ -0,0 +1,48 @@
# nix src build file
#============================================================================
src_dirs = [
'libutil',
'libstore',
'libmain',
'libexpr',
'nix',
'resolve-system-dependencies'
]
foreach dir : src_dirs
subdir(dir)
endforeach
libstore_config = pkg.generate(
libstore_lib,
libraries : [
libutil_lib],
version : meson.project_version(),
name : 'Nix',
subdirs : ['nix/'],
filebase : 'nix-store',
extra_cflags : '-std=c++17',
description : 'Nix Package Manager.')
libmain_config = pkg.generate(
libmain_lib,
version : meson.project_version(),
name : 'Nix',
subdirs : ['nix/'],
filebase : 'nix-main',
extra_cflags : '-std=c++17',
description : 'Nix Package Manager.')
libexpr_config = pkg.generate(
libexpr_lib,
libraries : [
libstore_lib],
version : meson.project_version(),
name : 'Nix',
subdirs : ['nix/'],
filebase : 'nix-expr',
extra_cflags : '-std=c++17',
description : 'Nix Package Manager.')

View file

@ -21,7 +21,7 @@
using namespace nix; using namespace nix;
using namespace std::string_literals; using namespace std::string_literals;
extern char * * environ; extern char * * environ __attribute__((weak));
/* Recreate the effect of the perl shellwords function, breaking up a /* Recreate the effect of the perl shellwords function, breaking up a
* string into arguments like a shell word, including escapes * string into arguments like a shell word, including escapes

View file

@ -13,6 +13,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h>
#include <ifaddrs.h> #include <ifaddrs.h>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>

152
third_party/nix/src/nix/meson.build vendored Normal file
View file

@ -0,0 +1,152 @@
# Nix exec build file
#============================================================================
# src files
#============================================================================
src_inc += include_directories('.')
nix_src = files(
join_paths(meson.source_root(), 'src/nix/add-to-store.cc'),
join_paths(meson.source_root(), 'src/nix/build.cc'),
join_paths(meson.source_root(), 'src/nix/cat.cc'),
join_paths(meson.source_root(), 'src/nix/command.cc'),
join_paths(meson.source_root(), 'src/nix/copy.cc'),
join_paths(meson.source_root(), 'src/nix/doctor.cc'),
join_paths(meson.source_root(), 'src/nix/dump-path.cc'),
join_paths(meson.source_root(), 'src/nix/edit.cc'),
join_paths(meson.source_root(), 'src/nix/eval.cc'),
join_paths(meson.source_root(), 'src/nix/hash.cc'),
join_paths(meson.source_root(), 'src/nix/installables.cc'),
join_paths(meson.source_root(), 'src/nix/legacy.cc'),
join_paths(meson.source_root(), 'src/nix/log.cc'),
join_paths(meson.source_root(), 'src/nix/ls.cc'),
join_paths(meson.source_root(), 'src/nix/main.cc'),
join_paths(meson.source_root(), 'src/nix/optimise-store.cc'),
join_paths(meson.source_root(), 'src/nix/path-info.cc'),
join_paths(meson.source_root(), 'src/nix/ping-store.cc'),
join_paths(meson.source_root(), 'src/nix/progress-bar.cc'),
join_paths(meson.source_root(), 'src/nix/repl.cc'),
join_paths(meson.source_root(), 'src/nix/run.cc'),
join_paths(meson.source_root(), 'src/nix/search.cc'),
join_paths(meson.source_root(), 'src/nix/show-config.cc'),
join_paths(meson.source_root(), 'src/nix/show-derivation.cc'),
join_paths(meson.source_root(), 'src/nix/sigs.cc'),
join_paths(meson.source_root(), 'src/nix/upgrade-nix.cc'),
join_paths(meson.source_root(), 'src/nix/verify.cc'),
join_paths(meson.source_root(), 'src/nix/why-depends.cc'),
join_paths(meson.source_root(), 'src/build-remote/build-remote.cc'),
join_paths(meson.source_root(), 'src/nix-build/nix-build.cc'),
join_paths(meson.source_root(), 'src/nix-channel/nix-channel.cc'),
join_paths(meson.source_root(), 'src/nix-collect-garbage/nix-collect-garbage.cc'),
join_paths(meson.source_root(), 'src/nix-copy-closure/nix-copy-closure.cc'),
join_paths(meson.source_root(), 'src/nix-daemon/nix-daemon.cc'),
join_paths(meson.source_root(), 'src/nix-env/nix-env.cc'),
join_paths(meson.source_root(), 'src/nix-env/user-env.cc'),
join_paths(meson.source_root(), 'src/nix-instantiate/nix-instantiate.cc'),
join_paths(meson.source_root(), 'src/nix-prefetch-url/nix-prefetch-url.cc'),
join_paths(meson.source_root(), 'src/nix-store/dotgraph.cc'),
join_paths(meson.source_root(), 'src/nix-store/graphml.cc'),
join_paths(meson.source_root(), 'src/nix-store/nix-store.cc'))
nix_ln_src = [
[ bindir, 'nix-build' ],
[ bindir, 'nix-channel' ],
[ bindir, 'nix-collect-garbage' ],
[ bindir, 'nix-copy-closure' ],
[ bindir, 'nix-daemon' ],
[ bindir, 'nix-env' ],
[ bindir, 'nix-hash' ],
[ bindir, 'nix-instantiate' ],
[ bindir, 'nix-prefetch-url' ],
[ bindir, 'nix-shell' ],
[ bindir, 'nix-store' ],
[ join_paths(libexecdir, 'nix'), 'build-remote' ]]
nix_headers = files (
join_paths(meson.source_root(), 'src/nix/command.hh'),
join_paths(meson.source_root(), 'src/nix/legacy.hh'),
join_paths(meson.source_root(), 'src/nix/progress-bar.hh'),
join_paths(meson.source_root(), 'src/nix-env/user-env.hh'),
join_paths(meson.source_root(), 'src/nix-store/dotgraph.hh'),
join_paths(meson.source_root(), 'src/nix-store/graphml.hh'))
# dependancies
#============================================================================
nix_dep_list = [
pthread_dep,
libdl_dep,
boost_dep,
editline_dep,
libsodium_dep]
# Link args
#============================================================================
nix_link_list = [
libutil_lib,
libstore_lib,
libmain_lib,
libexpr_lib
]
nix_link_args = []
# compiler args
#============================================================================
nix_cxx_args = []
# targets
#============================================================================
# build
#============================================================================
nix_bin = executable(
'nix',
install : true,
install_mode : 'rwxr-xr-x',
install_dir : bindir,
include_directories : src_inc,
sources : nix_src,
link_with : nix_link_list,
dependencies : nix_dep_list)
# meson does not yet support installing symlink files.
# this is a simple workaround
foreach name : nix_ln_src
meson.add_install_script(
'ln',
'-sf',
join_paths(bindir, 'nix'),
name[1])
meson.add_install_script(
'cp',
'-r',
name[1],
join_paths(name[0], name[1]))
endforeach
install_headers(
nix_headers,
install_dir : join_paths(includedir, 'nix'))

View file

@ -0,0 +1,58 @@
# Nix exec build file
#============================================================================
# src files
#============================================================================
nix_src = files(
join_paths(meson.source_root(),
'src/resolve-system-dependencies/resolve-system-dependencies.cc'))
# dependancies
#============================================================================
sys_deps_dep_list = []
# Link args
#============================================================================
sys_deps_link_args = []
# compiler args
#============================================================================
sys_deps_cxx_args = []
# targets
#============================================================================
# build
#============================================================================
if sys_name == 'darwin'
sys_deps_bin = executable(
'resolve-system-dependencies',
install : true,
install_dir : bindir,
include_directories : src_inc,
sources : nix_src,
link_args : sys_deps_link_args,
dependencies : sys_deps_dep_list)
endif

5
third_party/nix/tests/meson.build vendored Normal file
View file

@ -0,0 +1,5 @@
# nix doc build file
#============================================================================
# TODO: all of this :|