NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.83k stars 1.52k forks source link

Triage and break up the global settings #5638

Open Ericson2314 opened 2 years ago

Ericson2314 commented 2 years ago

Thinking through #5603, and the two getDefaultSystemFeatures reminded me of this:

  1. We have many global settings that should be per-store. thisSytem and extraPlatforms are good examples. This works best after https://github.com/NixOS/nix/issues/5729 so that we don't pollute stores like HttpBinaryCacheStore with these new per-store options that don't make sense for them.

  2. 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

    • We should probably make stores that can build a subclass of stores that just are read/written. Then we don't have to do silly things like say what "extraPlatforms" s3://... has.
  3. 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.

  4. Finally, there may be global settings that are for the libstore layer at all, and they can be moved to another downstream library.

rickynils commented 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?

fricklerhandwerk commented 1 year ago

Triaged in the Nix team meeting 2023-02-17:

nixos-discourse commented 1 year ago

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

Ericson2314 commented 1 year ago

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!

Ericson2314 commented 1 year ago

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.


Brainstorming

virusdave commented 1 year ago
  • 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...]

roberth commented 1 year ago

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?]

nixos-discourse commented 1 year ago

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

roberth commented 1 year ago

Doing this turns bugs into errors, which is a tangible improvement.

nixos-discourse commented 1 year ago

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

thufschmitt commented 9 months ago

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.

Need to think about what we want. The config file / `--option foo` won't change, but the `--foo` shorthands can be discussed - @thufschmitt: Can we make these shorthands opt-in when declaring the config option? - Broad agreement, need to open an issue about it - Post-meeting: Opened https://github.com/NixOS/nix/issues/9908 for that. - Would only warn at first for non-opted-in flags to give a small grace period. The split between store settings and global settings can be treated independently from the CLI stabilization if we have this whitespace mechanism.
nixos-discourse commented 9 months ago

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

nixos-discourse commented 5 months ago

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