-
-
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
Replace 'configurationsXyz' and 'modulesXyz' with 'configurations.xyz' and 'modules.xyz' #6257
Comments
It's not clear to me what the advantage of this proposal is. What's the usefulness of having a semantics-free |
This allows the community to define its own module groups. Here are a few examples:
|
Oh, and just to be clear
It is not semantics-free. Current design is |
But there may be other kinds of modules, nixos ones are not the only ones. |
Yeah, which is why I am suggesting to make flakes schema more flexible, so it could accommodate nix-darwin/home-manager/etc modules as well. |
Overall a good idea 👍 I think this would cleanup flake's relationship with configuration systems. Largest question for me is whether Also to be clear it would be Although, I could see |
The answer is simple: Nope. One of the checks is the derivation path itself, there are a few options:
As for the last part - I did not quite get it. Assuming modules are identical I would expect something along the lines of this: {self}:{
modules.nixos.abc = import ./xyz.nix;
modules.darwin = self.modules.nixos;
# As of right now common approach is: https://github.com/gytis-ivaskevicius/flake-utils-plus/pull/111/files
nixosModules = {abc = import ./xyz.nix;};
darwinModules = self.nixosModules; # unknown properly
} |
I posted a copy of my flake (#6723) using nixosConfigurations attribute to contain home-manager and darwin configurations - this flake does not have errors when running |
With a solution like https://github.com/hercules-ci/flake-parts you could remove the hardcoded schema checking in Nix and let the nixpkgs repo define I'm still surprised how much Nix is hardcoding ecosystem stuff that it has no business knowing about. It's as if we've forgotten that the nix implementation can't be pinned by expressions or lock files. Good thing flakes are experimental so this stuff can still be removed. |
I think getting this change in before the stable release of flakes is important. Examples for these projects:
And of course there are the well known:
In my opinion, the most reasonable schema would to be a 3 levels nested attrset, like: @gytis-ivaskevicius Reading the OP it's not quite clear if you are suggesting a 2-levels or 3-levels nested attrset. Maybe you could edit the OP to make that more clear. |
Updated |
Earlier, we've decided not to check the NixOS modules with flakes anymore, because there was very little practical utility in doing so (as the things that might end up in the attribute tend to be indistinguishable from valid modules), along with it being somewhat flawed architecturally. To get more use out of this, I think we need to first establish in the module system which things are definitely not modules. There's probably something to be gained there, by making it check against certain things that are known to be highly unlikely to be modules. Ultimately it is (educated) guesswork, so hardcoding that guesswork in Nix doesn't seem like the right thing to do. Together with the architectural argument, I think it'd be better to defer the checking to frameworks (flake.parts, etc), perhaps with a new interface for eval checks that frameworks can hook into. Nix's responsibility is then reduced to accepting and ignoring a Similar logic would apply to the Superficially this might seem like a lazy-but-overengineered solution, but it is the one that allows community expressions to evolve in a forward compatible manner, noting the Nix's logic can not be pinned, unlike community expressions. |
An example of evolution on the Nixpkgs side is Examples of checking behavior that may evolve
|
Currently the module system in I wonder if we could rename it to Nix Module and move the document to Nixpkgs manual. |
@Atry I think your message is quite orthogonal to this issue, I'd suggest opening a new issue for that instead |
I agree documenting might belong to another issue, but it is still related to this issue, because this issue is about renaming |
I would argue if different "config system"s really exist. Most NixOS modules can be used as For example, you can create a flake-parts project, then configure some Jupyter kernels using After all, NixOS modules are just config file generators. We don't have to run the generated files in |
@Atry, while this may be possible today, you should expect this to break, unless adequate testing is added in the nixpkgs repo to ensure that this use case keeps working. This essentially what RFC 78 is about. See my comment for an example of how the module system can be leveraged to avoid the unnecessary NixOS-specific complexity in your use case (although it leaves a lot to the imagination). |
In this PR, the concept of "config system" or "module system application" is formalized as flake."${class}Configurations"
flake."${class}Modules" This is also mentioned in the module system documentation (but the online manual hasn't updated yet). The suggested attribute path convention would be: flake.configurations.${class}
flake.modules.${class} Furthermore the PR has added |
Neither naming scheme has a particularly good spot for generic modules. |
A helper for module system applications. Naming compatible with NixOS/nix#6257 To be supported by nix flake check in NixOS/nix#8332 Concept is in the spirit of a proposed module based solution to [RFC 0078 System-agnostic configuration file generators](NixOS/rfcs#78).
Let me reply to @blaggacao here
DefinitionsIf it's portable, then "system" is a parameter, which means it is not a configuration in the sense of the module system. It's unfortunate that user expectations and the bottom-up definition lead to an overloading of the term "configuration", and they meet in the flake schema. Simple schemaThe practical problem with configuration families in relation to this issue's goal is that they have a different schema compared to a normal attribute set of configurations. If we were to put both in the It might still be possible to traverse such a heterogeneous attribute set without significant cost based on So in line with the goal of this issue, actually simplifying the schema, I'd rather keep Modules instead?As a final note, a different interpretation is that if a Home Manager configuration is truly portable, then "system" is not part of the configuration. Arguably the derivations it builds need to be configured, so there's a hole in that configuration. Such a hole, whether it's a function parameter or an option is representable using a module rather than a configuration. This would look like: modules.home-manager.foo = { ... }: {
# ...
} While I like the simplicity of this, it has some issues
These issues seem sufficient to warrant a new flake output attribute containing this info. Brainstorming: Possible attrs:
Actually |
Without going too far, still:
I could see definition of "configuration levels" helpful as a community-provided shared mental model. This model captures different aspects (or "levels") of exogenous input, such as system, ip-addresses, identity, etc. With the shared knowledge and understanding of such levels, we can make use of the two fundamental strategies of specialization in configuration management: functions (if there's a "hole") and overlays (if its a "variant"). The magic of (Nix') fix points is a really powerful primitive to build such an incremental/layered mental model while at the same time avoiding impracticalities (such as rendering the change of trunk values like A shared mental model ("framework"), even without implementation, could help advance the Community's understanding and pave the way for better interfaces. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flake-schemas-making-flake-outputs-extensible/32421/8 |
Simply put - the current approach is just not scalable, we got projects defining custom modules/configurations which are being recognized as 'unknown' due to the lack of a type system.
Some peeps suggest implementing nixpkgs options system or type system via JSON spec but I think the best solution here is to just remove the need for a type system in this case entirely.
Expected properties rename:
nixosConfigurations.hostname = {...}
toconfigurations.nixos.hostname = {...}
, so schema would be:configurations.<name>.<hostname> = {...}
nixosModules.moduleName = {...}
tomodules.nixos.moduleName = {...}
, so schema would be:modules.<name>.<moduleName> = {...}
(Similar idea to REST naming convention and existing system-specific properties)
Also, may I add that there is one annoyance current
nix flake check
implementation:nix/src/nix/flake.cc
Line 421 in 895dfc6
Alias in nixpkgs should be added so we could replace this line with something like this:
auto vToplevel = findAlongAttrPath(*state, "config.drv", bindings, v).first;
The text was updated successfully, but these errors were encountered: