Skip to content

Commit c7ec336

Browse files
Ericson2314Qyriadeldritch horrors
committed
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>
1 parent 8af73f0 commit c7ec336

19 files changed

Lines changed: 141 additions & 14 deletions

File tree

build-utils-meson/export/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ foreach dep : deps_public_subproject
1010
endforeach
1111
requires_public += deps_public
1212

13+
extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {})
1314
import('pkgconfig').generate(
1415
this_library,
1516
filebase : meson.project_name(),
@@ -20,11 +21,13 @@ import('pkgconfig').generate(
2021
requires : requires_public,
2122
requires_private : requires_private,
2223
libraries_private : libraries_private,
24+
variables : extra_pkg_config_variables,
2325
)
2426

2527
meson.override_dependency(meson.project_name(), declare_dependency(
2628
include_directories : include_dirs,
2729
link_with : this_library,
2830
compile_args : ['-std=c++2a'],
2931
dependencies : deps_public_subproject + deps_public,
32+
variables : extra_pkg_config_variables,
3033
))

flake.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
devShells = let
296296
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs:
297297
let
298+
buildCanExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
298299
modular = devFlake.getSystem stdenv.buildPlatform.system;
299300
transformFlag = prefix: flag:
300301
assert builtins.isString flag;
@@ -352,7 +353,7 @@
352353
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
353354
++ pkgs.nixComponents.nix-functional-tests.baseNativeBuildInputs
354355
++ lib.optional
355-
(!stdenv.buildPlatform.canExecute stdenv.hostPlatform
356+
(!buildCanExecuteHost
356357
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
357358
&& !(stdenv.hostPlatform.isWindows && stdenv.buildPlatform.isDarwin)
358359
&& stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages

meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
project('nix-dev-shell', 'cpp',
55
version : files('.version'),
6-
subproject_dir : 'src',
6+
default_options : [
7+
'localstatedir=/nix/var',
8+
]
79
)
810

911
# Internal Libraries

misc/bash/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
configure_file(
2+
input : 'completion.sh',
3+
output : 'nix',
4+
install : true,
5+
install_dir : get_option('datadir') / 'bash-completion' / 'completions',
6+
install_mode : 'rw-r--r--',
7+
copy : true,
8+
)

misc/fish/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
configure_file(
2+
input : 'completion.fish',
3+
output : 'nix.fish',
4+
install : true,
5+
install_dir : get_option('datadir') / 'fish' / 'vendor_completions.d',
6+
install_mode : 'rw-r--r--',
7+
copy : true,
8+
)

misc/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
subdir('bash')
2+
subdir('fish')
3+
subdir('zsh')
4+
5+
subdir('systemd')

misc/systemd/meson.build

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
foreach config : [ 'nix-daemon.socket', 'nix-daemon.service' ]
2+
configure_file(
3+
input : config + '.in',
4+
output : config,
5+
install : true,
6+
install_dir : get_option('prefix') / 'lib/systemd/system',
7+
install_mode : 'rw-r--r--',
8+
configuration : {
9+
'storedir' : store_dir,
10+
'localstatedir' : localstatedir,
11+
'bindir' : get_option('datadir'),
12+
},
13+
)
14+
endforeach
15+
16+
configure_file(
17+
input : 'nix-daemon.conf.in',
18+
output : 'nix-daemon.conf',
19+
install : true,
20+
install_dir : get_option('prefix') / 'lib/tmpfiles.d',
21+
install_mode : 'rw-r--r--',
22+
configuration : {
23+
'localstatedir' : localstatedir,
24+
},
25+
)

misc/zsh/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
foreach script : [ [ 'completion.zsh', '_nix' ], [ 'run-help-nix' ] ]
2+
configure_file(
3+
input : script[0],
4+
output : script.get(1, script[0]),
5+
install : true,
6+
install_dir : get_option('datadir') / 'zsh/site-functions',
7+
install_mode : 'rw-r--r--',
8+
copy : true,
9+
)
10+
endforeach

scripts/meson.build

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# configures `scripts/nix-profile.sh.in` (and copies the original to the build directory).
2+
# this is only needed for tests, but running it unconditionally does not hurt enough to care.
3+
configure_file(
4+
input : 'nix-profile.sh.in',
5+
output : 'nix-profile.sh',
6+
configuration : {
7+
'localstatedir': localstatedir,
8+
}
9+
)
10+
11+
# https://github.com/mesonbuild/meson/issues/860
12+
configure_file(
13+
input : 'nix-profile.sh.in',
14+
output : 'nix-profile.sh.in',
15+
copy : true,
16+
)
17+
18+
foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ]
19+
configure_file(
20+
input : 'nix-profile' + rc + '.in',
21+
output : 'nix' + rc,
22+
install : true,
23+
install_dir : get_option('profile-dir'),
24+
install_mode : 'rw-r--r--',
25+
configuration : {
26+
'localstatedir': localstatedir,
27+
},
28+
)
29+
endforeach

src/libstore/meson.build

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ project('nix-store', 'cpp',
77
'debug=true',
88
'optimization=2',
99
'errorlogs=true', # Please print logs for tests that fail
10+
'localstatedir=/nix/var',
1011
],
1112
meson_version : '>= 1.1',
1213
license : 'LGPL-2.1-or-later',
@@ -324,7 +325,7 @@ fs = import('fs')
324325

325326
prefix = get_option('prefix')
326327
# For each of these paths, assume that it is relative to the prefix unless
327-
# it is already an absolute path (which is the default for store-dir, state-dir, and log-dir).
328+
# it is already an absolute path (which is the default for store-dir, localstatedir, and log-dir).
328329
path_opts = [
329330
# Meson built-ins.
330331
'datadir',
@@ -334,13 +335,13 @@ path_opts = [
334335
'libexecdir',
335336
# Homecooked Nix directories.
336337
'store-dir',
337-
'state-dir',
338+
'localstatedir',
338339
'log-dir',
339340
]
340341
# For your grepping pleasure, this loop sets the following variables that aren't mentioned
341342
# literally above:
342343
# store_dir
343-
# state_dir
344+
# localstatedir
344345
# log_dir
345346
# profile_dir
346347
foreach optname : path_opts
@@ -364,12 +365,12 @@ lsof = find_program('lsof', required : false)
364365

365366
# Aside from prefix itself, each of these was made into an absolute path
366367
# by joining it with prefix, unless it was already an absolute path
367-
# (which is the default for store-dir, state-dir, and log-dir).
368+
# (which is the default for store-dir, localstatedir, and log-dir).
368369
cpp_str_defines = {
369370
'NIX_PREFIX': prefix,
370371
'NIX_STORE_DIR': store_dir,
371372
'NIX_DATA_DIR': datadir,
372-
'NIX_STATE_DIR': state_dir / 'nix',
373+
'NIX_STATE_DIR': localstatedir / 'nix',
373374
'NIX_LOG_DIR': log_dir,
374375
'NIX_CONF_DIR': sysconfdir / 'nix',
375376
'NIX_MAN_DIR': mandir,
@@ -421,4 +422,15 @@ install_headers(headers, subdir : 'nix', preserve_path : true)
421422

422423
libraries_private = []
423424

425+
extra_pkg_config_variables = {
426+
'storedir' : get_option('store-dir'),
427+
}
428+
429+
# Working around https://github.com/mesonbuild/meson/issues/13584
430+
if host_machine.system() != 'macos'
431+
extra_pkg_config_variables += {
432+
'localstatedir' : get_option('localstatedir'),
433+
}
434+
endif
435+
424436
subdir('build-utils-meson/export')

0 commit comments

Comments
 (0)