Skip to content

C API: Settings loading #12926

Description

@roberth

Is your feature request related to a problem?

First class settings are a good start, but we don't currently have a way to load actual settings into them; whether that's from the environment, or setting individual settings.

Proposed solution

Add functions to

  • load from the ambient environment
  • set individual settings

This applies to all _settings objects. Perhaps we could add an explicit pointer upcast function from e.g. nix_flake_settings * to nix_abstract_settings *, so that these functions work for all types that have such a "cast". These should be non-failing functions so that users can easily write something like:

err = nix_settings_load(globalSettingsValues, nix_flake_settings_as_abstract_settings(flakeSettings));

They would not be expected to store these nix_abstract_settings * anywhere, and we don't provide downcasts. If they want runtime polymorphism, they could implement it themselves and do a better job using an existing polymorphism system, especially when the caller is a language binding.

Alternative solutions

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    c apiNix as a C library with a stable interfacefeatureFeature request or proposalsettingsSettings, global flags, nix.conf

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions