meson: getting the nix command building

Change-Id: If2f4a82b0d23a11a828bb4b305fabe4e30e1e91b
This commit is contained in:
Qyriad 2024-03-15 16:44:54 -06:00
parent 557dc678fd
commit 6fb79d08ae
6 changed files with 184 additions and 14 deletions

View file

@ -113,6 +113,7 @@ deps += lowdown
#
# Build-time tools
#
bash = find_program('bash')
lsof = find_program('lsof')
#
@ -196,14 +197,4 @@ add_project_arguments(
language : 'cpp',
)
subdir('src/libutil')
# Load-bearing order. libstore depends on libutil.
subdir('src/libstore')
# libfetchers depends on libstore.
subdir('src/libfetchers')
# libexpr depends on libfetchers.
subdir('src/libexpr')
# libmain depends on libutil and libstore.
subdir('src/libmain')
# libcmd depends on everything
subdir('src/libcmd')
subdir('src')

View file

@ -28,3 +28,8 @@ libcmd = library(
lowdown,
],
)
liblixcmd = declare_dependency(
include_directories : '.',
link_with : libcmd,
)

View file

@ -1,5 +1,3 @@
bash = find_program('bash')
schema_sql_gen = custom_target(
input : 'schema.sql',
output : 'schema.sql.gen.hh',
@ -90,18 +88,24 @@ all_sources += {
'libstore': libstore_sources,
}
prefix = get_option('prefix')
cpp_str_defines = {
'LSOF': lsof.full_path(),
'NIX_PREFIX': get_option('prefix'),
'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_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_str_defines += {
'NIX_STATE_DIR': '/nix/var/nix',
}
cpp_args = []
foreach name, value : cpp_str_defines

80
src/meson.build Normal file
View file

@ -0,0 +1,80 @@
# Subcomponents: these link into artifacts themselves, and have interdependencies.
subdir('libutil')
# Load-bearing order. libstore depends on libutil.
subdir('libstore')
# libfetchers depends on libstore
subdir('libfetchers')
# libexpr depends on all of the above
subdir('libexpr')
# libmain depends on libutil and libstore
subdir('libmain')
# libcmd depends on everything
subdir('libcmd')
# The rest of the subdirectories aren't separate components,
# just source files in another directory, so we process them here.
build_remote_sources = files(
'build-remote/build-remote.cc',
)
nix_build_sources = files(
'nix-build/nix-build.cc',
)
nix_channel_sources = files(
'nix-channel/nix-channel.cc',
)
unpack_channel_gen = custom_target(
input : 'nix-channel/unpack-channel.nix',
output : 'unpack-channel.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_collect_garbage_sources = files(
'nix-collect-garbage/nix-collect-garbage.cc',
)
nix_copy_closure_sources = files(
'nix-copy-closure/nix-copy-closure.cc',
)
nix_store_sources = files(
'nix-store/dotgraph.cc',
'nix-store/graphml.cc',
'nix-store/nix-store.cc',
)
nix_env_buildenv = custom_target(
input : 'nix-env/buildenv.nix',
output : 'buildenv.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_env_sources = files(
'nix-env/nix-env.cc',
'nix-env/user-env.cc',
)
# Hurray for Meson list flattening!
nix2_commands_sources = [
build_remote_sources,
nix_build_sources,
nix_channel_sources,
unpack_channel_gen,
nix_collect_garbage_sources,
nix_copy_closure_sources,
nix_store_sources,
nix_env_buildenv,
nix_env_sources,
]
# Finally, the nix command itself, which all of the other commands are implmented in terms of
# as a multicall binary.
subdir('nix')

4
src/nix-env/meson.build Normal file
View file

@ -0,0 +1,4 @@
nix_env_sources = files(
'nix-env.cc',
'user-env.cc'
)

86
src/nix/meson.build Normal file
View file

@ -0,0 +1,86 @@
generate_manpage_gen = custom_target(
input : meson.project_source_root() / 'doc/manual/generate-manpage.nix',
output : 'generate-manpage.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
utils_gen = custom_target(
input : meson.project_source_root() / 'doc/manual/utils.nix',
output : 'utils.nix.gen.hh',
command : [
bash,
'-c',
'echo \'R"foo(\' | cat - @INPUT@ && echo \')foo"\'',
],
capture : true,
)
nix_sources = files(
'add-to-store.cc',
'app.cc',
'build.cc',
'bundle.cc',
'cat.cc',
'copy.cc',
'daemon.cc',
'derivation-add.cc',
'derivation-show.cc',
'derivation.cc',
'develop.cc',
'diff-closures.cc',
'doctor.cc',
'dump-path.cc',
'edit.cc',
'eval.cc',
'flake.cc',
'fmt.cc',
'hash.cc',
'log.cc',
'ls.cc',
'main.cc',
'make-content-addressed.cc',
'nar.cc',
'optimise-store.cc',
'path-from-hash-part.cc',
'path-info.cc',
'ping-store.cc',
'prefetch.cc',
'profile.cc',
'realisation.cc',
'registry.cc',
'repl.cc',
'run.cc',
'search.cc',
'show-config.cc',
'sigs.cc',
'store-copy-log.cc',
'store-delete.cc',
'store-gc.cc',
'store-repair.cc',
'store.cc',
'upgrade-nix.cc',
'verify.cc',
'why-depends.cc',
)
nix = executable(
'nix',
nix_sources,
generate_manpage_gen,
utils_gen,
nix2_commands_sources,
dependencies : [
liblixcmd,
liblixutil,
liblixstore,
liblixexpr,
liblixfetchers,
liblixmain,
boehm,
],
)