Merge "packaging: rename nixexpr -> lixexpr and so on" into main

This commit is contained in:
jade 2024-05-23 23:19:28 +00:00 committed by Gerrit Code Review
commit 9530b7f2b2
26 changed files with 181 additions and 77 deletions

View file

@ -0,0 +1,31 @@
---
synopsis: Rename all the libraries nixexpr, nixstore, etc to lixexpr, lixstore, etc
credits: jade
category: Breaking Changes
---
The Lix C++ API libraries have had the following changes:
- Includes moved from `include/nix/` to `include/lix/`
- `pkg-config` files renamed from `nix-expr` to `lix-expr` and so on.
- Libraries renamed from `libnixexpr.so` to `liblixexpr.so` and so on.
There are other changes between Nix 2.18 and Lix, since these APIs are not
stable. However, this change in particular is a deliberate compatibility break
to force downstreams linking to Lix to specifically handle Lix and avoid Lix
accidentally getting ensnared in compatibility code for newer CppNix.
Migration path:
- expr.hh -> lix/libexpr/expr.hh
- nix/config.h -> lix/config.h
To apply this migration automatically, remove all `<nix/>` from includes, so `#include <nix/expr.hh>` -> `#include <expr.hh>`.
Then, the correct paths will be resolved from the tangled mess, and the clang-tidy automated fix will work.
Then run the following for out of tree projects:
```console
lix_root=$HOME/lix
(cd $lix_root/clang-tidy && nix develop -c 'meson setup build && ninja -C build')
run-clang-tidy -checks='-*,lix-fixincludes' -load=$lix_root/clang-tidy/build/liblix-clang-tidy.so -p build/ -fix src
```

View file

@ -102,14 +102,14 @@ $ meson compile -C build nixexpr
All targets may be addressed as their output, relative to the build directory, e.g.: All targets may be addressed as their output, relative to the build directory, e.g.:
```bash ```bash
$ meson compile -C build src/libexpr/libnixexpr.so $ meson compile -C build src/libexpr/liblixexpr.so
``` ```
But Meson does not consider intermediate files like object files targets. But Meson does not consider intermediate files like object files targets.
To build a specific object file, use Ninja directly and specify the output file relative to the build directory: To build a specific object file, use Ninja directly and specify the output file relative to the build directory:
```bash ```bash
$ ninja -C build src/libexpr/libnixexpr.so.p/nixexpr.cc.o $ ninja -C build src/libexpr/liblixexpr.so.p/nixexpr.cc.o
``` ```
To inspect the canonical source of truth on what the state of the buildsystem configuration is, use: To inspect the canonical source of truth on what the state of the buildsystem configuration is, use:

View file

@ -395,7 +395,21 @@ config_h = configure_file(
output : 'config.h', output : 'config.h',
) )
install_headers(config_h, subdir : 'nix') install_headers(config_h, subdir : 'lix')
# FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here
configure_file(
input : 'src/lix-base.pc.in',
output : 'lix-base.pc',
install_dir : libdir / 'pkgconfig',
configuration : {
'prefix' : prefix,
'libdir' : libdir,
'includedir' : includedir,
'PACKAGE_VERSION' : meson.project_version(),
},
)
add_project_arguments( add_project_arguments(
# TODO(Qyriad): Yes this is how the autoconf+Make system did it. # TODO(Qyriad): Yes this is how the autoconf+Make system did it.

View file

@ -47,4 +47,4 @@ fi
# Intentionally not using -f. # Intentionally not using -f.
# If these files don't exist then our assumptions have been violated and we should fail. # If these files don't exist then our assumptions have been violated and we should fail.
rm -v "$includedir/nix/parser-tab.cc" "$includedir/nix/lexer-tab.cc" rm -v "$includedir/lix/libexpr/parser-tab.cc" "$includedir/lix/libexpr/lexer-tab.cc"

View file

@ -49,7 +49,7 @@
# internal fork of nix-doc providing :doc in the repl # internal fork of nix-doc providing :doc in the repl
lix-doc ? __forDefaults.lix-doc, lix-doc ? __forDefaults.lix-doc,
pname ? "nix", pname ? "lix",
versionSuffix ? "", versionSuffix ? "",
officialRelease ? false, officialRelease ? false,
# Set to true to build the release notes for the next release. # Set to true to build the release notes for the next release.
@ -333,7 +333,7 @@ stdenv.mkDerivation (finalAttrs: {
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
'' ''
+ lib.optionalString stdenv.isDarwin '' + lib.optionalString stdenv.isDarwin ''
for lib in libnixutil.dylib libnixexpr.dylib; do for lib in liblixutil.dylib liblixexpr.dylib; do
install_name_tool \ install_name_tool \
-change "${lib.getLib boost}/lib/libboost_context.dylib" \ -change "${lib.getLib boost}/lib/libboost_context.dylib" \
"$out/lib/libboost_context.dylib" \ "$out/lib/libboost_context.dylib" \

View file

@ -27,7 +27,7 @@ perl_libstore = shared_module(
], ],
link_args : [ link_args : [
# Nix doesn't provide a pkg-config file for libutil. # Nix doesn't provide a pkg-config file for libutil.
'-lnixutil', '-llixutil',
soname_args, soname_args,
], ],
install : true, install : true,

View file

@ -64,6 +64,6 @@ if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
add_project_link_arguments('-Wl,--no-copy-dt-needed-entries', language : 'cpp') add_project_link_arguments('-Wl,--no-copy-dt-needed-entries', language : 'cpp')
endif endif
libstore = dependency('nixstore', 'nix-store', required : true) libstore = dependency('lixstore', 'lix-store', required : true)
subdir('lib/Nix') subdir('lib/Nix')

10
src/libcmd/lix-cmd.pc.in Normal file
View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix (libcmd)
Description: Lix Package Manager (libcmd)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util
Libs: -L${libdir} -llixcmd
Cflags: -I${includedir}/lix/libcmd

View file

@ -39,7 +39,7 @@ libcmd_generated_headers = [
] ]
libcmd = library( libcmd = library(
'nixcmd', 'lixcmd',
libcmd_generated_headers, libcmd_generated_headers,
libcmd_sources, libcmd_sources,
dependencies : [ dependencies : [
@ -59,13 +59,13 @@ libcmd = library(
install_rpath : libdir, install_rpath : libdir,
) )
install_headers(libcmd_headers, subdir : 'nix', preserve_path : true) install_headers(libcmd_headers, subdir : 'lix/libcmd', preserve_path : true)
custom_target( custom_target(
command : [ 'cp', '@INPUT@', '@OUTPUT@' ], command : [ 'cp', '@INPUT@', '@OUTPUT@' ],
input : libcmd_generated_headers, input : libcmd_generated_headers,
output : '@PLAINNAME@', output : '@PLAINNAME@',
install : true, install : true,
install_dir : includedir / 'nix', install_dir : includedir / 'lix/libcmd',
) )
liblixcmd = declare_dependency( liblixcmd = declare_dependency(
@ -76,8 +76,8 @@ liblixcmd = declare_dependency(
# FIXME: not using the pkg-config module because it creates way too many deps # FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here # while meson migration is in progress, and we want to not include boost here
configure_file( configure_file(
input : 'nix-cmd.pc.in', input : 'lix-cmd.pc.in',
output : 'nix-cmd.pc', output : 'lix-cmd.pc',
install_dir : libdir / 'pkgconfig', install_dir : libdir / 'pkgconfig',
configuration : { configuration : {
'prefix' : prefix, 'prefix' : prefix,

View file

@ -1,9 +0,0 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Nix
Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lnixcmd
Cflags: -I${includedir}/nix -std=c++2a

View file

@ -4,5 +4,5 @@ libexpr_generated_headers += custom_target(
output : '@PLAINNAME@.gen.hh', output : '@PLAINNAME@.gen.hh',
capture : true, capture : true,
install : true, install : true,
install_dir : includedir / 'nix/flake', install_dir : includedir / 'lix/libexpr/flake',
) )

View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix libexpr
Description: Lix Package Manager (libexpr)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util lix-fetchers lix-store bdw-gc
Libs: -L${libdir} -llixexpr
Cflags: -I${includedir}/lix/libexpr

View file

@ -15,7 +15,7 @@ parser_tab = custom_target(
# NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add # NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add
# an install script below which removes parser-tab.cc. # an install script below which removes parser-tab.cc.
install : true, install : true,
install_dir : includedir / 'nix', install_dir : includedir / 'lix/libexpr',
) )
lexer_tab = custom_target( lexer_tab = custom_target(
@ -37,7 +37,7 @@ lexer_tab = custom_target(
# NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add # NOTE(Qyriad): Meson doesn't support installing only part of a custom target, so we add
# an install script below which removes lexer-tab.cc. # an install script below which removes lexer-tab.cc.
install : true, install : true,
install_dir : includedir / 'nix', install_dir : includedir / 'lix/libexpr',
) )
# TODO(Qyriad): When the parser and lexer are rewritten this should be removed. # TODO(Qyriad): When the parser and lexer are rewritten this should be removed.
@ -59,7 +59,7 @@ foreach header : [ 'imported-drv-to-derivation.nix', 'fetchurl.nix' ]
output : '@PLAINNAME@.gen.hh', output : '@PLAINNAME@.gen.hh',
capture : true, capture : true,
install : true, install : true,
install_dir : includedir / 'nix', install_dir : includedir / 'lix/libexpr',
) )
endforeach endforeach
subdir('flake') subdir('flake')
@ -127,7 +127,7 @@ libexpr_headers = files(
) )
libexpr = library( libexpr = library(
'nixexpr', 'lixexpr',
libexpr_sources, libexpr_sources,
parser_tab, parser_tab,
lexer_tab, lexer_tab,
@ -152,7 +152,7 @@ libexpr = library(
install_headers( install_headers(
libexpr_headers, libexpr_headers,
subdir : 'nix', subdir : 'lix/libexpr',
preserve_path : true, preserve_path : true,
) )
@ -164,8 +164,8 @@ liblixexpr = declare_dependency(
# FIXME: not using the pkg-config module because it creates way too many deps # FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here # while meson migration is in progress, and we want to not include boost here
configure_file( configure_file(
input : 'nix-expr.pc.in', input : 'lix-expr.pc.in',
output : 'nix-expr.pc', output : 'lix-expr.pc',
install_dir : libdir / 'pkgconfig', install_dir : libdir / 'pkgconfig',
configuration : { configuration : {
'prefix' : prefix, 'prefix' : prefix,

View file

@ -1,10 +0,0 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Nix
Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Requires: nix-store bdw-gc
Libs: -L${libdir} -lnixexpr
Cflags: -I${includedir}/nix -std=c++2a

View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix libfetchers
Description: Lix Package Manager (libfetchers)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util
Libs: -L${libdir} -llixfetchers
Cflags: -I${includedir}/lix/libfetchers

View file

@ -23,7 +23,7 @@ libfetchers_headers = files(
) )
libfetchers = library( libfetchers = library(
'nixfetchers', 'lixfetchers',
libfetchers_sources, libfetchers_sources,
dependencies : [ dependencies : [
liblixstore, liblixstore,
@ -35,7 +35,21 @@ libfetchers = library(
install_rpath : libdir, install_rpath : libdir,
) )
install_headers(libfetchers_headers, subdir : 'nix', preserve_path : true) install_headers(libfetchers_headers, subdir : 'lix/libfetchers', preserve_path : true)
# FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here
configure_file(
input : 'lix-fetchers.pc.in',
output : 'lix-fetchers.pc',
install_dir : libdir / 'pkgconfig',
configuration : {
'prefix' : prefix,
'libdir' : libdir,
'includedir' : includedir,
'PACKAGE_VERSION' : meson.project_version(),
},
)
liblixfetchers = declare_dependency( liblixfetchers = declare_dependency(
include_directories : include_directories('.'), include_directories : include_directories('.'),

View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix libmain
Description: Lix Package Manager (libmain)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util
Libs: -L${libdir} -llixmain
Cflags: -I${includedir}/lix/libmain

View file

@ -14,7 +14,7 @@ libmain_headers = files(
) )
libmain = library( libmain = library(
'nixmain', 'lixmain',
libmain_sources, libmain_sources,
dependencies : [ dependencies : [
liblixutil, liblixutil,
@ -25,7 +25,7 @@ libmain = library(
install_rpath : libdir, install_rpath : libdir,
) )
install_headers(libmain_headers, subdir : 'nix', preserve_path : true) install_headers(libmain_headers, subdir : 'lix/libmain', preserve_path : true)
liblixmain = declare_dependency( liblixmain = declare_dependency(
include_directories : include_directories('.'), include_directories : include_directories('.'),
@ -35,8 +35,8 @@ liblixmain = declare_dependency(
# FIXME: not using the pkg-config module because it creates way too many deps # FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here # while meson migration is in progress, and we want to not include boost here
configure_file( configure_file(
input : 'nix-main.pc.in', input : 'lix-main.pc.in',
output : 'nix-main.pc', output : 'lix-main.pc',
install_dir : libdir / 'pkgconfig', install_dir : libdir / 'pkgconfig',
configuration : { configuration : {
'prefix' : prefix, 'prefix' : prefix,

View file

@ -1,9 +0,0 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Nix
Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lnixmain
Cflags: -I${includedir}/nix -std=c++2a

View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix libstore
Description: Lix Package Manager (libstore)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util
Libs: -L${libdir} -llixstore -llixutil
Cflags: -I${includedir}/lix/libstore

View file

@ -6,7 +6,7 @@ foreach header : [ 'schema.sql', 'ca-specific-schema.sql' ]
output : '@PLAINNAME@.gen.hh', output : '@PLAINNAME@.gen.hh',
capture : true, capture : true,
install : true, install : true,
install_dir : includedir / 'nix', install_dir : includedir / 'lix/libstore',
) )
endforeach endforeach
@ -201,7 +201,7 @@ foreach name, value : cpp_str_defines
endforeach endforeach
libstore = library( libstore = library(
'nixstore', 'lixstore',
libstore_generated_headers, libstore_generated_headers,
libstore_sources, libstore_sources,
dependencies : [ dependencies : [
@ -224,7 +224,7 @@ libstore = library(
install_rpath : libdir, install_rpath : libdir,
) )
install_headers(libstore_headers, subdir : 'nix', preserve_path : true) install_headers(libstore_headers, subdir : 'lix/libstore', preserve_path : true)
# Used by libfetchers. # Used by libfetchers.
liblixstore = declare_dependency( liblixstore = declare_dependency(
@ -235,8 +235,8 @@ liblixstore = declare_dependency(
# FIXME: not using the pkg-config module because it creates way too many deps # FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here # while meson migration is in progress, and we want to not include boost here
configure_file( configure_file(
input : 'nix-store.pc.in', input : 'lix-store.pc.in',
output : 'nix-store.pc', output : 'lix-store.pc',
install_dir : libdir / 'pkgconfig', install_dir : libdir / 'pkgconfig',
configuration : { configuration : {
'prefix' : prefix, 'prefix' : prefix,

View file

@ -1,9 +0,0 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Nix
Description: Nix Package Manager
Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lnixstore -lnixutil
Cflags: -I${includedir}/nix -std=c++2a

View file

@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix libutil
Description: Lix Package Manager (libutil)
Version: @PACKAGE_VERSION@
Requires: lix-base lix-util
Libs: -L${libdir} -llixutil
Cflags: -I${includedir}/lix/libutil

View file

@ -100,7 +100,7 @@ libutil_headers = files(
) )
libutil = library( libutil = library(
'nixutil', 'lixutil',
libutil_sources, libutil_sources,
dependencies : [ dependencies : [
aws_sdk, aws_sdk,
@ -118,7 +118,21 @@ libutil = library(
install : true, install : true,
) )
install_headers(libutil_headers, subdir : 'nix', preserve_path : true) install_headers(libutil_headers, subdir : 'lix/libutil', preserve_path : true)
# FIXME: not using the pkg-config module because it creates way too many deps
# while meson migration is in progress, and we want to not include boost here
configure_file(
input : 'lix-util.pc.in',
output : 'lix-util.pc',
install_dir : libdir / 'pkgconfig',
configuration : {
'prefix' : prefix,
'libdir' : libdir,
'includedir' : includedir,
'PACKAGE_VERSION' : meson.project_version(),
},
)
# Used by libstore and libfetchers. # Used by libstore and libfetchers.
liblixutil = declare_dependency( liblixutil = declare_dependency(

8
src/lix-base.pc.in Normal file
View file

@ -0,0 +1,8 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
Name: Lix base
Description: Lix Package Manager (config.hh fixup)
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}/lix

View file

@ -17,7 +17,7 @@ libutil_test_support_sources = files(
'libutil-support/tests/terminal-code-eater.cc', 'libutil-support/tests/terminal-code-eater.cc',
) )
libutil_test_support = library( libutil_test_support = library(
'nixutil-test-support', 'lixutil-test-support',
libutil_test_support_sources, libutil_test_support_sources,
dependencies : [ dependencies : [
liblixutil, liblixutil,
@ -57,7 +57,7 @@ libutil_tests_sources = files(
) )
libutil_tester = executable( libutil_tester = executable(
'libnixutil-tests', 'liblixutil-tests',
libutil_tests_sources, libutil_tests_sources,
dependencies : [ dependencies : [
rapidcheck, rapidcheck,
@ -90,7 +90,7 @@ libstore_test_support_sources = files(
) )
libstore_test_support = library( libstore_test_support = library(
'nixstore-test-support', 'lixstore-test-support',
libstore_test_support_sources, libstore_test_support_sources,
dependencies : [ dependencies : [
liblixutil_test_support, liblixutil_test_support,
@ -124,7 +124,7 @@ libstore_tests_sources = files(
) )
libstore_tester = executable( libstore_tester = executable(
'libnixstore-tests', 'liblixstore-tests',
libstore_tests_sources, libstore_tests_sources,
dependencies : [ dependencies : [
liblixstore_test_support, liblixstore_test_support,
@ -154,7 +154,7 @@ libexpr_test_support_sources = files(
) )
libexpr_test_support = library( libexpr_test_support = library(
'nixexpr-test-support', 'lixexpr-test-support',
libexpr_test_support_sources, libexpr_test_support_sources,
dependencies : [ dependencies : [
liblixstore_test_support, liblixstore_test_support,
@ -185,7 +185,7 @@ libexpr_tests_sources = files(
) )
libexpr_tester = executable( libexpr_tester = executable(
'libnixexpr-tests', 'liblixexpr-tests',
libexpr_tests_sources, libexpr_tests_sources,
dependencies : [ dependencies : [
liblixexpr_test_support, liblixexpr_test_support,