1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

Meson misc things

Meson-ify a few things, scripts, completions, etc. Should make our Meson
build complete except for docs.

Co-Authored-By: Qyriad <qyriad@qyriad.me>
Co-Authored-By: eldritch horrors <pennae@lix.systems>
This commit is contained in:
John Ericson 2024-08-14 16:19:35 -04:00
parent 8af73f0a74
commit c7ec33605e
19 changed files with 141 additions and 14 deletions

View file

@ -7,6 +7,7 @@ project('nix-store', 'cpp',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
'localstatedir=/nix/var',
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
@ -324,7 +325,7 @@ fs = import('fs')
prefix = get_option('prefix')
# For each of these paths, assume that it is relative to the prefix unless
# it is already an absolute path (which is the default for store-dir, state-dir, and log-dir).
# it is already an absolute path (which is the default for store-dir, localstatedir, and log-dir).
path_opts = [
# Meson built-ins.
'datadir',
@ -334,13 +335,13 @@ path_opts = [
'libexecdir',
# Homecooked Nix directories.
'store-dir',
'state-dir',
'localstatedir',
'log-dir',
]
# For your grepping pleasure, this loop sets the following variables that aren't mentioned
# literally above:
# store_dir
# state_dir
# localstatedir
# log_dir
# profile_dir
foreach optname : path_opts
@ -364,12 +365,12 @@ lsof = find_program('lsof', required : false)
# Aside from prefix itself, each of these was made into an absolute path
# by joining it with prefix, unless it was already an absolute path
# (which is the default for store-dir, state-dir, and log-dir).
# (which is the default for store-dir, localstatedir, and log-dir).
cpp_str_defines = {
'NIX_PREFIX': prefix,
'NIX_STORE_DIR': store_dir,
'NIX_DATA_DIR': datadir,
'NIX_STATE_DIR': state_dir / 'nix',
'NIX_STATE_DIR': localstatedir / 'nix',
'NIX_LOG_DIR': log_dir,
'NIX_CONF_DIR': sysconfdir / 'nix',
'NIX_MAN_DIR': mandir,
@ -421,4 +422,15 @@ install_headers(headers, subdir : 'nix', preserve_path : true)
libraries_private = []
extra_pkg_config_variables = {
'storedir' : get_option('store-dir'),
}
# Working around https://github.com/mesonbuild/meson/issues/13584
if host_machine.system() != 'macos'
extra_pkg_config_variables += {
'localstatedir' : get_option('localstatedir'),
}
endif
subdir('build-utils-meson/export')

View file

@ -16,10 +16,6 @@ option('store-dir', type : 'string', value : '/nix/store',
description : 'path of the Nix store',
)
option('state-dir', type : 'string', value : '/nix/var',
description : 'path to store state in for Nix',
)
option('log-dir', type : 'string', value : '/nix/var/log/nix',
description : 'path to store logs in for Nix',
)

View file

@ -129,7 +129,6 @@ sources = files(
'english.cc',
'environment-variables.cc',
'error.cc',
'exec.hh',
'executable-path.cc',
'exit.cc',
'experimental-features.cc',
@ -186,6 +185,7 @@ headers = [config_h] + files(
'english.hh',
'environment-variables.hh',
'error.hh',
'exec.hh',
'executable-path.hh',
'exit.hh',
'experimental-features.hh',

View file

@ -7,6 +7,7 @@ project('nix', 'cpp',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
'localstatedir=/nix/var',
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
@ -16,9 +17,11 @@ cxx = meson.get_compiler('cpp')
subdir('build-utils-meson/deps-lists')
nix_store = dependency('nix-store')
deps_private_maybe_subproject = [
dependency('nix-util'),
dependency('nix-store'),
nix_store,
dependency('nix-expr'),
dependency('nix-flake'),
dependency('nix-fetchers'),
@ -244,3 +247,12 @@ custom_target(
)
# TODO(Ericson3214): Dosen't yet work
#meson.override_find_program(linkname, t)
localstatedir = nix_store.get_variable(
'localstatedir',
default_value : get_option('localstatedir'),
)
assert(localstatedir == get_option('localstatedir'))
store_dir = nix_store.get_variable('storedir')
subdir('scripts')
subdir('misc')

6
src/nix/meson.options Normal file
View file

@ -0,0 +1,6 @@
# vim: filetype=meson
# A relative path means it gets appended to prefix.
option('profile-dir', type : 'string', value : 'etc/profile.d',
description : 'the path to install shell profile files',
)

1
src/nix/misc Symbolic link
View file

@ -0,0 +1 @@
../../misc

View file

@ -36,9 +36,10 @@ mkMesonDerivation (finalAttrs: {
../../.version
./.version
./meson.build
# ./meson.options
./meson.options
# Symbolic links to other dirs
## exes
./build-remote
./doc
./nix-build
@ -48,6 +49,11 @@ mkMesonDerivation (finalAttrs: {
./nix-env
./nix-instantiate
./nix-store
## dirs
./scripts
../../scripts
./misc
../../misc
# Doc nix files for --help
../../doc/manual/generate-manpage.nix

1
src/nix/scripts Symbolic link
View file

@ -0,0 +1 @@
../../scripts