diff --git a/meson.build b/meson.build index 991dce917..c3aa68549 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,46 @@ all_deps = { } deps = [ ] configdata = { } -aws_sdk = dependency('aws-cpp-sdk-core', required : false) +# +# Dependencies +# + +boehm = dependency('bdw-gc', required : get_option('gc')) +if boehm.found() + deps += boehm +endif +configdata += { + 'HAVE_BOEHMGC': boehm.found().to_int(), +} + +boost = dependency('boost', required : true, modules : ['context', 'coroutine', 'container']) +deps += boost + +cpuid = dependency('libcpuid', 'cpuid', required : get_option('cpuid')) +configdata += { + 'HAVE_LIBCPUID': cpuid.found().to_int(), + } +deps += cpuid + +seccomp = dependency('libseccomp', 'seccomp', required : get_option('seccomp-sandboxing')) +configdata += { + 'HAVE_SECCOMP': seccomp.found().to_int(), + } + +libarchive = dependency('libarchive', required : true) +deps += libarchive + +brotli = [ + dependency('libbrotlicommon', required : true), + dependency('libbrotlidec', required : true), + dependency('libbrotlienc', required : true), + ] +deps += brotli + +openssl = dependency('libcrypto', 'openssl', required : true) +deps += openssl + +aws_sdk = dependency('aws-cpp-sdk-core', required : true) if aws_sdk.found() # The AWS pkg-config adds -std=c++11. aws_sdk = aws_sdk.partial_dependency( @@ -35,8 +74,15 @@ if aws_sdk.found() 'AWS_VERSION_MINOR': s[1].to_int(), 'AWS_VERSION_PATCH': s[2].to_int(), } + aws_sdk_transfer = dependency('aws-cpp-sdk-transfer', required : true).partial_dependency( + compile_args : false, + includes : true, + link_args : true, + links : true, + sources : true, + ) endif -aws_s3 = dependency('aws-cpp-sdk-s3', required : false) +aws_s3 = dependency('aws-cpp-sdk-s3', required : true) if aws_s3.found() # The AWS pkg-config adds -std=c++11. aws_s3 = aws_s3.partial_dependency( @@ -48,10 +94,26 @@ if aws_s3.found() ) deps += aws_s3 endif -configdata += { - 'ENABLE_S3': aws_s3.found().to_int(), -} +sqlite = dependency('sqlite3', 'sqlite', version : '>=3.6.19', required : true) +deps += sqlite + +sodium = dependency('sodium', 'libsodium', required : true) +deps += sodium + +curl = dependency('libcurl', 'curl', required : true) +deps += curl + +# +# Build-time tools +# +lsof = find_program('lsof') + +# +# Configuration +# + +# FIXME(Qyriad): at least do this in the build directory run_command('ln', '-s', 'bla', 'tmp_link', check : true) can_link_symlink = run_command('ln', 'tmp_link', 'tmp_link2', check : false).returncode() == 0 run_command('rm', '-f', 'tmp_link', 'tmp_link2', check : true) @@ -100,41 +162,10 @@ configdata += { 'HAVE_PUBSETBUF': has_pubsetbuf.to_int(), } -boehm = dependency('bdw-gc', required : get_option('enable-gc')) -if boehm.found() - deps += boehm -endif configdata += { - 'HAVE_BOEHMGC': boehm.found().to_int(), + 'ENABLE_S3': aws_s3.found().to_int(), } -boost = dependency('boost', required : true, modules : ['context', 'coroutine', 'container']) -deps += boost - -cpuid = dependency('libcpuid', required : get_option('enable-cpuid')) -configdata += { - 'HAVE_LIBCPUID': cpuid.found().to_int(), -} -deps += cpuid - -seccomp = dependency('libseccomp', required : get_option('enable-seccomp-sandboxing')) -configdata += { - 'HAVE_SECCOMP': seccomp.found().to_int(), -} - -libarchive = dependency('libarchive', required : true) -deps += libarchive - -brotli = [ - dependency('libbrotlicommon', required : true), - dependency('libbrotlidec', required : true), - dependency('libbrotlienc', required : true), -] -deps += brotli - -openssl = dependency('libcrypto', required : true) -deps += openssl - configure_file( configuration : { 'PACKAGE_NAME': '"' + meson.project_name() + '"', @@ -160,3 +191,5 @@ add_project_arguments( ) subdir('src/libutil') +# Load-bearing order. libstore depends on libutil (includes). +subdir('src/libstore') diff --git a/meson.options b/meson.options index e14344bdd..393e59733 100644 --- a/meson.options +++ b/meson.options @@ -1,16 +1,24 @@ # vim: filetype=meson -option('enable-gc', type : 'feature', +option('gc', type : 'feature', description : 'enable garbage collection in the Nix expression evaluator (requires Boehm GC)', ) # TODO(Qyriad): is this feature maintained? -option('enable-embedded-sandbox-shell', type : 'feature', +option('embedded-sandbox-shell', type : 'feature', description : 'include the sandbox shell in the Nix bindary', ) -option('enable-cpuid', type : 'feature', +option('cpuid', type : 'feature', description : 'determine microarchitecture levels with libcpuid (only relevant on x86_64)', ) -option('enable-seccomp-sandboxing', type : 'feature', +option('seccomp-sandboxing', type : 'feature', description : 'build support for seccomp sandboxing (recommended unless your arch doesn\'t support libseccomp, only relevant on Linux)', ) + +option('store-dir', type : 'string', value : '/nix/store', + description : 'path of the Nix store', +) + +option('sandbox-shell', type : 'string', + description : 'path to a statically-linked shell to use as /bin/sh in sandboxes (usually busybox)', +) diff --git a/src/libstore/meson.build b/src/libstore/meson.build new file mode 100644 index 000000000..4c2593904 --- /dev/null +++ b/src/libstore/meson.build @@ -0,0 +1,125 @@ +find_program('lsof') + +# Yes this is really what it does. +# FIXME: do we. really need to rely on the shell for this? +gen_script = ''' + echo 'R"foo(' >> @OUTPUT@.tmp && + cat < @INPUT@ >> @OUTPUT@.tmp && + echo ')foo"' >> @OUTPUT@.tmp && + mv @OUTPUT@.tmp @OUTPUT +'''.replace('\n', ' ') + +schema_sql_gen = custom_target( + input : 'schema.sql', + output : 'schema.sql.gen.hh', + command : [ + 'bash', '-c', + gen_script, + ], +) + +libstore_sources = files( + 'binary-cache-store.cc', + 'build-result.cc', + 'common-protocol.cc', + 'content-address.cc', + 'crypto.cc', + 'daemon.cc', + 'derivations.cc', + 'derived-path-map.cc', + 'derived-path.cc', + 'downstream-placeholder.cc', + 'dummy-store.cc', + 'export-import.cc', + 'filetransfer.cc', + 'gc.cc', + 'globals.cc', + 'http-binary-cache-store.cc', + 'legacy-ssh-store.cc', + 'local-binary-cache-store.cc', + 'local-fs-store.cc', + 'local-store.cc', + 'lock.cc', + 'log-store.cc', + 'machines.cc', + 'make-content-addressed.cc', + 'misc.cc', + 'names.cc', + 'nar-accessor.cc', + 'nar-info-disk-cache.cc', + 'nar-info.cc', + 'optimise-store.cc', + 'outputs-spec.cc', + 'parsed-derivations.cc', + 'path-info.cc', + 'path-references.cc', + 'path-with-outputs.cc', + 'path.cc', + 'pathlocks.cc', + 'profiles.cc', + 'realisation.cc', + 'remote-fs-accessor.cc', + 'remote-store.cc', + 's3-binary-cache-store.cc', + 'serve-protocol.cc', + 'sqlite.cc', + 'ssh-store.cc', + 'ssh.cc', + 'store-api.cc', + 'uds-remote-store.cc', + 'worker-protocol.cc', + 'build/derivation-goal.cc', + 'build/drv-output-substitution-goal.cc', + 'build/entry-points.cc', + 'build/goal.cc', + 'build/hook-instance.cc', + 'build/local-derivation-goal.cc', + 'build/personality.cc', + 'build/substitution-goal.cc', + 'build/worker.cc', + 'builtins/buildenv.cc', + 'builtins/fetchurl.cc', + 'builtins/unpack-channel.cc', +) + +all_sources += { + 'libstore': libstore_sources, +} + +cpp_str_defines = { + 'NIX_PREFIX': get_option('prefix'), + 'LSOF': lsof.full_path(), + 'NIX_STORE_DIR': get_option('store-dir'), + 'NIX_DATA_DIR': get_option('prefix') / 'share', # FIXME: make separately-configurable + 'NIX_STATE_DIR': get_option('prefix') / 'nix', # FIXME: same + 'NIX_LOG_DIR': get_option('prefix') / 'log' / 'nix', # FIXME: same + 'NIX_CONF_DIR': get_option('prefix') / 'etc', # FIXME: same + 'NIX_BIN_DIR': get_option('prefix') / 'bin', # FIXME: same + 'NIX_MAN_DIR': get_option('prefix') / 'share' / 'man', # FIXME: same +} + +cpp_args = [] + +foreach name, value : cpp_str_defines + cpp_args += [ + '-D' + name + '=' + '"' + value + '"' + ] +endforeach + +library( + 'nixstore', + libstore_sources, + schema_sql_gen, + dependencies : [ + libarchive, + liblixutil, # Internal. + sqlite, + sodium, + curl, + openssl, + aws_sdk, + aws_s3, + aws_sdk_transfer, + ], + cpp_args : cpp_args, +) diff --git a/src/libutil/meson.build b/src/libutil/meson.build index cc930bea4..9cdde2d8e 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -1,5 +1,3 @@ - - libutil_sources = files( 'archive.cc', 'args.cc', @@ -34,7 +32,7 @@ all_sources += { 'libutil': libutil_sources, } -library( +libutil = library( 'nixutil', libutil_sources, dependencies : [ @@ -50,3 +48,8 @@ library( ], implicit_include_directories : true, ) + +liblixutil = declare_dependency( + include_directories : include_directories('.'), + link_with : libutil +)