diff --git a/flake.nix b/flake.nix index fc46ef940..cfea7d386 100644 --- a/flake.nix +++ b/flake.nix @@ -324,6 +324,7 @@ ++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs ++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs ++ [ + pkgs.buildPackages.cmake modular.pre-commit.settings.package (pkgs.writeScriptBin "pre-commit-hooks-install" modular.pre-commit.settings.installationScript) diff --git a/meson.build b/meson.build index e969fc907..fb38d7ef2 100644 --- a/meson.build +++ b/meson.build @@ -13,8 +13,8 @@ subproject('libexpr') subproject('libflake') # Docs -#subproject('internal-api-docs') -#subproject('external-api-docs') +subproject('internal-api-docs') +subproject('external-api-docs') # C wrappers subproject('libutil-c') diff --git a/src/libexpr-c/package.nix b/src/libexpr-c/package.nix index 542be064d..33412e218 100644 --- a/src/libexpr-c/package.nix +++ b/src/libexpr-c/package.nix @@ -62,9 +62,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libexpr-test-support/package.nix b/src/libexpr-test-support/package.nix index cbc852fa5..ecfb2bb09 100644 --- a/src/libexpr-test-support/package.nix +++ b/src/libexpr-test-support/package.nix @@ -64,9 +64,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libexpr-test/meson.build b/src/libexpr-test/meson.build index f70fd0693..04b60f6d6 100644 --- a/src/libexpr-test/meson.build +++ b/src/libexpr-test/meson.build @@ -17,18 +17,12 @@ cxx = meson.get_compiler('cpp') subdir('build-utils-meson/deps-lists') deps_private_maybe_subproject = [ -] -deps_public_maybe_subproject = [ - dependency('nix-util'), - dependency('nix-util-c'), - dependency('nix-util-test-support'), - dependency('nix-store'), - dependency('nix-store-c'), - dependency('nix-store-test-support'), dependency('nix-expr'), dependency('nix-expr-c'), dependency('nix-expr-test-support'), ] +deps_public_maybe_subproject = [ +] subdir('build-utils-meson/subprojects') subdir('build-utils-meson/export-all-symbols') diff --git a/src/libexpr-test/package.nix b/src/libexpr-test/package.nix index 7c8c9c4d1..12f4dd506 100644 --- a/src/libexpr-test/package.nix +++ b/src/libexpr-test/package.nix @@ -69,9 +69,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/call-flake.nix similarity index 100% rename from src/libexpr/flake/call-flake.nix rename to src/libexpr/call-flake.nix diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index d2be00e55..48ed66883 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -293,7 +293,7 @@ EvalState::EvalState( )} , callFlakeInternal{internalFS->addFile( CanonPath("call-flake.nix"), - #include "flake/call-flake.nix.gen.hh" + #include "call-flake.nix.gen.hh" )} , store(store) , buildStore(buildStore ? buildStore : store) diff --git a/src/libexpr/local.mk b/src/libexpr/local.mk index 26958bf2c..68518e184 100644 --- a/src/libexpr/local.mk +++ b/src/libexpr/local.mk @@ -47,4 +47,4 @@ $(foreach i, $(wildcard src/libexpr/value/*.hh), \ $(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh -$(d)/eval.cc: $(d)/primops/derivation.nix.gen.hh $(d)/fetchurl.nix.gen.hh $(d)/flake/call-flake.nix.gen.hh +$(d)/eval.cc: $(d)/primops/derivation.nix.gen.hh $(d)/fetchurl.nix.gen.hh $(d)/call-flake.nix.gen.hh diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index fdf264604..04822d179 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -55,6 +55,9 @@ if bdw_gc.found() endif configdata.set('HAVE_BOEHMGC', bdw_gc.found().to_int()) +toml11 = dependency('toml11', version : '>=3.7.0', method : 'cmake') +deps_other += toml11 + config_h = configure_file( configuration : configdata, output : 'config-expr.hh', @@ -117,8 +120,7 @@ generated_headers = [] foreach header : [ 'imported-drv-to-derivation.nix', 'fetchurl.nix', - 'flake/call-flake.nix', - 'primops/derivation.nix', + 'call-flake.nix', ] generated_headers += custom_target( command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ], @@ -142,11 +144,6 @@ sources = files( 'nixexpr.cc', 'paths.cc', 'primops.cc', - 'primops/context.cc', - 'primops/fetchClosure.cc', - 'primops/fetchMercurial.cc', - 'primops/fetchTree.cc', - 'primops/fromTOML.cc', 'print-ambiguous.cc', 'print.cc', 'search-path.cc', @@ -187,6 +184,8 @@ headers = [config_h] + files( 'value/context.hh', ) +subdir('primops') + this_library = library( 'nixexpr', sources, diff --git a/src/libexpr/package.nix b/src/libexpr/package.nix index 14fbf0a06..855d5057e 100644 --- a/src/libexpr/package.nix +++ b/src/libexpr/package.nix @@ -5,6 +5,9 @@ , meson , ninja , pkg-config +, bison +, flex +, cmake # for resolving toml11 dep , nix-util , nix-store @@ -12,6 +15,7 @@ , boost , boehmgc , nlohmann_json +, toml11 # Configuration Options @@ -57,8 +61,12 @@ mkDerivation (finalAttrs: { fileset = fileset.unions [ ./meson.build ./meson.options + ./primops/meson.build (fileset.fileFilter (file: file.hasExt "cc") ./.) (fileset.fileFilter (file: file.hasExt "hh") ./.) + ./lexer.l + ./parser.y + (fileset.fileFilter (file: file.hasExt "nix") ./.) ]; }; @@ -68,6 +76,13 @@ mkDerivation (finalAttrs: { meson ninja pkg-config + bison + flex + cmake + ]; + + buildInputs = [ + toml11 ]; propagatedBuildInputs = [ @@ -79,9 +94,11 @@ mkDerivation (finalAttrs: { ] ++ lib.optional enableGC boehmgc; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libexpr/primops/meson.build b/src/libexpr/primops/meson.build new file mode 100644 index 000000000..96a1dd07e --- /dev/null +++ b/src/libexpr/primops/meson.build @@ -0,0 +1,17 @@ +foreach header : [ + 'derivation.nix', +] + generated_headers += custom_target( + command : [ 'bash', '-c', '{ echo \'R"__NIX_STR(\' && cat @INPUT@ && echo \')__NIX_STR"\'; } > "$1"', '_ignored_argv0', '@OUTPUT@' ], + input : header, + output : '@PLAINNAME@.gen.hh', + ) +endforeach + +sources += files( + 'context.cc', + 'fetchClosure.cc', + 'fetchMercurial.cc', + 'fetchTree.cc', + 'fromTOML.cc', +) diff --git a/src/libfetchers-test/meson.build b/src/libfetchers-test/meson.build index e7c5b7873..785754b34 100644 --- a/src/libfetchers-test/meson.build +++ b/src/libfetchers-test/meson.build @@ -17,16 +17,11 @@ cxx = meson.get_compiler('cpp') subdir('build-utils-meson/deps-lists') deps_private_maybe_subproject = [ -] -deps_public_maybe_subproject = [ - dependency('nix-util'), - dependency('nix-util-c'), - dependency('nix-util-test-support'), - dependency('nix-store'), - dependency('nix-store-c'), dependency('nix-store-test-support'), dependency('nix-fetchers'), ] +deps_public_maybe_subproject = [ +] subdir('build-utils-meson/subprojects') subdir('build-utils-meson/export-all-symbols') @@ -43,8 +38,6 @@ add_project_arguments( '-include', 'config-util.hh', '-include', 'config-store.hh', '-include', 'config-store.hh', - '-include', 'config-util.h', - '-include', 'config-store.h', language : 'cpp', ) diff --git a/src/libfetchers-test/package.nix b/src/libfetchers-test/package.nix index f4d3f3b73..78d8ab490 100644 --- a/src/libfetchers-test/package.nix +++ b/src/libfetchers-test/package.nix @@ -67,9 +67,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libfetchers/meson.build b/src/libfetchers/meson.build index 257e15766..d5703bbb3 100644 --- a/src/libfetchers/meson.build +++ b/src/libfetchers/meson.build @@ -30,7 +30,7 @@ nlohmann_json = dependency('nlohmann_json', version : '>= 3.9') deps_public += nlohmann_json libgit2 = dependency('libgit2') -deps_public += libgit2 +deps_private += libgit2 add_project_arguments( # TODO(Qyriad): Yes this is how the autoconf+Make system did it. diff --git a/src/libfetchers/package.nix b/src/libfetchers/package.nix index d2560255e..0146f5aa5 100644 --- a/src/libfetchers/package.nix +++ b/src/libfetchers/package.nix @@ -69,9 +69,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so its not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { diff --git a/src/libflake-test/meson.build b/src/libflake-test/meson.build index dd3f658be..b8221b2ad 100644 --- a/src/libflake-test/meson.build +++ b/src/libflake-test/meson.build @@ -17,19 +17,11 @@ cxx = meson.get_compiler('cpp') subdir('build-utils-meson/deps-lists') deps_private_maybe_subproject = [ -] -deps_public_maybe_subproject = [ - dependency('nix-util'), - dependency('nix-util-c'), - dependency('nix-util-test-support'), - dependency('nix-store'), - dependency('nix-store-c'), - dependency('nix-store-test-support'), - dependency('nix-expr'), - dependency('nix-expr-c'), dependency('nix-expr-test-support'), dependency('nix-flake'), ] +deps_public_maybe_subproject = [ +] subdir('build-utils-meson/subprojects') subdir('build-utils-meson/export-all-symbols') @@ -46,9 +38,6 @@ add_project_arguments( '-include', 'config-util.hh', '-include', 'config-store.hh', '-include', 'config-expr.hh', - '-include', 'config-util.h', - '-include', 'config-store.h', - '-include', 'config-expr.h', language : 'cpp', ) diff --git a/src/libflake-test/package.nix b/src/libflake-test/package.nix index f03f58619..4fb190706 100644 --- a/src/libflake-test/package.nix +++ b/src/libflake-test/package.nix @@ -67,9 +67,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libflake/meson.build b/src/libflake/meson.build index e43d21dd3..30f98dce6 100644 --- a/src/libflake/meson.build +++ b/src/libflake/meson.build @@ -29,9 +29,6 @@ subdir('build-utils-meson/subprojects') nlohmann_json = dependency('nlohmann_json', version : '>= 3.9') deps_public += nlohmann_json -libgit2 = dependency('libgit2') -deps_public += libgit2 - add_project_arguments( # TODO(Qyriad): Yes this is how the autoconf+Make system did it. # It would be nice for our headers to be idempotent instead. diff --git a/src/libflake/package.nix b/src/libflake/package.nix index 1280df7b7..523da4b78 100644 --- a/src/libflake/package.nix +++ b/src/libflake/package.nix @@ -69,9 +69,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so its not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) { diff --git a/src/libstore-c/package.nix b/src/libstore-c/package.nix index 2ed78a760..d0e81b1f9 100644 --- a/src/libstore-c/package.nix +++ b/src/libstore-c/package.nix @@ -62,9 +62,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libstore-test-support/package.nix b/src/libstore-test-support/package.nix index a28f54e2a..0f4ea73ba 100644 --- a/src/libstore-test-support/package.nix +++ b/src/libstore-test-support/package.nix @@ -64,9 +64,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libstore-test/meson.build b/src/libstore-test/meson.build index 6599b2d96..bfd827b01 100644 --- a/src/libstore-test/meson.build +++ b/src/libstore-test/meson.build @@ -17,15 +17,12 @@ cxx = meson.get_compiler('cpp') subdir('build-utils-meson/deps-lists') deps_private_maybe_subproject = [ -] -deps_public_maybe_subproject = [ - dependency('nix-util'), - dependency('nix-util-c'), - dependency('nix-util-test-support'), dependency('nix-store'), dependency('nix-store-c'), dependency('nix-store-test-support'), ] +deps_public_maybe_subproject = [ +] subdir('build-utils-meson/subprojects') subdir('build-utils-meson/export-all-symbols') diff --git a/src/libstore-test/package.nix b/src/libstore-test/package.nix index b57adfea5..0a49f1a05 100644 --- a/src/libstore-test/package.nix +++ b/src/libstore-test/package.nix @@ -69,9 +69,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libstore/package.nix b/src/libstore/package.nix index 5af1a7815..a08fabff7 100644 --- a/src/libstore/package.nix +++ b/src/libstore/package.nix @@ -87,9 +87,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libutil-c/package.nix b/src/libutil-c/package.nix index 37f2291b5..ba1dbe38a 100644 --- a/src/libutil-c/package.nix +++ b/src/libutil-c/package.nix @@ -60,9 +60,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libutil-test-support/package.nix b/src/libutil-test-support/package.nix index c6a0f0183..795159ebf 100644 --- a/src/libutil-test-support/package.nix +++ b/src/libutil-test-support/package.nix @@ -62,9 +62,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libutil-test/meson.build b/src/libutil-test/meson.build index b90148f21..19157cda3 100644 --- a/src/libutil-test/meson.build +++ b/src/libutil-test/meson.build @@ -17,12 +17,12 @@ cxx = meson.get_compiler('cpp') subdir('build-utils-meson/deps-lists') deps_private_maybe_subproject = [ -] -deps_public_maybe_subproject = [ dependency('nix-util'), dependency('nix-util-c'), dependency('nix-util-test-support'), ] +deps_public_maybe_subproject = [ +] subdir('build-utils-meson/subprojects') subdir('build-utils-meson/export-all-symbols') diff --git a/src/libutil-test/package.nix b/src/libutil-test/package.nix index 391f8d853..396e41f3d 100644 --- a/src/libutil-test/package.nix +++ b/src/libutil-test/package.nix @@ -69,9 +69,11 @@ mkDerivation (finalAttrs: { ]; preConfigure = - # "Inline" .version so it's not a symlink, and includes the suffix + # "Inline" .version so it's not a symlink, and includes the suffix. + # Do the meson utils, without modification. '' echo ${version} > .version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [ diff --git a/src/libutil/package.nix b/src/libutil/package.nix index ef5e251fb..aff338d16 100644 --- a/src/libutil/package.nix +++ b/src/libutil/package.nix @@ -79,9 +79,11 @@ mkMesonDerivation (finalAttrs: { preConfigure = # TODO: change release process to add `pre` in `.version`, remove it before tagging, and restore after. + # Do the meson utils, without modification. '' chmod u+w ./.version echo ${version} > ../../.version + cp -r ${../../build-utils-meson} build-utils-meson ''; mesonFlags = [