Skip to content

Split out AutoAllocateUidSettings#15043

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:settings-split-0
Jan 26, 2026
Merged

Split out AutoAllocateUidSettings#15043
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:settings-split-0

Conversation

@Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Jan 22, 2026

Motivation

Progress on #5638

Context

This is a bit of weird process for a few reasons:

  1. I would like to get the struct as in the pair of fields to move out of globals.hh, but I don't want to move the settings descriptions to a new header, so I just did a weird split in place.

    Firstly because the setting descriptions (as we agreed) should not be in a header at all, and secondly, because I do want to group all these settings together somehow, not pass many unrelated, unnested arguments around.

  2. The current settings infrastructure prevents correct data modeling that would allow autoAllocateUids to go from a bool to a std::optional<AutoAllocateUidSettings>. So we are stuck just having a pair of a bool and AutoAllocateUidSettings which is not correct.

    However, we can compensate for this making the inheritance private and making the getter that looks like the field that we want to have. This pattern should be repeated as we break up the structs further, so we can enforce correct access patterns on the users of the globals without first having to overhaul the settings system before making any progress.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@Ericson2314 Ericson2314 force-pushed the settings-split-0 branch 2 times, most recently from 6f98e29 to cebc5c9 Compare January 22, 2026 04:12
amaanq added a commit to amaanq/nix that referenced this pull request Jan 22, 2026
This PR follows the same approach as NixOS#15043 and the
[`LogFileSettings`](NixOS#15051)
extraction:

- `GCSettings` struct inherits from virtual `Config`
- `Settings` privately inherits from it
- Accessed through `getGCSettings()`
amaanq added a commit to amaanq/nix that referenced this pull request Jan 22, 2026
This PR follows the same approach as NixOS#15043 and the
[`LogFileSettings`](NixOS#15051)
extraction:

- `GCSettings` struct inherits from virtual `Config`
- `Settings` privately inherits from it
- Accessed through `getGCSettings()`

The new method on `LocalStoreConfig` anticipates on making these
settings per-store. [This
commit](NixOS@0b606aa)
added both the autoGC and periodic wakeups.
amaanq added a commit to amaanq/nix that referenced this pull request Jan 22, 2026
This PR follows the same approach as NixOS#15043 and the
[`LogFileSettings`](NixOS#15051)
extraction:

- `GCSettings` struct inherits from virtual `Config`
- `Settings` privately inherits from it
- Accessed through `getGCSettings()`

The new method on `LocalStoreConfig` anticipates on making these
settings per-store. 0b606aa added both
the autoGC and periodic wakeups, which is why we think they are related.
amaanq added a commit to amaanq/nix that referenced this pull request Jan 22, 2026
This PR follows the same approach as NixOS#15043 and the
[`LogFileSettings`](NixOS#15051)
extraction:

- `GCSettings` struct inherits from virtual `Config`
- `Settings` privately inherits from it
- Accessed through `getGCSettings()`

The new method on `LocalStoreConfig` anticipates on making these
settings per-store. 0b606aa added both
the autoGC and periodic wakeups, which is why we think they are related.
@Mic92 Mic92 enabled auto-merge January 26, 2026 18:40
Follows the same pattern as `GCSettings`: extract UID allocation
settings
into a dedicated struct that Settings inherits privately from.

The current settings infrastructure prevents correct data modeling that
would allow `autoAllocateUids` to be a
`std::optional<AutoAllocateUidSettings>`.
To compensate, the getter `getAutoAllocateUidSettings()` returns a
pointer -
nullptr when disabled, providing the optional-like semantics we want.

Co-authored-by: Amaan Qureshi <git@amaanq.com>
@Ericson2314 Ericson2314 disabled auto-merge January 26, 2026 18:43
@Ericson2314 Ericson2314 enabled auto-merge January 26, 2026 19:16
@Ericson2314 Ericson2314 added this pull request to the merge queue Jan 26, 2026
Merged via the queue into NixOS:master with commit d3116dc Jan 26, 2026
14 checks passed
@Ericson2314 Ericson2314 deleted the settings-split-0 branch January 26, 2026 20:14
amaanq added a commit to obsidiansystems/nix that referenced this pull request Jan 26, 2026
This PR follows the same approach as NixOS#15043 and the extraction in
NixOS#15051. The `DatabaseSettings` struct inherits from the virtual `Config`
class, and `Settings` privately inherits from it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants