meson: correctly differentiate $profiledir and $sysconfdir/profile.d

The configured sysconfdir is used to look for nix.conf, so it needs
to be /etc, and not $out/etc, so we separate out the place where shell
profile files are installed, which is the only other place sysconfdir is
at all used.

See https://git.lix.systems/lix-project/lix/issues/231#issuecomment-1989
for more info.

Change-Id: Idbed8ba82e711b8a9d6b6127904befa27d58e279
This commit is contained in:
Qyriad 2024-04-09 02:03:24 -06:00
parent 2a98fe28cb
commit 4b99f43aeb
3 changed files with 15 additions and 2 deletions

View file

@ -45,7 +45,6 @@ prefix = get_option('prefix')
path_opts = [ path_opts = [
# Meson built-ins. # Meson built-ins.
'datadir', 'datadir',
'sysconfdir',
'bindir', 'bindir',
'mandir', 'mandir',
'libdir', 'libdir',
@ -55,12 +54,14 @@ path_opts = [
'store-dir', 'store-dir',
'state-dir', 'state-dir',
'log-dir', 'log-dir',
'profile-dir',
] ]
# For your grepping pleasure, this loop sets the following variables that aren't mentioned # For your grepping pleasure, this loop sets the following variables that aren't mentioned
# literally above: # literally above:
# store_dir # store_dir
# state_dir # state_dir
# log_dir # log_dir
# profile_dir
foreach optname : path_opts foreach optname : path_opts
varname = optname.replace('-', '_') varname = optname.replace('-', '_')
path = get_option(optname) path = get_option(optname)
@ -71,6 +72,13 @@ foreach optname : path_opts
endif endif
endforeach endforeach
# sysconfdir doesn't get anything installed to directly, and is only used to
# tell Lix where to look for nix.conf, so it doesn't get appended to prefix.
sysconfdir = get_option('sysconfdir')
if not fs.is_absolute(sysconfdir)
sysconfdir = '/' / sysconfdir
endif
enable_docs = get_option('enable-docs') enable_docs = get_option('enable-docs')
enable_tests = get_option('enable-tests') enable_tests = get_option('enable-tests')

View file

@ -50,3 +50,8 @@ option('log-dir', type : 'string', value : '/nix/var/log',
option('enable-docs', type : 'boolean', value : true, option('enable-docs', type : 'boolean', value : true,
description : 'whether to build documentation', description : 'whether to build documentation',
) )
# 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',
)

View file

@ -20,7 +20,7 @@ foreach rc : [ '.sh', '.fish', '-daemon.sh', '-daemon.fish' ]
input : 'nix-profile' + rc + '.in', input : 'nix-profile' + rc + '.in',
output : 'nix' + rc, output : 'nix' + rc,
install : true, install : true,
install_dir : sysconfdir / 'profile.d', install_dir : profile_dir,
install_mode : 'rw-r--r--', install_mode : 'rw-r--r--',
configuration : { configuration : {
'localstatedir': state_dir, 'localstatedir': state_dir,