Skip to content

Commit

Permalink
Meson misc things
Browse files Browse the repository at this point in the history
Co-Authored-By: Qyriad <[email protected]>
Co-Authored-By: eldritch horrors <[email protected]>
  • Loading branch information
3 people committed Aug 14, 2024
1 parent b41cc1a commit 6ef1bca
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build-utils-meson/export/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ foreach dep : deps_public_subproject
endforeach
requires_public += deps_public

extra_pkg_config_variables = get_variable('extra_pkg_config_variables', {})
import('pkgconfig').generate(
this_library,
filebase : meson.project_name(),
Expand All @@ -20,11 +21,13 @@ import('pkgconfig').generate(
requires : requires_public,
requires_private : requires_private,
libraries_private : libraries_private,
variables : extra_pkg_config_variables,
)

meson.override_dependency(meson.project_name(), declare_dependency(
include_directories : include_dirs,
link_with : this_library,
compile_args : ['-std=c++2a'],
dependencies : deps_public_subproject + deps_public,
variables : extra_pkg_config_variables,
))
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@
devShells = let
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs:
let
buildCanExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
modular = devFlake.getSystem stdenv.buildPlatform.system;
transformFlag = prefix: flag:
assert builtins.isString flag;
Expand Down Expand Up @@ -349,7 +350,7 @@
++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs
++ pkgs.nixComponents.nix-functional-tests.baseNativeBuildInputs
++ lib.optional
(!stdenv.buildPlatform.canExecute stdenv.hostPlatform
(!buildCanExecuteHost
# Hack around https://github.com/nixos/nixpkgs/commit/bf7ad8cfbfa102a90463433e2c5027573b462479
&& !(stdenv.hostPlatform.isWindows && stdenv.buildPlatform.isDarwin)
&& stdenv.hostPlatform.emulatorAvailable pkgs.buildPackages
Expand Down
1 change: 0 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

project('nix-dev-shell', 'cpp',
version : files('.version'),
subproject_dir : 'src',
)

# Internal Libraries
Expand Down
8 changes: 8 additions & 0 deletions misc/bash/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
configure_file(
input : 'completion.sh',
output : 'nix',
install : true,
install_dir : get_option('datadir') / 'bash-completion' / 'completions',
install_mode : 'rw-r--r--',
copy : true,
)
8 changes: 8 additions & 0 deletions misc/fish/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
configure_file(
input : 'completion.fish',
output : 'nix.fish',
install : true,
install_dir : get_option('datadir') / 'fish' / 'vendor_completions.d',
install_mode : 'rw-r--r--',
copy : true,
)
5 changes: 5 additions & 0 deletions misc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
subdir('bash')
subdir('fish')
subdir('zsh')

subdir('systemd')
25 changes: 25 additions & 0 deletions misc/systemd/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
foreach config : [ 'nix-daemon.socket', 'nix-daemon.service' ]
configure_file(
input : config + '.in',
output : config,
install : true,
install_dir : get_option('prefix') / 'lib/systemd/system',
install_mode : 'rw-r--r--',
configuration : {
'storedir' : store_dir,
'localstatedir' : state_dir,
'bindir' : get_option('datadir'),
},
)
endforeach

configure_file(
input : 'nix-daemon.conf.in',
output : 'nix-daemon.conf',
install : true,
install_dir : get_option('prefix') / 'lib/tmpfiles.d',
install_mode : 'rw-r--r--',
configuration : {
'localstatedir' : state_dir,
},
)
10 changes: 10 additions & 0 deletions misc/zsh/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
foreach script : [ [ 'completion.zsh', '_nix' ], [ 'run-help-nix' ] ]
configure_file(
input : script[0],
output : script.get(1, script[0]),
install : true,
install_dir : get_option('datadir') / 'zsh/site-functions',
install_mode : 'rw-r--r--',
copy : true,
)
endforeach
29 changes: 29 additions & 0 deletions scripts/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# configures `scripts/nix-profile.sh.in` (and copies the original to the build directory).
# this is only needed for tests, but running it unconditionally does not hurt enough to care.
configure_file(
input : 'nix-profile.sh.in',
output : 'nix-profile.sh',
configuration : {
'localstatedir': state_dir,
}
)

# https://github.com/mesonbuild/meson/issues/860
configure_file(
input : 'nix-profile.sh.in',
output : 'nix-profile.sh.in',
copy : true,
)

foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ]
configure_file(
input : 'nix-profile' + rc + '.in',
output : 'nix' + rc,
install : true,
install_dir : get_option('profile-dir'),
install_mode : 'rw-r--r--',
configuration : {
'localstatedir': state_dir,
},
)
endforeach
5 changes: 5 additions & 0 deletions src/libstore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,9 @@ install_headers(headers, subdir : 'nix', preserve_path : true)

libraries_private = []

extra_pkg_config_variables = {
'localstatedir' : get_option('state-dir'),
'storedir' : get_option('store-dir'),
}

subdir('build-utils-meson/export')
9 changes: 8 additions & 1 deletion src/nix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,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'),
Expand Down Expand Up @@ -244,3 +246,8 @@ custom_target(
)
# TODO(Ericson3214): Dosen't yet work
#meson.override_find_program(linkname, t)

state_dir = nix_store.get_variable('localstatedir')
store_dir = nix_store.get_variable('storedir')
subdir('scripts')
subdir('misc')
10 changes: 10 additions & 0 deletions src/nix/meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# vim: filetype=meson

option('state-dir', type : 'string', value : '/nix/var',
description : 'path to store state in for Nix',
)

# 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 change: 1 addition & 0 deletions src/nix/misc
8 changes: 7 additions & 1 deletion src/nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/nix/scripts
1 change: 1 addition & 0 deletions subprojects

0 comments on commit 6ef1bca

Please sign in to comment.