-
-
Notifications
You must be signed in to change notification settings - Fork 160
[RFC 0132] Meson Builds Nix #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
9714f41
85759af
003393e
3e0be88
d4497fd
18c732d
a843fb1
0bf382d
6c3f5d2
bd4bfe9
e1a0620
0060937
265020c
b7b859b
3eea629
8650a36
ab2dec1
6980048
b58c8b6
17069b6
9821ad2
ab42c2f
3111e49
9d89692
dca9276
38f3c44
714457b
894946b
72dec20
6d8f6bd
94eb5c7
934555d
16e2033
8dadf6a
587d349
86bc4bc
9ad0874
5e621af
3de1372
c5a9e48
3f1182c
e361407
a228c6f
aef0827
212bf63
4df4944
0a41323
e071944
d8904e9
680e6b8
0430b71
61ad7c4
afca581
9bb63e0
e6b4e05
719562c
e4715c4
f37cedd
5b0a734
56c86fa
b03e5b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
feature: meson_builds_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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This build system became clunky and plastered, and consequently hard to understand, modify, improve and port to other systems besides Linux. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Examples and Interactions | ||
[examples-and-interactions]: #examples-and-interactions | ||
|
||
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`) | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Usually, commandline options assume the format `-Dname=value`. This small change in user interface when compared to the typical `--name=value` is mostly harmless. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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, Meson is well documented, and its language is easy to grasp, specially for those familiarized with Python. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ Namely, Muon and Samurai are implementations of Meson and Ninja that require only a C compiler and a set of POSIX standard tools. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would definitely keep this drawback in mind and explore alternatives that don't expand the bootstrap closure. Maybe you could also mention what the current bootstrap closure is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @asymmetric please read the prior PR to read discussions; meson does not increase bootstrap dependencies, it dramatically decreases them. available tools are provided that only require a working c compiler; c --> muon --> samurai --> nix. the benefit & end goal of this is removing gnu userland tools as a requirement of building, dramatically decreasing the amount of tools needed for bootstrapping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You mean NixOS/nix#3160?
Didn't you say in the RFC that Meson is in Python? What I wanted to say with my comment is to emphasize the idea that we shouldn't increase the bootstrap closure, and so I approve that you mentioned it and provided alternatives that don't increase it. But AFAIU Python is not part of the current Nix bootstrap closure, so if we use straight Meson, rather than muon and/or Ninja, we would indeed increase it. Is that correct? If that's the case, why wouldn't we choose muon directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Who said that muon isn't "directly" chosen? Maybe the confusion here is that the RFC is to use "Meson" the buildsystem description DSL, but not specifically to bootstrap Nix with "Meson" the reference implementation of "Meson". What's the goal of this review comment? To rename this RFC to
??? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was indeed the thing that confused me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we need a line in the RFC that says "meson the dsl language != meson.py the tool" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As far as I know, M4 (the somewhat obscure macro language) and Bash, and whatever autoconf brings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some required build programs include
|
||
|
||
- 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. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ Many open source projects use it, from mpv and dosbox-staging to Xorg and GNOME | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ 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 | ||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the sake of completeness there should probably also be an item here about bazel, buck & friends There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it is well summarized on the examples of waf and premake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly. The argument against them is that they are a language-specific DSL, but that's not the case of Bazel or Buck. They do have a bootstrap problem ofc, but it's a different one (single implem, lots of deps) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A different one, and considerably worse than Meson. Cmake would be way better than them. I do not believe they deserve more than a mention. If anyone is interested on picking Buck or Bazel or Imake, kudos to them! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well now, let's be fair, there's definitely more than one implementation of Bazel. The original design of it is Google's internal closed-source thing designed specifically to meet Google's distributed cloud computing needs, after all. ;) Bazel itself is just an open-source attempt to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My list of complaints:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep sounds about right 🤣 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe too late. Has Zig been considered? It claims being an alternative:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the entire point of meson is it offers the ability to compile all projects regardless of source language, build environment, linker, or compiler configurations. it offers flexibility and simplicity which allows easy maintainability into the future. the zig buildsystem is designed for c/c++ and is not nearly as well documented or flexible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also Zig is oriented to Zig itself, while Meson is general-purpose. |
||
|
||
The alternatives are | ||
|
||
- Doing nothing | ||
|
||
It would keep the current code confusing and harder to work with. | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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 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; | ||
- On the other hand, the language is arguably more complex. | ||
|
||
# Unresolved questions | ||
[unresolved]: #unresolved-questions | ||
|
||
Questions that deserve further inquiry: | ||
|
||
- Unexpected interactions with Meson and Ninja | ||
- Specially, vendoring and reproducibility. | ||
|
||
# Future work | ||
[future]: #future-work | ||
|
||
- Deprecate the current build scripts | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Backport the new build system to Nix 2.3 | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- It was the latest release without Flakes support; it is important to bring such a deep modification to it. | ||
|
||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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/) | ||
AndersonTorres marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.