Open Ericson2314 opened 2 years ago
I'm dumping some references here, where discussions about options propagation to remote builders can be found:
https://github.com/NixOS/nix/issues/5600 https://github.com/NixOS/nix/pull/2994 https://github.com/NixOS/nix/pull/4180
The issue is that when using remote builders or remote stores, it is not at all clear what options will be in effect. For ssh://
there is a small set of settings propagated, for ssh-ng://
almost no options (I think builders-use-substitutes
is the only one) are propagated. It doesn't make sense to propagate all Nix options indiscriminately, because many settings are related to aspects of the local machine. If I understand this issue correctly, we could identify options that are related to specific types of stores and then propagate these when such remote stores are used?
Triaged in the Nix team meeting 2023-02-17:
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2023-02-17-nix-team-meeting-minutes-33/25624/1
The author of #6980, @virusdave, talks it about it being confusing that an arbitrary Nix invocation looks up the users home directory. I agree this seems off!
The reason for this is ultimately that our settings are stored in these giant global variables. The default value settings must be created and start-up time, and since profiles optionally got moved to home directories, that means looking up the user's home directory.
The new location is good, and the warning on looking up the home directory is also good. The problem is, once again, the global. Global settings mean a violation of "pay for what you use, only". We have to do all this work for settings we may well not end up using, simply because global variables mean all configuration must be done eagerly.
This is not good!
We discussed this today during the Nix Team meeting at length.
As part of this, we discussed the sort of user facing configuration changes we could also do that that relate to this. There should be a separate "overhaul the configuration system" ticket for that to track these user-facing points distinct from this info which is really about implementation details (though each does inform the other!). That said, that issue doesn't yet exist, and the conversation went back and forth, so so I will post everything here for now.
check-trusted
):
@Ericson2314: would be good to have hierarchical settings
@edolstra: it would be much easier if nix.conf
was a JSON file
but this is unrelated, because how many settings do we really want to have for a single program?
having a flat namespace for settings is not bad in itself
documentation can be solved by having settings in categories
gc-<foo>
@edolstra clarifying a "limited" JSON file he supports:
illustrating
{
# bad according to Eelco
"gc": {
"auto": {
"enable": true
}
}
# good acording to Eelco
"gc-auto-enable": true,
"use-substitutes": false,
"substituters": [
{"url": "https://cache.nixos.org", "priority": 10}
],
# Today, not so good
"store": "local?system=i686-linux"
# Better:
"store": {
"type": "local",
"system": "i686-linux"
},
"eval-store": null, # defaults to `.store`
"builders": [
{
# there may not be "hostname": "builder.example.org",
"systemTypes": ["i686-linux"],
"store": {
"type": "local",
"chroot": "/tmp/nix",
}
}
]
}
--extra-builders '[{....}]'
good--builders.0.system-types '[...]'
not good@edolstra: in the NixOS module system we have an ambiguity, where although it looks like a hierarchical configuration it's in fact a flat namespace that collides with actually hierarchical settings
gc
is about the store
@Ericson2314: one way of thinking about this is that it should be possible to rig up two Nix processes which run on different configurations, such as different daemons and GCs
@tomberek: in flakes we have two methods of expressing inputs, as attributes and as URL; may work similarly for remote stores/builders
@roberth: we should pay attention the rules of database design; we're designing a database for configurations
@roberth: should also consider e.g. settings for S3 stores, we may have multiple of those
@edolstra: with lists there is no way to override elements inside a list
@ericson2314:
"builder": true
with "builder": "allowed"
vs "builder": "used-by-default"
.@roberth: concerning aliases: thinking along the lines of the SSH config file
@ericson2314: related to installer:
Some different directions of work going on:
@ericson3214 ultimately thinks that second approach is the the right way forward: Make the complexity lazy / on demand, rather than trying to deal with setting up everything the user might possibly need to do, before they actually might do it.
@roberth: this is interface segragation (or "pay for what you use"): SOLID
@ericson2314:
Only configure/initialize what you use:
nix-env
you don't need to worry about profile dirsNIX_PATH
Only set up state for what you use
@edolstra: how does this differ from the current state? if you don't use values in the configuration, they don't matter
nix.conf
is a fully generic configuration file or a generic one for Nix
@edolstra: lazy and hierarchical options seem to be orthogonal concepts
nix-env
, then we can validate the root attrset and allow a profile
setting that contains garbage by just ignoring it
@fricklerhandwerk: is this enough for @ericson2314 and @roberth to make a design draft and a sketch of a migration path?
illustrating
{ # bad according to Eelco "gc": { "auto": { "enable": true } } # good acording to Eelco "gc-auto-enable": true, "use-substitutes": false, "substituters": [ {"url": "https://cache.nixos.org", "priority": 10} ], # Today, not so good "store": "local?system=i686-linux" # Better: "store": { "type": "local", "system": "i686-linux" }, "eval-store": null, # defaults to `.store` "builders": [ { # there may not be "hostname": "builder.example.org", "systemTypes": ["i686-linux"], "store": { "type": "local", "chroot": "/tmp/nix", } } ] }
At the risk of opening up an unintended deluge of derision, response spam, or bikeshedding...
I want to quickly suggest consideration of something other than json for things like this. Clearly Eelco doesn't like the verbosity of namespacing that json requires, but something like HOCON (with c++ impl) solves this completely and gives you familiar json-like syntax but in a human-friendly form without the downsides of abominations like YAML or resorting to "namespacing-via-string-concat-in-key-names" like in the above hypothetical example. Other options would include things like cue, or many other common or standard-ish options that don't suck like json does.
I do realize there's already use of json in nix, so using something else would require adding an additional dependency, but for anything likely to attract human interaction (like configuration as discussed here), i would beseech consideration of a better, less human-hostile format for config state storage. I, at least, believe that the benefits outweigh the dependency cost.
[@virusdave ducks backs back out of the discussion here...]
I think finding the right data model is orders of magnitude more important than the syntax. That said...
[@virusdave ducks backs back out of the discussion here...]
Wise choice ;)
HOCON
The references are too much for me. I've had the misfortune of using HOCON with an Akka application once, and I would describe the use of references for some sort of overriding as haunting at best. We may also consider reusing TOML.
[@roberth joins @virusdave in the nice place where syntax does not matter... Anyone else joining?]
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2023-03-13-nix-team-meeting-minutes-40/26309/1
Doing this turns bugs into errors, which is a tangible improvement.
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 during the Nix maintainers meeting on 2024-01-30. Need to tackle https://github.com/NixOS/nix/issues/9908 first so that this doesn't block the CLI stabilisation any more.
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2024-01-30-nix-team-meeting-minutes-119/39185/1
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2024-06-05-nix-team-meeting-minutes-150/46583/1
Thinking through #5603, and the two
getDefaultSystemFeatures
reminded me of this:We have many global settings that should be per-store.
thisSytem
andextraPlatforms
are good examples. This works best after https://github.com/NixOS/nix/issues/5729 so that we don't pollute stores likeHttpBinaryCacheStore
with these new per-store options that don't make sense for them.We have too much ad-hoc logic around build remotes that should be fixed up to use per-store settings instead, as we did before with system features in 4720853129b6866775edd9f90ad6f10701f98a3c
s3://...
has.https://github.com/NixOS/nix/issues/5025#issuecomment-887444929 remains a very good idea. Then many of the remaining settings which aren't per-store would make sense as an additional config parameter to this now-freestanding (not
Store
method) function.Finally, there may be global settings that are for the libstore layer at all, and they can be moved to another downstream library.