-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Reorganize this repo #7876
Comments
Overall this sounds reasonable to me except the navigability issues introduced by encoding the header install targets as paths:
Alternative:
...that is, make all Nix components top-level, and set the complete install targets (e.g. If there is generally only one build target per component, one may as well leave out the nested items within |
@fricklerhandwerk The problem with that is that I would love to go add an |
I see. Now also convinced this is the least bad option. |
Triaged in the Nix team meeting:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-02-24-nix-team-meeting-minutes-35/25757/1 |
Here's another repo-wide change we've been postponing.
Do we have more such changes to consider? I've edited the proposal to add a better location for: |
Discussed in the Nix team meeting:
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-03-27-nix-team-meeting-minutes-44/26759/1 |
Discussed in Nix team meeting:
|
I wish we could stop making excuses and workarounds, and just do the damn thing. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-04-14-nix-team-meeting-minutes-48/27358/1 |
Revisited in the Nix maintainer meeting: @roberth will make a PR to update the source filter in @Ericson2314 argues many files can be moved piecemeal, leveraging Git's support for renames. A careful attempt is encouraged. Also discussed #7847 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-07-21-nix-team-meeting-minutes-73/30768/1 |
Related: #2503 |
Desiderata
Here are a number of goals we would like to have, where the current organization falls shorts
Low latency Nix builds
For CI and local development a like, it is nice if repeated Nix builds avoid duplicated work. This means having fine-grained derivations with well-scoped inputs and outputs.
Ultimately, we would need Recursive Nix or RFC 92 to really nail this, but in the meantime we can at least focus on some lower hanging fruit: filtering sources just to the files relevant for the task at hand.
One way to do this is with
builtins.filterSource
and friends, but keeping such predicates up to date is a bit frustrating. A more maintainable way is to leverage the repo directory structure so that separate build tasks correspond to separate directories.This also makes it easy to understand the project structure at a glance.
Cross-project incremental development.
For proper builds, dependencies should always be built in separate derivations, for the reason of low latency defined above. But for the foreseeable future, developers wanted the best developer experience will still be doing impure builds in a development shell environment.
If the developer is just working on one project, giving that shell environment the same dependencies as the regular build is fine, but quite often the developer wants to work on multiple projects at once. Then, having the dependencies be pre-built in the development shell is very frustrating for two reasons:
This is an issue both within this repo and between repos:
The relationship to repo organization is that in order to maintainably support both the development and release builds workflows, they must be as similar as possible. The means, the location of source files in the repo need to roughly correspond to the location of installed files in dependencies' outputs.
-I /nix/store/...
flags) or in tree (with `-I this/repo/...) flags.-include config.h
should be done, because downstream projects should need to include headers not replicate such CLI flags.The status quo
Today, we have a directory structure like this:
Here are the problems with this:
Even though we have separate top-level projects, Nix itself is splatted on the top level
The header are directly in the root of
-I
search path entries, but they will be installed in$dev/include/nix/
-- a newnix
subdir! We have a non-standard pkg-config hacking around this, but this is not a good solution.The flake.nix is too big and hard to read.
The test headers are mix in with the library headers, and we have to manually be careful not to install them.
A plan
I propose we instead adopt something like this:
Note these changes:
Each project (Nix itself, Perl bindings, Python bindings) is confined to its own subdir, clarifying the project structure and avoiding input leakage for lower latency builds
Each project gets its own
default.nix
, which will becallPackage
d in the top-levelflake.nix
. This makes clear what dependencies of each "unit" are, and those files could someday be mirrored one-for-one in Nixpkgs easing maintenance. The top-levelflake.nix
is much shorter and clearer.The extra
src
dir is removed, we can go straight to talking about each librarysrc
dir per libraryThe public headers are put in their own directory, and given the same prefix they would be installed under.
nix/
vsnix/expr
, for example, is an orthogonal choice we can decide on separately.src
directory, indicating they are not installed.The test libraries are completely separated out
The integration tests (NixOS VM tests) are separated out, so that changes to them don't need to cause a
nix
rebuildBonus: Meson support
One of Meson's best features is Subprojects. This is designed to agglomerate a bunch of separate packages into one single incremental build with minimal hassle. Dependencies (or rather virtual things to depend-upon) can be declared in individual meson projects, and then when the projects are combined together needed-dependencies can be satisfied with these instead of externally (e.g. with `pkg-config).
If we switched to using Meson across the board (Nix itself, Python bindings, Perl bindings, Hydra), we would have a
meson.build
in each sub-directory, and then a top-levelmeson.build
in the root of this repo adding all the others as sub-projects. The top-levelmeson.build
would just be used for development.If a developer wants to develop Nix and hydra at the same time, they would unpack/symlink hydra to a new subdir along-side the others and then add it with
subproject(...)
in the top-levelmeson.build
. Then incremental builds of Nix and Hydra together would just work --- no further manual steps needed!Drawbacks
A lot of files will move around
File paths are longer and more redundant
src
directory helps a bit, but we still have things likenix/libstore/include/nix/store/foo-bar.hh
. But it doesn't seem that much can be done out of this without failing to meet our desiderata.Files are further apart.
foo.cc
is no longer right next tofoo.hh
The text was updated successfully, but these errors were encountered: