From 9714f41023ae3bf273e46828ecdd0ae0d1f915be Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 00:44:49 -0300 Subject: [PATCH 01/61] Use Meson to build Nix --- rfcs/0132-use-meson-to-build-nix.md | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 rfcs/0132-use-meson-to-build-nix.md diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md new file mode 100644 index 000000000..d99142dc1 --- /dev/null +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -0,0 +1,121 @@ +--- +feature: use_meson_to_build_nix +start-date: 2022-08-25 +author: Anderson Torres +co-authors: @p01arst0rm +shepherd-team: +shepherd-leader: +related-issues: +--- + +# Summary +[summary]: #summary + +Use meson as an alternative build system for the reference implementation of +Nix. + +# Motivation +[motivation]: #motivation + +Currently, the reference implementation of Nix evaluator and its companion +toolset generated from the Nix source tree are built using an autotools-like +script. + +This quasi-autotools script became clunky and plastered, and consequently hard +to understand, modify, improve and port to other systems besides Linux. + +Such state of things hinders development, specially outside the Linux and NixOS +niches. + +In light of this, we propose a novel, from-scratch alternative build +infrastructure. + +We expect to accomplish, among other goals, + +- better code structuring +- improved cross-platform support, especially in other programming environments, + including but not limited to Unix-like operating systems; +- shorter build times; +- an overall improved user experience. + +# Detailed design +[design]: #detailed-design + +A carefully crafted set of files written in Meson should be included in the Nix +repository, in order to describe how to deploy the Nix repository, generating +all the expected artifacts (command line tools, libraries, configuration files +etc.) + +This novel build infrastructure should be able to provide at least all the +features already present on the current quasi-autotools implementation, possibly +with a different user interface. + +# Examples and Interactions +[examples-and-interactions]: #examples-and-interactions + +Currently @p01arst0rm is writing an implementation from scratch. + +# Drawbacks +[drawbacks]: #drawbacks + +Some possible drawbacks: + +- A new build system would require changes on the code + + On the other hand, such changes are likely to improve the code base. + +- A new build system requires the developers become familiarized with it + - Specially when this build system uses its own description language + + However, the Meson language is easy to grasp, specially for those + familiarized with Python, besides being well documented. + +- A new build system indirectly brings its own dependencies to the Nix project + - In particular, the reference implementation of Meson is written in Python. + - Further, this reference implementation generates script files meant to be + consumed by Ninja, a tool written in C++ that acts like a Make replacement. + - This particular setting brings concerns about complexifying the bootstrap + route. + + Given that Nix is currently written in C++, we can assume a C++ compiler as + part of such a bootstrap route. + + There are full-featured alternative tools that replace Meson and Ninja. + Namely, Muon and Samurai are implementations of Meson and Ninja that require + only a C compiler and a set of POSIX standard tools. + +- A new build system would require new strategies from the end users + - In particular, package managers that deploy Nix for their respective + platforms + + However, Meson is nowadays a widespread tool, used in many open source + projects ranging from DOSBox Staging and mpv to GNOME and Xorg; therefore it + is already included in many package managers' databases + +# Alternatives +[alternatives]: #alternatives + +The alternatives are + +- Doing nothing + + It would keep the current code confusing and harder to work with. + +- Other building systems (cmake, waf, scons etc.) + - Their strenghts and weaknesses should be evaluated. + - Tools like waf and scons are strongly discouraged, because they are tied + to other programming languages, bringing the bootstrap concerns already + discussed above. + +# Unresolved questions +[unresolved]: #unresolved-questions + +Questions that deserve furtehr inquiry: + +- Unexpected interactions with Meson and Ninja + - Specially, vendoring and reproducibility. +- Smooth the transition between the old and new build systems + - A wrapper script, maybe? + +# Future work +[future]: #future-work + +- Deprecate the quasi-autotools script set +- Backport the new build system to Nix 2.3 + - It was the latest release without Flakes support; it is important to + bring such a deep modification to it. From 85759af05666d8e550a7fb17bedbf01caffacc5d Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:39:41 -0300 Subject: [PATCH 02/61] Modify feature attribute `meson_builds_nix` is a more cool name. --- rfcs/0132-use-meson-to-build-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index d99142dc1..9e08b10b7 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -1,5 +1,5 @@ --- -feature: use_meson_to_build_nix +feature: meson_builds_nix start-date: 2022-08-25 author: Anderson Torres co-authors: @p01arst0rm From 003393ef4d2bcf8435d33d7635ff4b01905950aa Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:41:03 -0300 Subject: [PATCH 03/61] Small clarification --- rfcs/0132-use-meson-to-build-nix.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index 9e08b10b7..c2fd47ad4 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -18,11 +18,12 @@ Nix. [motivation]: #motivation Currently, the reference implementation of Nix evaluator and its companion -toolset generated from the Nix source tree are built using an autotools-like -script. +toolset generated from the Nix source tree are built using the typical +`./configure` shell script that relies on autoconf and the standard GNU Make +utility. -This quasi-autotools script became clunky and plastered, and consequently hard -to understand, modify, improve and port to other systems besides Linux. +This build system became clunky and plastered, and consequently hard to +understand, modify, improve and port to other systems besides Linux. Such state of things hinders development, specially outside the Linux and NixOS niches. From 3e0be881f7eeff5f9fecfc51769bc175f9cad184 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:45:33 -0300 Subject: [PATCH 04/61] Reformulates the alternatives section --- rfcs/0132-use-meson-to-build-nix.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index c2fd47ad4..0c2d015dc 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -97,11 +97,16 @@ The alternatives are It would keep the current code confusing and harder to work with. -- Other building systems (cmake, waf, scons etc.) +- Other building systems (cmake, waf, premake etc.) - Their strenghts and weaknesses should be evaluated. - - Tools like waf and scons are strongly discouraged, because they are tied - to other programming languages, bringing the bootstrap concerns already - discussed above. + - Tools strongly tied to other programming languages are strongly + discouraged, because they further complexifies the bootstrap route as + discussed above. Namely, waf is basically a Python libraries, whereas + premake is a Lua library. + - Cmake has many noteworthy advantages: + - Can generates Make- and Ninja-compatible scripts; + - Supports Windows NT + - Supports typical high level idiomatic constructions # Unresolved questions [unresolved]: #unresolved-questions From d4497fd591d02ee6bfa3bcc857447ca755142fbb Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:49:55 -0300 Subject: [PATCH 05/61] Answer new drawback --- rfcs/0132-use-meson-to-build-nix.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index 0c2d015dc..518235e16 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -88,6 +88,10 @@ Some possible drawbacks: projects ranging from DOSBox Staging and mpv to GNOME and Xorg; therefore it is already included in many package managers' databases +- The transition between between the old and new build systems should be smooth + - A wrapper script, maybe? + + Meson is not an obscure project; a mere documentation update should suffice + # Alternatives [alternatives]: #alternatives @@ -115,8 +119,6 @@ Questions that deserve furtehr inquiry: - Unexpected interactions with Meson and Ninja - Specially, vendoring and reproducibility. -- Smooth the transition between the old and new build systems - - A wrapper script, maybe? # Future work [future]: #future-work From 18c732d7e3787e74c27e7dbdbd7fc2c04116a016 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:50:39 -0300 Subject: [PATCH 06/61] Typo --- rfcs/0132-use-meson-to-build-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index 518235e16..96ef37073 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -115,7 +115,7 @@ The alternatives are # Unresolved questions [unresolved]: #unresolved-questions -Questions that deserve furtehr inquiry: +Questions that deserve further inquiry: - Unexpected interactions with Meson and Ninja - Specially, vendoring and reproducibility. From a843fb1a5f0bdee11589cbc7935f22f85aaa0a86 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:51:04 -0300 Subject: [PATCH 07/61] Rewording --- rfcs/0132-use-meson-to-build-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index 96ef37073..85ad48b27 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -123,7 +123,7 @@ Questions that deserve further inquiry: # Future work [future]: #future-work -- Deprecate the quasi-autotools script set +- Deprecate the current build scripts - Backport the new build system to Nix 2.3 - It was the latest release without Flakes support; it is important to bring such a deep modification to it. From 0bf382d9095ebfc3aa4616e09a44c55a8f8939aa Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:54:18 -0300 Subject: [PATCH 08/61] Unfill the paragraphs --- rfcs/0132-use-meson-to-build-nix.md | 62 +++++++++-------------------- 1 file changed, 19 insertions(+), 43 deletions(-) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-use-meson-to-build-nix.md index 85ad48b27..f18c18424 100644 --- a/rfcs/0132-use-meson-to-build-nix.md +++ b/rfcs/0132-use-meson-to-build-nix.md @@ -11,45 +11,32 @@ related-issues: # Summary [summary]: #summary -Use meson as an alternative build system for the reference implementation of -Nix. +Use meson as an alternative build system for the reference implementation of Nix. # Motivation [motivation]: #motivation -Currently, the reference implementation of Nix evaluator and its companion -toolset generated from the Nix source tree are built using the typical -`./configure` shell script that relies on autoconf and the standard GNU Make -utility. +Currently, the reference implementation of Nix evaluator and its companion toolset generated from the Nix source tree are built using the typical `./configure` shell script that relies on autoconf and the standard GNU Make utility. -This build system became clunky and plastered, and consequently hard to -understand, modify, improve and port to other systems besides Linux. +This build system became clunky and plastered, and consequently hard to understand, modify, improve and port to other systems besides Linux. -Such state of things hinders development, specially outside the Linux and NixOS -niches. +Such state of things hinders development, specially outside the Linux and NixOS niches. -In light of this, we propose a novel, from-scratch alternative build -infrastructure. +In light of this, we propose a novel, from-scratch alternative build infrastructure. We expect to accomplish, among other goals, - better code structuring -- improved cross-platform support, especially in other programming environments, - including but not limited to Unix-like operating systems; +- improved cross-platform support, especially in other programming environments, including but not limited to Unix-like operating systems; - shorter build times; - an overall improved user experience. # Detailed design [design]: #detailed-design -A carefully crafted set of files written in Meson should be included in the Nix -repository, in order to describe how to deploy the Nix repository, generating -all the expected artifacts (command line tools, libraries, configuration files -etc.) +A carefully crafted set of files written in Meson should be included in the Nix repository, in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) -This novel build infrastructure should be able to provide at least all the -features already present on the current quasi-autotools implementation, possibly -with a different user interface. +This novel build infrastructure should be able to provide at least all the features already present on the current quasi-autotools implementation, possibly with a different user interface. # Examples and Interactions [examples-and-interactions]: #examples-and-interactions @@ -66,27 +53,19 @@ Some possible drawbacks: - A new build system requires the developers become familiarized with it - Specially when this build system uses its own description language - + However, the Meson language is easy to grasp, specially for those - familiarized with Python, besides being well documented. + + However, the Meson language is easy to grasp, specially for those familiarized with Python, besides being well documented. - A new build system indirectly brings its own dependencies to the Nix project - In particular, the reference implementation of Meson is written in Python. - - Further, this reference implementation generates script files meant to be - consumed by Ninja, a tool written in C++ that acts like a Make replacement. - - This particular setting brings concerns about complexifying the bootstrap - route. - + Given that Nix is currently written in C++, we can assume a C++ compiler as - part of such a bootstrap route. - + There are full-featured alternative tools that replace Meson and Ninja. - Namely, Muon and Samurai are implementations of Meson and Ninja that require - only a C compiler and a set of POSIX standard tools. + - Further, this reference implementation generates script files meant to be consumed by Ninja, a tool written in C++ that acts like a Make replacement. + - This particular setting brings concerns about complexifying the bootstrap route. + + Given that Nix is currently written in C++, we can assume a C++ compiler as part of such a bootstrap route. + + There are full-featured alternative tools that replace Meson and Ninja. + + Namely, Muon and Samurai are implementations of Meson and Ninja that require only a C compiler and a set of POSIX standard tools. - A new build system would require new strategies from the end users - - In particular, package managers that deploy Nix for their respective - platforms - + However, Meson is nowadays a widespread tool, used in many open source - projects ranging from DOSBox Staging and mpv to GNOME and Xorg; therefore it - is already included in many package managers' databases + - In particular, package managers that deploy Nix for their respective platforms + + However, Meson is nowadays a widespread tool, used in many open source projects ranging from DOSBox Staging and mpv to GNOME and Xorg; therefore it is already included in many package managers' databases - The transition between between the old and new build systems should be smooth - A wrapper script, maybe? @@ -103,10 +82,8 @@ The alternatives are - Other building systems (cmake, waf, premake etc.) - Their strenghts and weaknesses should be evaluated. - - Tools strongly tied to other programming languages are strongly - discouraged, because they further complexifies the bootstrap route as - discussed above. Namely, waf is basically a Python libraries, whereas - premake is a Lua library. + - Tools strongly tied to other programming languages are strongly discouraged, because they further complexifies the bootstrap route as discussed above. + - Namely, waf is basically a Python library, whereas premake is a Lua library. - Cmake has many noteworthy advantages: - Can generates Make- and Ninja-compatible scripts; - Supports Windows NT @@ -125,5 +102,4 @@ Questions that deserve further inquiry: - Deprecate the current build scripts - Backport the new build system to Nix 2.3 - - It was the latest release without Flakes support; it is important to - bring such a deep modification to it. + - It was the latest release without Flakes support; it is important to bring such a deep modification to it. From 6c3f5d23d9767141602d1d80accad7f2c7c38b4e Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 25 Aug 2022 22:55:32 -0300 Subject: [PATCH 09/61] Rename RFC file --- rfcs/{0132-use-meson-to-build-nix.md => 0132-meson-builds-nix.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename rfcs/{0132-use-meson-to-build-nix.md => 0132-meson-builds-nix.md} (100%) diff --git a/rfcs/0132-use-meson-to-build-nix.md b/rfcs/0132-meson-builds-nix.md similarity index 100% rename from rfcs/0132-use-meson-to-build-nix.md rename to rfcs/0132-meson-builds-nix.md From bd4bfe9ca5e2cd11f0a85de2c8e3a38beb7ceaa1 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 26 Aug 2022 23:58:20 -0300 Subject: [PATCH 10/61] Small punctuation fixes --- rfcs/0132-meson-builds-nix.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index f18c18424..c458ded8f 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -26,7 +26,7 @@ In light of this, we propose a novel, from-scratch alternative build infrastruct We expect to accomplish, among other goals, -- better code structuring +- better code structuring; - improved cross-platform support, especially in other programming environments, including but not limited to Unix-like operating systems; - shorter build times; - an overall improved user experience. @@ -52,8 +52,8 @@ Some possible drawbacks: + On the other hand, such changes are likely to improve the code base. - A new build system requires the developers become familiarized with it - - Specially when this build system uses its own description language - + However, the Meson language is easy to grasp, specially for those familiarized with Python, besides being well documented. + - Specially when this build system uses its own description language. + + However, Meson is well documented, and its language is easy to grasp, specially for those familiarized with Python. - A new build system indirectly brings its own dependencies to the Nix project - In particular, the reference implementation of Meson is written in Python. @@ -85,9 +85,10 @@ The alternatives are - Tools strongly tied to other programming languages are strongly discouraged, because they further complexifies the bootstrap route as discussed above. - Namely, waf is basically a Python library, whereas premake is a Lua library. - Cmake has many noteworthy advantages: - - Can generates Make- and Ninja-compatible scripts; - - Supports Windows NT - - Supports typical high level idiomatic constructions + + Can generates Make- and Ninja-compatible scripts; + + Supports Windows NT; + + Supports typical high level idiomatic constructions; + - On the other hand, the language is arguably more complex. # Unresolved questions [unresolved]: #unresolved-questions From e1a0620e2e5dfecb4416f97661070c3695a177b9 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 26 Aug 2022 23:58:57 -0300 Subject: [PATCH 11/61] Rewording --- rfcs/0132-meson-builds-nix.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index c458ded8f..920591629 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -64,8 +64,10 @@ Some possible drawbacks: + Namely, Muon and Samurai are implementations of Meson and Ninja that require only a C compiler and a set of POSIX standard tools. - A new build system would require new strategies from the end users - - In particular, package managers that deploy Nix for their respective platforms - + However, Meson is nowadays a widespread tool, used in many open source projects ranging from DOSBox Staging and mpv to GNOME and Xorg; therefore it is already included in many package managers' databases + - In particular, package managers that deploy Nix for their respective platforms. + + However, Meson and Ninja are nowadays a widespread toolset. + + Many open source projects use it, from mpv and dosbox-staging to Xorg and GNOME + + According to Repology, Meson is present in 53 package manager's families - The transition between between the old and new build systems should be smooth - A wrapper script, maybe? From 006093741ca6072775d88b5da89e3535c37a0d68 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 27 Aug 2022 00:10:01 -0300 Subject: [PATCH 12/61] Add usage example --- rfcs/0132-meson-builds-nix.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 920591629..85cf5b311 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -43,6 +43,14 @@ This novel build infrastructure should be able to provide at least all the featu Currently @p01arst0rm is writing an implementation from scratch. +Some typical expected interactions are: + +- Configuring: `meson setup build_dir` +- Building: `ninja -C build_dir` (or the backend-agnostic `meson -C build_dir compile`) +- Installing: `ninja -C build_dir install` (or the backend-agnostic `meson -C build_dir install`) + +Usually, commandline options assume the format `-Dname=value`. This small change in user interface when compared to the typical `--name=value` is mostly harmless. + # Drawbacks [drawbacks]: #drawbacks From 265020c39bbdcbc7535496e8a02794184b04b048 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 26 Aug 2022 23:59:25 -0300 Subject: [PATCH 13/61] Add references --- rfcs/0132-meson-builds-nix.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 85cf5b311..f4ef56601 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -114,3 +114,11 @@ Questions that deserve further inquiry: - Deprecate the current build scripts - Backport the new build system to Nix 2.3 - It was the latest release without Flakes support; it is important to bring such a deep modification to it. + +# References +[references]: #references + +- [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) +- [Muon](https://muon.build/), a C99 implementation of [Meson](https://meson.build/) +- [Samurai](https://github.com/michaelforney/samurai), a C99 implementation of [Ninja](https://ninja-build.org/) +- [Cmake](https://cmake.org/) From b7b859b328a2cf0e00fc0b7a4974f49260c37803 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 27 Aug 2022 14:12:22 -0300 Subject: [PATCH 14/61] Improvements on the wording --- rfcs/0132-meson-builds-nix.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index f4ef56601..2f4f783df 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -16,27 +16,28 @@ Use meson as an alternative build system for the reference implementation of Nix # Motivation [motivation]: #motivation -Currently, the reference implementation of Nix evaluator and its companion toolset generated from the Nix source tree are built using the typical `./configure` shell script that relies on autoconf and the standard GNU Make utility. +Currently, the reference implementation of Nix evaluator, as well as its companion toolset generated from the Nix source tree, is built using the typical `./configure` shell script that relies on autoconf, along with standard GNU Make utility. -This build system became clunky and plastered, and consequently hard to understand, modify, improve and port to other systems besides Linux. +Over time, this build system has been modified to keep up with the development needs of Nix projec. However, it has reached a state where the build system became clunky and plastered, hard to understand and modify, consequently making improvements to the project as a whole very difficult. -Such state of things hinders development, specially outside the Linux and NixOS niches. +In particular, many changes have been introduced that impact compatibility outside Linux and NixOS niches. These issues can hinder development on other platforms, including but not limited to Unix-like systems. -In light of this, we propose a novel, from-scratch alternative build infrastructure. +In light of this state of things, propose a novel alternative to the current buildsystem infrastructure. We expect to accomplish, among other goals, -- better code structuring; +- better code structuring and documentation; - improved cross-platform support, especially in other programming environments, including but not limited to Unix-like operating systems; - shorter build times; +- improved unit testing; - an overall improved user experience. # Detailed design [design]: #detailed-design -A carefully crafted set of files written in Meson should be included in the Nix repository, in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) +A carefully crafted set of Meson files should be included in the Nix repository, in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) -This novel build infrastructure should be able to provide at least all the features already present on the current quasi-autotools implementation, possibly with a different user interface. +This novel build infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit with a different user interface. # Examples and Interactions [examples-and-interactions]: #examples-and-interactions @@ -61,11 +62,12 @@ Some possible drawbacks: - A new build system requires the developers become familiarized with it - Specially when this build system uses its own description language. - + However, Meson is well documented, and its language is easy to grasp, specially for those familiarized with Python. + + However, Meson is well documented, and its Python-esque language is easy to grasp. - A new build system indirectly brings its own dependencies to the Nix project - In particular, the reference implementation of Meson is written in Python. - - Further, this reference implementation generates script files meant to be consumed by Ninja, a tool written in C++ that acts like a Make replacement. + - Further, this reference implementation generates script files meant to be consumed by Ninja. + - Ninja is a tool written in C++ that acts like a `make` replacement. - This particular setting brings concerns about complexifying the bootstrap route. + Given that Nix is currently written in C++, we can assume a C++ compiler as part of such a bootstrap route. + There are full-featured alternative tools that replace Meson and Ninja. @@ -73,8 +75,8 @@ Some possible drawbacks: - A new build system would require new strategies from the end users - In particular, package managers that deploy Nix for their respective platforms. - + However, Meson and Ninja are nowadays a widespread toolset. - + Many open source projects use it, from mpv and dosbox-staging to Xorg and GNOME + + However, Meson and Ninja are a widespread toolset. + + Many open source projects use Meson, from mpv and dosbox-staging to Xorg and GNOME + According to Repology, Meson is present in 53 package manager's families - The transition between between the old and new build systems should be smooth @@ -96,9 +98,10 @@ The alternatives are - Namely, waf is basically a Python library, whereas premake is a Lua library. - Cmake has many noteworthy advantages: + Can generates Make- and Ninja-compatible scripts; - + Supports Windows NT; + + Supports Windows NT and MacOS platforms + Supports typical high level idiomatic constructions; - - On the other hand, the language is arguably more complex. + - On the other hand, cmake language is arguably more complex. + - Both Meson and Cmake support Apple Xcode and Microsoft MSVC project file formats # Unresolved questions [unresolved]: #unresolved-questions @@ -111,7 +114,7 @@ Questions that deserve further inquiry: # Future work [future]: #future-work -- Deprecate the current build scripts +- Deprecate and remove the current quasi-autotools scripts - Backport the new build system to Nix 2.3 - It was the latest release without Flakes support; it is important to bring such a deep modification to it. From 3eea629d29afbd2af81b2ed69e3117942b940a9a Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:03:36 -0300 Subject: [PATCH 15/61] Reword the reference to Nix It is unneeded to make a distinction between Nix language and its implementation. --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 2f4f783df..f0880e395 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -11,12 +11,12 @@ related-issues: # Summary [summary]: #summary -Use meson as an alternative build system for the reference implementation of Nix. +Use meson as an alternative build system for Nix. # Motivation [motivation]: #motivation -Currently, the reference implementation of Nix evaluator, as well as its companion toolset generated from the Nix source tree, is built using the typical `./configure` shell script that relies on autoconf, along with standard GNU Make utility. +Currently, the Nix evaluator and its companion toolset generated from the Nix source tree are built using the typical `./configure` shell script that relies on autoconf, along with standard GNU Make utility. Over time, this build system has been modified to keep up with the development needs of Nix projec. However, it has reached a state where the build system became clunky and plastered, hard to understand and modify, consequently making improvements to the project as a whole very difficult. From 8650a36a8b046af17c253a8556759c193341d167 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:08:48 -0300 Subject: [PATCH 16/61] Typo projec -> project --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index f0880e395..de3f7d372 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -18,7 +18,7 @@ Use meson as an alternative build system for Nix. Currently, the Nix evaluator and its companion toolset generated from the Nix source tree are built using the typical `./configure` shell script that relies on autoconf, along with standard GNU Make utility. -Over time, this build system has been modified to keep up with the development needs of Nix projec. However, it has reached a state where the build system became clunky and plastered, hard to understand and modify, consequently making improvements to the project as a whole very difficult. +Over time, this build system has been modified to keep up with the development needs of Nix project. However, it has reached a state where the build system became clunky and plastered, hard to understand and modify, consequently making improvements to the project as a whole very difficult. In particular, many changes have been introduced that impact compatibility outside Linux and NixOS niches. These issues can hinder development on other platforms, including but not limited to Unix-like systems. From ab2dec16a8105f12321754f093e6023227a6b356 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:09:20 -0300 Subject: [PATCH 17/61] Typo Word "we" was lost. --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index de3f7d372..09fca9c5a 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -22,7 +22,7 @@ Over time, this build system has been modified to keep up with the development n In particular, many changes have been introduced that impact compatibility outside Linux and NixOS niches. These issues can hinder development on other platforms, including but not limited to Unix-like systems. -In light of this state of things, propose a novel alternative to the current buildsystem infrastructure. +In light of this state of things, we propose a novel alternative to the current building infrastructure. We expect to accomplish, among other goals, From 6980048cf70614c7fe9a920921d8b6dc888f051a Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:10:56 -0300 Subject: [PATCH 18/61] Reword a paragraph --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 09fca9c5a..fbcdd53c9 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -27,7 +27,7 @@ In light of this state of things, we propose a novel alternative to the current We expect to accomplish, among other goals, - better code structuring and documentation; -- improved cross-platform support, especially in other programming environments, including but not limited to Unix-like operating systems; +- improved cross-platform support, especially outside NixOS and Linux programming environments - shorter build times; - improved unit testing; - an overall improved user experience. From b58c8b632f433285ddedb3feb48fd2843f253466 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:12:12 -0300 Subject: [PATCH 19/61] Reword the detailed design --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index fbcdd53c9..76157eb22 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -35,9 +35,9 @@ We expect to accomplish, among other goals, # Detailed design [design]: #detailed-design -A carefully crafted set of Meson files should be included in the Nix repository, in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) +A carefully crafted set of Meson files should be included in the Nix repository, providing a description on how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) -This novel build infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit with a different user interface. +This novel building infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit in a different user interface. # Examples and Interactions [examples-and-interactions]: #examples-and-interactions From 17069b687d9babc4eb9b88282d7313de214f7454 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:13:27 -0300 Subject: [PATCH 20/61] Reword the examples A comparison table is cleaner than a dot list. --- rfcs/0132-meson-builds-nix.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 76157eb22..fee6155e1 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -44,13 +44,16 @@ This novel building infrastructure should be able to provide at least feature pa Currently @p01arst0rm is writing an implementation from scratch. -Some typical expected interactions are: - -- Configuring: `meson setup build_dir` -- Building: `ninja -C build_dir` (or the backend-agnostic `meson -C build_dir compile`) -- Installing: `ninja -C build_dir install` (or the backend-agnostic `meson -C build_dir install`) - -Usually, commandline options assume the format `-Dname=value`. This small change in user interface when compared to the typical `--name=value` is mostly harmless. +Here is a table comparing some expected interactions: + +|----------------------|--------------------|------------------------------| +| Action | Current | Meson | +|----------------------|--------------------|------------------------------| +| Configuring | `./configure` | `meson setup build_dir` | +| Building | `make` | `meson -C build_dir compile` | +| Installing | `make install` | `meson -C build_dir install` | +| Command-line Options | `--enable-gc=true` | `-Dgc=enabled` | +|----------------------|--------------------|------------------------------| # Drawbacks [drawbacks]: #drawbacks From 9821ad257afb6a80c97fe4e4e3de01cdd71cd2e5 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:14:49 -0300 Subject: [PATCH 21/61] Add a paragraph about the current (quasi-) autotools --- rfcs/0132-meson-builds-nix.md | 1 + 1 file changed, 1 insertion(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index fee6155e1..aafc60821 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -75,6 +75,7 @@ Some possible drawbacks: + Given that Nix is currently written in C++, we can assume a C++ compiler as part of such a bootstrap route. + There are full-featured alternative tools that replace Meson and Ninja. + Namely, Muon and Samurai are implementations of Meson and Ninja that require only a C compiler and a set of POSIX standard tools. + + Autotools also have its own set of dependencies, and a fair comparison should include them - A new build system would require new strategies from the end users - In particular, package managers that deploy Nix for their respective platforms. From ab42c2fec540a64783ee0dcbec6985a0cc627459 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:15:38 -0300 Subject: [PATCH 22/61] Reword commentary about transition --- rfcs/0132-meson-builds-nix.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index aafc60821..cc55d18cd 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -84,8 +84,7 @@ Some possible drawbacks: + According to Repology, Meson is present in 53 package manager's families - The transition between between the old and new build systems should be smooth - - A wrapper script, maybe? - + Meson is not an obscure project; a mere documentation update should suffice + + Meson is not an obscure project; a careful documentation update should be sufficient # Alternatives [alternatives]: #alternatives From 3111e49299cf633f9d7bd72074c8523fe2cc06e6 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:17:00 -0300 Subject: [PATCH 23/61] Reword alternatives --- rfcs/0132-meson-builds-nix.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index cc55d18cd..3ab5368fb 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -95,9 +95,10 @@ The alternatives are It would keep the current code confusing and harder to work with. -- Other building systems (cmake, waf, premake etc.) +- Other building systems (waf, premake, cmake etc.) - Their strenghts and weaknesses should be evaluated. - - Tools strongly tied to other programming languages are strongly discouraged, because they further complexifies the bootstrap route as discussed above. + - Tools strongly tied to other programming languages are strongly discouraged + - They complexify the bootstrap route as discussed above. - Namely, waf is basically a Python library, whereas premake is a Lua library. - Cmake has many noteworthy advantages: + Can generates Make- and Ninja-compatible scripts; From 9d89692d48ce577d4dc4acb85cbd96659d32811c Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:17:28 -0300 Subject: [PATCH 24/61] Reword commentary about Cmake --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 3ab5368fb..d90f3a15c 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -102,10 +102,10 @@ The alternatives are - Namely, waf is basically a Python library, whereas premake is a Lua library. - Cmake has many noteworthy advantages: + Can generates Make- and Ninja-compatible scripts; - + Supports Windows NT and MacOS platforms + Supports typical high level idiomatic constructions; - On the other hand, cmake language is arguably more complex. - - Both Meson and Cmake support Apple Xcode and Microsoft MSVC project file formats + + Both Meson and Cmake support Microsoft Windows NT and Apple MacOS platforms; + + including project file formats of both MSVC and Xcode. # Unresolved questions [unresolved]: #unresolved-questions From dca9276b4cfbd597742268e0296eca0fbcc84702 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:18:28 -0300 Subject: [PATCH 25/61] Remove commentary about backport --- rfcs/0132-meson-builds-nix.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index d90f3a15c..6558026a0 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -119,8 +119,6 @@ Questions that deserve further inquiry: [future]: #future-work - Deprecate and remove the current quasi-autotools scripts -- Backport the new build system to Nix 2.3 - - It was the latest release without Flakes support; it is important to bring such a deep modification to it. # References [references]: #references From 38f3c44dff3872b4ebcd4c01b1c9196471a5693f Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:18:59 -0300 Subject: [PATCH 26/61] Bring more items to future work --- rfcs/0132-meson-builds-nix.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 6558026a0..1dcc21845 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -118,7 +118,11 @@ Questions that deserve further inquiry: # Future work [future]: #future-work +- Update project's continuous integration and related stuff - Deprecate and remove the current quasi-autotools scripts + - Preferably, the removal should be allocated to a minor version release +- Evaluate the positive and negative impacts of such a change + - Specially the most subjective ones # References [references]: #references From 714457bb3615f78525d2b06951c5041870a7a161 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 00:19:42 -0300 Subject: [PATCH 27/61] Add references Two tutorials from NetBSD and Meson docs about converting autotools to Meson. --- rfcs/0132-meson-builds-nix.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 1dcc21845..bb3ac57f5 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -131,3 +131,5 @@ Questions that deserve further inquiry: - [Muon](https://muon.build/), a C99 implementation of [Meson](https://meson.build/) - [Samurai](https://github.com/michaelforney/samurai), a C99 implementation of [Ninja](https://ninja-build.org/) - [Cmake](https://cmake.org/) +- [Meson tutorial](https://mesonbuild.com/Porting-from-autotools.html) comparing autotools and Meson +- [NetBSD tutorial](https://wiki.netbsd.org/pkgsrc/how_to_convert_autotools_to_meson/) comparing Meson and autotools From 894946b762c6d4fcce9a7727f04232cb2e50822b Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 31 Aug 2022 23:29:51 -0300 Subject: [PATCH 28/61] Reorder references --- rfcs/0132-meson-builds-nix.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index bb3ac57f5..f681d91d8 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -127,9 +127,12 @@ Questions that deserve further inquiry: # References [references]: #references -- [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) -- [Muon](https://muon.build/), a C99 implementation of [Meson](https://meson.build/) -- [Samurai](https://github.com/michaelforney/samurai), a C99 implementation of [Ninja](https://ninja-build.org/) -- [Cmake](https://cmake.org/) +- [Meson](https://meson.build/) official site + - [Muon](https://muon.build/), a C99 alternative implementation +- [Ninja](https://ninja-build.org/) official site + - [Samurai](https://github.com/michaelforney/samurai), a C99 alternative implementation +- [CMake](https://cmake.org/) - [Meson tutorial](https://mesonbuild.com/Porting-from-autotools.html) comparing autotools and Meson - [NetBSD tutorial](https://wiki.netbsd.org/pkgsrc/how_to_convert_autotools_to_meson/) comparing Meson and autotools + +- [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) From 72dec20d2939176ac32a1089a9576432e5f3ba08 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 1 Sep 2022 01:01:56 -0300 Subject: [PATCH 29/61] Reword motivation section --- rfcs/0132-meson-builds-nix.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index f681d91d8..2678aeb20 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -27,9 +27,10 @@ In light of this state of things, we propose a novel alternative to the current We expect to accomplish, among other goals, - better code structuring and documentation; -- improved cross-platform support, especially outside NixOS and Linux programming environments +- improved support across platforms, especially outside NixOS and Linux - shorter build times; -- improved unit testing; +- improved testing; +- more reasonable dependency management; - an overall improved user experience. # Detailed design From 6d8f6bdc73bdd5dfb85dd840893504cce1a5919c Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 1 Sep 2022 01:02:38 -0300 Subject: [PATCH 30/61] Reword paragraph --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 2678aeb20..6976b4c99 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -36,7 +36,7 @@ We expect to accomplish, among other goals, # Detailed design [design]: #detailed-design -A carefully crafted set of Meson files should be included in the Nix repository, providing a description on how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files etc.) +A carefully crafted set of Meson files should be included in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files, documentation etc.) This novel building infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit in a different user interface. From 94eb5c75f2cc117930de5f426155e78cd9bcb926 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 1 Sep 2022 01:03:07 -0300 Subject: [PATCH 31/61] Rework examples and interactions --- rfcs/0132-meson-builds-nix.md | 54 +++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 6976b4c99..7cd033e75 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -43,18 +43,54 @@ This novel building infrastructure should be able to provide at least feature pa # Examples and Interactions [examples-and-interactions]: #examples-and-interactions -Currently @p01arst0rm is writing an implementation from scratch. +Before the examples, some informative paragraphs: + +## What is Meson? + +Meson is an open source, multiplatform build system crafted to be fast, correct and user-friendly. + +According to its main site, + +> The main design point of Meson is that every moment a developer spends writing or debugging build definitions is a second wasted. So is every second spent waiting for the build system to actually start compiling code. + +Among its features, we highlight: + +- user-friendly non-Turing complete DSL + - very readable Python-esque syntax and functional, stateless semantics +- multiplatform support + - among operating systems: Linux, Apple MacOS, Microsoft Windows NT + - among programming environments: GCC, Clang, Xcode, Visual Studio etc. + - among programming languages: C, C++, D, Fortran, Java, Rust etc. + - supports command customization + - cross compilation + - many useful modules included (pkg-config, filesystem inspection, internationalization etc.) +- Comprehensive documentation + - including tutorials, reference manuals and real world projects using it + +## What is Ninja? + +Ninja is a small, speed-focused, build tool that fills a similar role of Unix `make` or GNU `gmake`. + +Its main feature is a low-level approach to build description. Where other build systems act like high level languages, Ninja acts like an assembly. + +Ninja is bare-bones and constrained by design, having only the necessary semantics to describe build dependency graphs, relegating decision-making to superior tools like Meson or CMake. + +Ninja DSL is human-readable, however it is not convenient to be manually written by human beings. As said before, Ninja is commonly used in tandem with other, higher-level build system. + +## Example interaction Here is a table comparing some expected interactions: -|----------------------|--------------------|------------------------------| -| Action | Current | Meson | -|----------------------|--------------------|------------------------------| -| Configuring | `./configure` | `meson setup build_dir` | -| Building | `make` | `meson -C build_dir compile` | -| Installing | `make install` | `meson -C build_dir install` | -| Command-line Options | `--enable-gc=true` | `-Dgc=enabled` | -|----------------------|--------------------|------------------------------| +| Action | Current | Meson+Ninja | Meson, backend-agnostic | +|-----------|--------------------------------|--------------------------------------|--------------------------------------| +| Configure | `./configure --enable-gc=true` | `meson setup build_dir -Dgc=enabled` | `meson setup build_dir -Dgc=enabled` | +| Build | `make` | `ninja -C build_dir build` | `meson -C build_dir compile` | +| Install | `make install` | `ninja -C build_dir install` | `meson -C build_dir install` | +| Uninstall | `make uninstall` | `ninja -C build_dir unistall` | `meson -C build_dir unistall` | + +## Implementation + +Currently, @p01arst0rm is working on an implementation from scratch. # Drawbacks [drawbacks]: #drawbacks From 934555d58b61d6d524138dfd9d2d6a24f402f80d Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 1 Sep 2022 01:04:48 -0300 Subject: [PATCH 32/61] Rework drawbacks --- rfcs/0132-meson-builds-nix.md | 69 ++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 7cd033e75..19041545d 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -95,33 +95,50 @@ Currently, @p01arst0rm is working on an implementation from scratch. # Drawbacks [drawbacks]: #drawbacks -Some possible drawbacks: +Below we will list some possible drawbacks and balances to them. -- A new build system would require changes on the code - + On the other hand, such changes are likely to improve the code base. - -- A new build system requires the developers become familiarized with it - - Specially when this build system uses its own description language. - + However, Meson is well documented, and its Python-esque language is easy to grasp. - -- A new build system indirectly brings its own dependencies to the Nix project - - In particular, the reference implementation of Meson is written in Python. - - Further, this reference implementation generates script files meant to be consumed by Ninja. - - Ninja is a tool written in C++ that acts like a `make` replacement. - - This particular setting brings concerns about complexifying the bootstrap route. - + Given that Nix is currently written in C++, we can assume a C++ compiler as part of such a bootstrap route. - + There are full-featured alternative tools that replace Meson and Ninja. - + Namely, Muon and Samurai are implementations of Meson and Ninja that require only a C compiler and a set of POSIX standard tools. - + Autotools also have its own set of dependencies, and a fair comparison should include them - -- A new build system would require new strategies from the end users - - In particular, package managers that deploy Nix for their respective platforms. - + However, Meson and Ninja are a widespread toolset. - + Many open source projects use Meson, from mpv and dosbox-staging to Xorg and GNOME - + According to Repology, Meson is present in 53 package manager's families - -- The transition between between the old and new build systems should be smooth - + Meson is not an obscure project; a careful documentation update should be sufficient +## Complexity and Bootstrap Issues + +A new build system, and any build system for that matter, indirectly brings its own dependencies to the Nix project. + +Ideally, such dependencies should be minimal, both in number and complexity, with extra good points for dependencies already present (e.g the ubiquitous C compiler). + +About this specific point, a non-negligible drawback is: the reference implementation of Meson is written in Python. At least theoretically, it brings the necessity of including a Python 3 interpreter on the _bootstrap route_ of Nix. + +However, some points can be laid out on the opposite side: + +1. By design, the meson reference evaluator depends only on Python, avoiding the use of extra libraries. +2. Also by design, the implementation language is never exposed to the meson DSL. Because of it, the reimplementation of Meson in other programming languages becomes way more facilitated. + 1. Indeed, Muon is an alternative implementation of Meson written in C. +3. As part of this evaluation of this bootstrap route, we should also evaluate the current bootstrap route, in order to have a fair comparison. + +Further, in principle the same criticisms and answers can be laid out for Ninja; however, Ninja is written in C++, a language already used to implement Nix. Therefore the bootstrap route suffers little to no alteration here. + +## Learning the new system + +A somewhat subjective but important and non-negligible issue is the barrier of entrance of this new build system. + +Paraphasing Eelco Dolstra, switching from a known build system to one unknown is not without its problems. + +However, the Meson development team strives to keep the DSL easy to learn and pleasurable to use. It should not be hard to become familiar with the Python-esque syntax of meson, and its functional, stateless approach is certainly something very appreciated by the Nix community as a whole. + +The huge advantages of implementing Meson surpass the small drawbacks of learning it. + +## Source code changes + +Further to the obvious inclusion of meson files (and the removal of the old quasi-autotools ones), there is a reasonable expectation of code refactoring. + +However, such refactorings are completely validated on the long term goals of Nix, in particular the improvements on portability. + +## End users + +The most known end user of Nix is certainly Nixpkgs. However, there are many other Linux distributions that already keep Nix on their repositories (15 families, according to Repology). There is also a reasonable expectation of affecting those package managers' devteams. + +However, most (if not all) of those distributions already have Meson and its companion tool Ninja in their respective package databases (53 families, according to Repology), given that many open source tools use them as build system. + +## Transition between old and new build infrastructure + +The transition between between the old and new build systems should be as smooth and controlled as possible. # Alternatives [alternatives]: #alternatives From 16e203301998460ea89d12167102f560f01d532f Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 1 Sep 2022 01:05:47 -0300 Subject: [PATCH 33/61] Rework alternatives --- rfcs/0132-meson-builds-nix.md | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 19041545d..5f96274e3 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -145,21 +145,29 @@ The transition between between the old and new build systems should be as smooth The alternatives are -- Doing nothing - - It would keep the current code confusing and harder to work with. - -- Other building systems (waf, premake, cmake etc.) - - Their strenghts and weaknesses should be evaluated. - - Tools strongly tied to other programming languages are strongly discouraged - - They complexify the bootstrap route as discussed above. - - Namely, waf is basically a Python library, whereas premake is a Lua library. - - Cmake has many noteworthy advantages: - + Can generates Make- and Ninja-compatible scripts; - + Supports typical high level idiomatic constructions; - - On the other hand, cmake language is arguably more complex. - + Both Meson and Cmake support Microsoft Windows NT and Apple MacOS platforms; - + including project file formats of both MSVC and Xcode. +- Do nothing + + It would keep the current code confusing and harder to work with, as stated on the motivation section. + +- Use CMake + + Indeed, CMake has many noteworthy advantages: + + - Supports typical high level idiomatic constructions. + - Can generate GNU Make- and Ninja-compatible scripts. + - By design, Meson does not have a Make backend. + - Both Meson and CMake support Microsoft Windows NT and Apple MacOS platforms + - As well as MSVC and XCode. + + - On the other hand, CMake DSL cmake language is arguably more complex and cumbersome. + +- Evaluate other building systems (waf, premake, cmake etc.) + + About this, a principle should be observed: + + Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are strongly discouraged. + + E.g. waf is basically a Python library, whereas premake is a Lua library. They can't reasonable be decoupled of their implementation languages. # Unresolved questions [unresolved]: #unresolved-questions From 8dadf6acdf106c9708a724554664ed6589c586f2 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 4 Sep 2022 23:51:22 -0300 Subject: [PATCH 34/61] Some fixups --- rfcs/0132-meson-builds-nix.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 5f96274e3..6fdb6d4f3 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -116,11 +116,9 @@ Further, in principle the same criticisms and answers can be laid out for Ninja; ## Learning the new system -A somewhat subjective but important and non-negligible issue is the barrier of entrance of this new build system. +A somewhat subjective but non-negligible issue is the entry barrier of this new build system. Switching from a known build system to one unknown is not without its problems. -Paraphasing Eelco Dolstra, switching from a known build system to one unknown is not without its problems. - -However, the Meson development team strives to keep the DSL easy to learn and pleasurable to use. It should not be hard to become familiar with the Python-esque syntax of meson, and its functional, stateless approach is certainly something very appreciated by the Nix community as a whole. +However, the Meson development team strives to keep the DSL easy to learn and pleasurable to use. It should not be hard to become familiar with the Python-esque syntax of meson, and its functional, stateless approach is certainly a feature highly appreciated by the Nix community as a whole. The huge advantages of implementing Meson surpass the small drawbacks of learning it. @@ -134,7 +132,7 @@ However, such refactorings are completely validated on the long term goals of Ni The most known end user of Nix is certainly Nixpkgs. However, there are many other Linux distributions that already keep Nix on their repositories (15 families, according to Repology). There is also a reasonable expectation of affecting those package managers' devteams. -However, most (if not all) of those distributions already have Meson and its companion tool Ninja in their respective package databases (53 families, according to Repology), given that many open source tools use them as build system. +However, most (if not all) of those distributions already have Meson and its companion tool Ninja in their respective package databases (53 families, according to Repology), given that many open source projects use them as build system. ## Transition between old and new build infrastructure @@ -161,13 +159,13 @@ The alternatives are - On the other hand, CMake DSL cmake language is arguably more complex and cumbersome. -- Evaluate other building systems (waf, premake, cmake etc.) +- Evaluate other building systems (waf, premake, etc.) About this, a principle should be observed: Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are strongly discouraged. - E.g. waf is basically a Python library, whereas premake is a Lua library. They can't reasonable be decoupled of their implementation languages. + E.g. waf is basically a Python library, whereas premake is a Lua library. They can't be decoupled of their implementation languages. # Unresolved questions [unresolved]: #unresolved-questions From 587d349892fa4bc9649369b5ff1aa4eac09d1e58 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 9 Sep 2022 00:48:08 -0300 Subject: [PATCH 35/61] Include some more examples of build systems --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 6fdb6d4f3..6cfb85b1a 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -159,7 +159,7 @@ The alternatives are - On the other hand, CMake DSL cmake language is arguably more complex and cumbersome. -- Evaluate other building systems (waf, premake, etc.) +- Evaluate other building systems (waf, premake, bazel, xmake etc.) About this, a principle should be observed: From 86bc4bc13afc31ab4ed1ddb02c75ba26ea39bb3b Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 9 Sep 2022 00:48:32 -0300 Subject: [PATCH 36/61] Reorder references --- rfcs/0132-meson-builds-nix.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 6cfb85b1a..d16620c84 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -191,8 +191,9 @@ Questions that deserve further inquiry: - [Muon](https://muon.build/), a C99 alternative implementation - [Ninja](https://ninja-build.org/) official site - [Samurai](https://github.com/michaelforney/samurai), a C99 alternative implementation -- [CMake](https://cmake.org/) - [Meson tutorial](https://mesonbuild.com/Porting-from-autotools.html) comparing autotools and Meson - [NetBSD tutorial](https://wiki.netbsd.org/pkgsrc/how_to_convert_autotools_to_meson/) comparing Meson and autotools +- [CMake](https://cmake.org/) +- [Xmake](https://xmake.io/) - [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) From 9ad087477958bfe242500c15ff3a58a2a85e7c25 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 9 Sep 2022 00:48:50 -0300 Subject: [PATCH 37/61] Reword cmake subsection --- rfcs/0132-meson-builds-nix.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index d16620c84..67f4f970e 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -152,10 +152,10 @@ The alternatives are Indeed, CMake has many noteworthy advantages: - Supports typical high level idiomatic constructions. - - Can generate GNU Make- and Ninja-compatible scripts. - - By design, Meson does not have a Make backend. + - Can generate GMake- and Ninja-compatible scripts. + - By design, Meson does not provide a Make backend. - Both Meson and CMake support Microsoft Windows NT and Apple MacOS platforms - - As well as MSVC and XCode. + - As well as MSVC and XCode programming environments. - On the other hand, CMake DSL cmake language is arguably more complex and cumbersome. From 5e621afdae8f47e600f0c28e2f25c06879773f6a Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Fri, 9 Sep 2022 00:49:51 -0300 Subject: [PATCH 38/61] Move paragraphs about Meson and Ninja to detailed design section --- rfcs/0132-meson-builds-nix.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 67f4f970e..910a521da 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -36,13 +36,6 @@ We expect to accomplish, among other goals, # Detailed design [design]: #detailed-design -A carefully crafted set of Meson files should be included in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files, documentation etc.) - -This novel building infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit in a different user interface. - -# Examples and Interactions -[examples-and-interactions]: #examples-and-interactions - Before the examples, some informative paragraphs: ## What is Meson? @@ -69,13 +62,20 @@ Among its features, we highlight: ## What is Ninja? -Ninja is a small, speed-focused, build tool that fills a similar role of Unix `make` or GNU `gmake`. +Ninja is a small, speed-focused build tool that fills a similar role of Unix `make` or its GNU counterpart `gmake`. -Its main feature is a low-level approach to build description. Where other build systems act like high level languages, Ninja acts like an assembly. +Its main feature is a low-level approach to build description. Ninja is bare-bones and constrained by design, having only the necessary semantics to describe build dependency graphs, relegating decision-making to superior tools like Meson or CMake. Where other build systems act like high level languages, Ninja acts like an assembly. -Ninja is bare-bones and constrained by design, having only the necessary semantics to describe build dependency graphs, relegating decision-making to superior tools like Meson or CMake. +Albeit Ninja DSL is human-readable, it is not convenient to be manually written by human beings. As said before, Ninja is commonly used in tandem with other, higher-level build system in a two-pass fashion. In our present use case, the Meson interpreter converts Meson files to Ninja files that will be consumed by Ninja tool to effectively execute the building/deployment commands. -Ninja DSL is human-readable, however it is not convenient to be manually written by human beings. As said before, Ninja is commonly used in tandem with other, higher-level build system. +## Design + +A carefully crafted set of Meson files should be included in order to describe how to deploy the Nix repository, generating all the expected artifacts (command line tools, libraries, configuration files, documentation etc.) + +This novel building infrastructure should be able to provide at least feature parity with the current quasi-autotools implementation, albeit in a different user interface. + +# Examples and Interactions +[examples-and-interactions]: #examples-and-interactions ## Example interaction From 3de13727f15766b47579b4a8b75540070fa4a67d Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 10:18:04 -0300 Subject: [PATCH 39/61] Remove unneeded paragraph --- rfcs/0132-meson-builds-nix.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 910a521da..a3ef9eed8 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -36,8 +36,6 @@ We expect to accomplish, among other goals, # Detailed design [design]: #detailed-design -Before the examples, some informative paragraphs: - ## What is Meson? Meson is an open source, multiplatform build system crafted to be fast, correct and user-friendly. From c5a9e488f3fe6cd336e02810ec0b525f542e6e05 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 11:10:06 -0300 Subject: [PATCH 40/61] Include Bazel as alternative Because maybe someone out there believes it is good and viable to cite it ... --- rfcs/0132-meson-builds-nix.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index a3ef9eed8..6377f7dff 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -165,6 +165,23 @@ The alternatives are E.g. waf is basically a Python library, whereas premake is a Lua library. They can't be decoupled of their implementation languages. +- Use Bazel + + For the sake of completeness, there is Bazel. + + Advantages: + + - Fast, scalable, multi-language and extensible. + - Backed by Google(TM). + + Disadvantages: + + - [Not fully open source yet](https://bazel.build/about/faq#are_you_done_open_sourcing_bazel) + - Written in Java + - Java bootstrap is fairly complex and completely dependent on _open-source abandonware_, as demonstrated by [Bootstrappable](https://bootstrappable.org/projects/java.html) project. + - At the time there is no alternative implementation of Bazel in another language. + - Backed by Google(TM). + # Unresolved questions [unresolved]: #unresolved-questions From 3f1182cea23ffcc718be1ab447632142a715acd9 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 11:13:28 -0300 Subject: [PATCH 41/61] Reword paragraph --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 6377f7dff..7e0ac4676 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -163,7 +163,7 @@ The alternatives are Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are strongly discouraged. - E.g. waf is basically a Python library, whereas premake is a Lua library. They can't be decoupled of their implementation languages. + E.g. waf is basically a Python library, whereas premake and xmake are Lua libraries. They can't be decoupled of their implementation languages. - Use Bazel From e3614074e0bc18a88b748bbf7333bbd26a87547f Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 11:13:56 -0300 Subject: [PATCH 42/61] Punctuation --- rfcs/0132-meson-builds-nix.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 7e0ac4676..073a738fd 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -193,11 +193,11 @@ Questions that deserve further inquiry: # Future work [future]: #future-work -- Update project's continuous integration and related stuff +- Update project's continuous integration and related stuff; - Deprecate and remove the current quasi-autotools scripts - - Preferably, the removal should be allocated to a minor version release + - Preferably, the removal should be allocated to a minor version release. - Evaluate the positive and negative impacts of such a change - - Specially the most subjective ones + - Specially the most subjective ones. # References [references]: #references From a228c6f8ac6cb30f5157d4ce88993f110c5b525e Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 11:15:38 -0300 Subject: [PATCH 43/61] More references --- rfcs/0132-meson-builds-nix.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 073a738fd..416cb017d 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -208,7 +208,9 @@ Questions that deserve further inquiry: - [Samurai](https://github.com/michaelforney/samurai), a C99 alternative implementation - [Meson tutorial](https://mesonbuild.com/Porting-from-autotools.html) comparing autotools and Meson - [NetBSD tutorial](https://wiki.netbsd.org/pkgsrc/how_to_convert_autotools_to_meson/) comparing Meson and autotools +- [Boostrappable Builds](https://bootstrappable.org/) - [CMake](https://cmake.org/) - [Xmake](https://xmake.io/) +- [Bazel](https://bazel.build) - [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) From aef082744f3b3e1240ca63f280992beb0b4c755f Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sat, 10 Sep 2022 23:33:13 -0300 Subject: [PATCH 44/61] Reword --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 416cb017d..44c2d2786 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -47,9 +47,9 @@ According to its main site, Among its features, we highlight: - user-friendly non-Turing complete DSL - - very readable Python-esque syntax and functional, stateless semantics + - Python-esque syntax and functional, stateless semantics - multiplatform support - - among operating systems: Linux, Apple MacOS, Microsoft Windows NT + - among operating systems: Linux, *BSD, Apple MacOS, Microsoft Windows NT - among programming environments: GCC, Clang, Xcode, Visual Studio etc. - among programming languages: C, C++, D, Fortran, Java, Rust etc. - supports command customization From 212bf6392849d5db8a1c212921a6a93a4e774697 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 11 Sep 2022 00:38:37 -0300 Subject: [PATCH 45/61] Typo --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 44c2d2786..b78ca5673 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -84,7 +84,7 @@ Here is a table comparing some expected interactions: | Configure | `./configure --enable-gc=true` | `meson setup build_dir -Dgc=enabled` | `meson setup build_dir -Dgc=enabled` | | Build | `make` | `ninja -C build_dir build` | `meson -C build_dir compile` | | Install | `make install` | `ninja -C build_dir install` | `meson -C build_dir install` | -| Uninstall | `make uninstall` | `ninja -C build_dir unistall` | `meson -C build_dir unistall` | +| Uninstall | `make uninstall` | `ninja -C build_dir uninstall` | `meson -C build_dir uninstall` | ## Implementation From 4df494406978a858ab9f7d7b98d76d711a1296ed Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 11 Sep 2022 00:38:52 -0300 Subject: [PATCH 46/61] Reword --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index b78ca5673..426b3a866 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -106,11 +106,11 @@ About this specific point, a non-negligible drawback is: the reference implement However, some points can be laid out on the opposite side: 1. By design, the meson reference evaluator depends only on Python, avoiding the use of extra libraries. -2. Also by design, the implementation language is never exposed to the meson DSL. Because of it, the reimplementation of Meson in other programming languages becomes way more facilitated. +2. Also by design, the implementation language is never exposed to the meson DSL. It allows the possibility of implementating alternative evaluators in other programming languages. 1. Indeed, Muon is an alternative implementation of Meson written in C. 3. As part of this evaluation of this bootstrap route, we should also evaluate the current bootstrap route, in order to have a fair comparison. -Further, in principle the same criticisms and answers can be laid out for Ninja; however, Ninja is written in C++, a language already used to implement Nix. Therefore the bootstrap route suffers little to no alteration here. +In principle, the same criticisms and answers can be laid out for Ninja too; however, Ninja is written in C++, a language already used to implement Nix. Therefore the bootstrap route suffers little to no alteration here. ## Learning the new system From 0a41323ceacd8d99b44c11e76311e8a1d38e28c0 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 11 Sep 2022 12:30:59 -0300 Subject: [PATCH 47/61] A bit more about Bazel For the sake of completeness. --- rfcs/0132-meson-builds-nix.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 426b3a866..942ed5fd1 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -167,11 +167,12 @@ The alternatives are - Use Bazel - For the sake of completeness, there is Bazel. + For the sake of completeness, there is Bazel, a Google(TM)-backed build system that sells itself as "fast, scalable, multi-language and extensible". Advantages: - Fast, scalable, multi-language and extensible. + - Your mileage may vary. - Backed by Google(TM). Disadvantages: From e071944ba7420367e1d7c4fb90a0516549ba5b50 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 5 Oct 2022 21:40:33 -0300 Subject: [PATCH 48/61] add feature: out-of-source build --- rfcs/0132-meson-builds-nix.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 942ed5fd1..32467f9da 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -55,6 +55,8 @@ Among its features, we highlight: - supports command customization - cross compilation - many useful modules included (pkg-config, filesystem inspection, internationalization etc.) +- out-of-source build support + - indeed, meson does not support inside-source build - Comprehensive documentation - including tutorials, reference manuals and real world projects using it From d8904e94ea7262dba21170a28bef2da8bbcca6a1 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 10 Nov 2022 21:59:07 -0300 Subject: [PATCH 49/61] Typos, typos and more typos --- rfcs/0132-meson-builds-nix.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 32467f9da..7c6662fc0 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -86,7 +86,7 @@ Here is a table comparing some expected interactions: | Configure | `./configure --enable-gc=true` | `meson setup build_dir -Dgc=enabled` | `meson setup build_dir -Dgc=enabled` | | Build | `make` | `ninja -C build_dir build` | `meson -C build_dir compile` | | Install | `make install` | `ninja -C build_dir install` | `meson -C build_dir install` | -| Uninstall | `make uninstall` | `ninja -C build_dir uninstall` | `meson -C build_dir uninstall` | +| Uninstall | `make uninstall` | `ninja -C build_dir uninstall` | `meson -C build_dir uninstall` | ## Implementation @@ -108,11 +108,11 @@ About this specific point, a non-negligible drawback is: the reference implement However, some points can be laid out on the opposite side: 1. By design, the meson reference evaluator depends only on Python, avoiding the use of extra libraries. -2. Also by design, the implementation language is never exposed to the meson DSL. It allows the possibility of implementating alternative evaluators in other programming languages. +2. Also by design, the implementation language is never exposed to the meson DSL. It allows the possibility of implementing alternative evaluators in other programming languages. 1. Indeed, Muon is an alternative implementation of Meson written in C. 3. As part of this evaluation of this bootstrap route, we should also evaluate the current bootstrap route, in order to have a fair comparison. -In principle, the same criticisms and answers can be laid out for Ninja too; however, Ninja is written in C++, a language already used to implement Nix. Therefore the bootstrap route suffers little to no alteration here. +In principle, the same criticisms and answers can be laid out for Ninja too; however, Ninja is written in C++, a language already used to implement Nix. Therefore, the bootstrap route suffers little to no alteration here. ## Learning the new system @@ -136,7 +136,7 @@ However, most (if not all) of those distributions already have Meson and its com ## Transition between old and new build infrastructure -The transition between between the old and new build systems should be as smooth and controlled as possible. +The transition between old and new build systems should be as smooth and controlled as possible. # Alternatives [alternatives]: #alternatives @@ -157,13 +157,13 @@ The alternatives are - Both Meson and CMake support Microsoft Windows NT and Apple MacOS platforms - As well as MSVC and XCode programming environments. - - On the other hand, CMake DSL cmake language is arguably more complex and cumbersome. + However, CMake DSL is arguably more complex and cumbersome, whereas Meson is more polished. - Evaluate other building systems (waf, premake, bazel, xmake etc.) About this, a principle should be observed: - Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are strongly discouraged. + Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are severely discouraged. E.g. waf is basically a Python library, whereas premake and xmake are Lua libraries. They can't be decoupled of their implementation languages. From 680e6b8186b004e3747680e9e8c4110386face74 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 10 Nov 2022 21:59:31 -0300 Subject: [PATCH 50/61] Link to the now free-as-in-beer book from the creator of Meson --- rfcs/0132-meson-builds-nix.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 7c6662fc0..4bf783203 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -216,4 +216,6 @@ Questions that deserve further inquiry: - [Xmake](https://xmake.io/) - [Bazel](https://bazel.build) +- [Free-to-read book from the creator of Meson](https://nibblestew.blogspot.com/2021/12/this-year-receive-gift-of-free-meson.html) + - [Current work in progress from @p01arst0rm](https://github.com/NixOS/nix/pull/3160) From 0430b71affaa0e07ab330da55abc993dadd97d00 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Thu, 10 Nov 2022 22:02:38 -0300 Subject: [PATCH 51/61] Another typo --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 4bf783203..313861eed 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -101,7 +101,7 @@ Below we will list some possible drawbacks and balances to them. A new build system, and any build system for that matter, indirectly brings its own dependencies to the Nix project. -Ideally, such dependencies should be minimal, both in number and complexity, with extra good points for dependencies already present (e.g the ubiquitous C compiler). +Ideally, such dependencies should be minimal, both in number and complexity, with extra good points for dependencies already present (e.g. the ubiquitous C compiler). About this specific point, a non-negligible drawback is: the reference implementation of Meson is written in Python. At least theoretically, it brings the necessity of including a Python 3 interpreter on the _bootstrap route_ of Nix. From 61ad7c433faecae63f8b790182e594df851027ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 17 Nov 2022 07:48:42 +0100 Subject: [PATCH 52/61] Add shepherds --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 313861eed..09bb0fa50 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -3,8 +3,8 @@ feature: meson_builds_nix start-date: 2022-08-25 author: Anderson Torres co-authors: @p01arst0rm -shepherd-team: -shepherd-leader: +shepherd-team: @Ericson2314 @edolstra @thufschmitt +shepherd-leader: @Ericson2314 related-issues: --- From afca5817e62ea53bc25876cc934b603025ab89f9 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Fri, 11 Aug 2023 22:18:08 -0300 Subject: [PATCH 53/61] add cross-compilation support to the criteria of evaluation of alternatives --- rfcs/0132-meson-builds-nix.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 09bb0fa50..d0eab41f4 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -167,6 +167,8 @@ The alternatives are E.g. waf is basically a Python library, whereas premake and xmake are Lua libraries. They can't be decoupled of their implementation languages. + Another indispensable attribute to be considered is cross-compilation support. + - Use Bazel For the sake of completeness, there is Bazel, a Google(TM)-backed build system that sells itself as "fast, scalable, multi-language and extensible". From 9bb63e0bc2846f97379b408750f0b717b4be5467 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 12:38:35 -0300 Subject: [PATCH 54/61] Typo --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index d0eab41f4..1111f89a3 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -27,7 +27,7 @@ In light of this state of things, we propose a novel alternative to the current We expect to accomplish, among other goals, - better code structuring and documentation; -- improved support across platforms, especially outside NixOS and Linux +- improved support across platforms, especially outside NixOS and Linux; - shorter build times; - improved testing; - more reasonable dependency management; From e6b4e0520f3bbf01e2ecd0e52a1a1981b18e066a Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 12:38:55 -0300 Subject: [PATCH 55/61] Reword examples --- rfcs/0132-meson-builds-nix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 1111f89a3..ae7efac73 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -159,13 +159,13 @@ The alternatives are However, CMake DSL is arguably more complex and cumbersome, whereas Meson is more polished. -- Evaluate other building systems (waf, premake, bazel, xmake etc.) +- Evaluate other building systems (waf, scons, premake, xmake etc.) About this, a principle should be observed: Per the bootstrap route issue discussed above, build tools strongly tied to other programming languages are severely discouraged. - E.g. waf is basically a Python library, whereas premake and xmake are Lua libraries. They can't be decoupled of their implementation languages. + E.g. waf and scons are Python libraries in essence, whereas premake and xmake are Lua libraries. They can't be decoupled of their implementation languages. Another indispensable attribute to be considered is cross-compilation support. From 719562c914bff27fe9933419ddddcc8e49424cbb Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 12:39:20 -0300 Subject: [PATCH 56/61] Add some more advantages for Bazel --- rfcs/0132-meson-builds-nix.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index ae7efac73..accb88961 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -177,7 +177,8 @@ The alternatives are - Fast, scalable, multi-language and extensible. - Your mileage may vary. - - Backed by Google(TM). + - Trusted by industry leaders. + - Backed by Google. Disadvantages: From e4715c48a88400935de50a9724c7a290bbcd8a31 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 12:39:46 -0300 Subject: [PATCH 57/61] Reword and add more disadvantages for Bazel --- rfcs/0132-meson-builds-nix.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index accb88961..a9869c553 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -182,11 +182,12 @@ The alternatives are Disadvantages: + - [Too tied to Google internals](https://bazel.build/about/faq#why_isn%E2%80%99t_all_development_done_in_the_open) - [Not fully open source yet](https://bazel.build/about/faq#are_you_done_open_sourcing_bazel) - Written in Java - - Java bootstrap is fairly complex and completely dependent on _open-source abandonware_, as demonstrated by [Bootstrappable](https://bootstrappable.org/projects/java.html) project. - - At the time there is no alternative implementation of Bazel in another language. - - Backed by Google(TM). + - Java bootstrap is fairly complex, currently relying on _open-source abandonware_, as demonstrated by [Bootstrappable](https://bootstrappable.org/projects/java.html) project. + - At the current time there is no alternative implementation of Bazel in another programming language. + - Backed by Google. # Unresolved questions [unresolved]: #unresolved-questions From f37cedd41460b438750c0f12de788d37a4bcd771 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 12:40:09 -0300 Subject: [PATCH 58/61] More references --- rfcs/0132-meson-builds-nix.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index a9869c553..e00ec48d8 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -209,14 +209,17 @@ Questions that deserve further inquiry: # References [references]: #references -- [Meson](https://meson.build/) official site +- [Meson](https://meson.build/) - [Muon](https://muon.build/), a C99 alternative implementation -- [Ninja](https://ninja-build.org/) official site +- [Ninja](https://ninja-build.org/) - [Samurai](https://github.com/michaelforney/samurai), a C99 alternative implementation - [Meson tutorial](https://mesonbuild.com/Porting-from-autotools.html) comparing autotools and Meson - [NetBSD tutorial](https://wiki.netbsd.org/pkgsrc/how_to_convert_autotools_to_meson/) comparing Meson and autotools - [Boostrappable Builds](https://bootstrappable.org/) - [CMake](https://cmake.org/) +- [Premake](https://premake.github.io/) +- [Waf](https://waf.io/) +- [SCons](https://scons.org/) - [Xmake](https://xmake.io/) - [Bazel](https://bazel.build) From 5b0a7348b384c4f35293c63c00454465fc038cbf Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 13:00:04 -0300 Subject: [PATCH 59/61] Reword Google company name --- rfcs/0132-meson-builds-nix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index e00ec48d8..fc701603a 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -171,7 +171,7 @@ The alternatives are - Use Bazel - For the sake of completeness, there is Bazel, a Google(TM)-backed build system that sells itself as "fast, scalable, multi-language and extensible". + For the sake of completeness, there is Bazel, a Google LLC-backed build system that sells itself as "fast, scalable, multi-language and extensible". Advantages: From 56c86fa98ec75521e953fe93ce497dfc8a925b07 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 25 Feb 2024 13:21:03 -0300 Subject: [PATCH 60/61] Add Prior Art section --- rfcs/0132-meson-builds-nix.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index fc701603a..579d22344 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -189,6 +189,17 @@ The alternatives are - At the current time there is no alternative implementation of Bazel in another programming language. - Backed by Google. +# Prior Art + +For the sake of completeness, and pushed by the advent of [RFC Process updates](https://github.com/NixOS/rfcs/pull/150), we are including here a list of projects that are in different stages of transition to Meson: + +- [GNOME](https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting) +- [X.Org Server](https://gitlab.freedesktop.org/xorg/xserver) + - [XTS](https://gitlab.freedesktop.org/xorg/test/xts), the X.Org Test Suite +- [MPV](https://mpv.io), the commandline video player +- [GIMP](https://gitlab.gnome.org/GNOME/gimp), the GNU Image Manipulation Program +- [Mesa](https://mesa3d.org/), the open source implementations of many low-level, graphics-related libraries + # Unresolved questions [unresolved]: #unresolved-questions From b03e5b6a9f7e93be2e0c3b45af1a48b0ae12b3cf Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Wed, 28 Feb 2024 19:43:48 -0300 Subject: [PATCH 61/61] Rewords and comparisons --- rfcs/0132-meson-builds-nix.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rfcs/0132-meson-builds-nix.md b/rfcs/0132-meson-builds-nix.md index 579d22344..c7eac0c12 100644 --- a/rfcs/0132-meson-builds-nix.md +++ b/rfcs/0132-meson-builds-nix.md @@ -110,7 +110,7 @@ However, some points can be laid out on the opposite side: 1. By design, the meson reference evaluator depends only on Python, avoiding the use of extra libraries. 2. Also by design, the implementation language is never exposed to the meson DSL. It allows the possibility of implementing alternative evaluators in other programming languages. 1. Indeed, Muon is an alternative implementation of Meson written in C. -3. As part of this evaluation of this bootstrap route, we should also evaluate the current bootstrap route, in order to have a fair comparison. +3. In order to evaluate the impact of this new bootstrap route, we should also evaluate the current bootstrap route, in order to have a fair comparison. In principle, the same criticisms and answers can be laid out for Ninja too; however, Ninja is written in C++, a language already used to implement Nix. Therefore, the bootstrap route suffers little to no alteration here. @@ -122,6 +122,8 @@ However, the Meson development team strives to keep the DSL easy to learn and pl The huge advantages of implementing Meson surpass the small drawbacks of learning it. +Further, the current barrier of entry should be evaluated in order to have a fair comparison. + ## Source code changes Further to the obvious inclusion of meson files (and the removal of the old quasi-autotools ones), there is a reasonable expectation of code refactoring.