Skip to content

configuration: make AbsolutePath a wrapper type#15362

Open
amaanq wants to merge 1 commit intoNixOS:masterfrom
obsidiansystems:convert-path-setting-followup
Open

configuration: make AbsolutePath a wrapper type#15362
amaanq wants to merge 1 commit intoNixOS:masterfrom
obsidiansystems:convert-path-setting-followup

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Feb 27, 2026

Motivation

Public inheritance from std::filesystem::path lets AbsolutePath
silently slice down to a plain path when passed by value, so this commit changes
AbsolutePath to use a path field instead, which is easier to reason about and prevents that.

Context


Add 👍 to pull requests you find important.

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

* rejecting empty and relative paths.
*/
struct AbsolutePath : std::filesystem::path
struct AbsolutePath
Copy link
Contributor

@xokdvium xokdvium Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done using private inheritance, no? Less churny code to write, just using path::operator== and stuff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I tried this, and it looks like we'd still have churn because we can't just do using path::operator== and friends because they are defined as non-member friend functions

Public inheritance from `std::filesystem::path` lets `AbsolutePath`
silently slice down to a plain path when passed by value, so this commit changes
`AbsolutePath` to use a `path` field instead, which is easier to reason about and prevents that.
@amaanq amaanq force-pushed the convert-path-setting-followup branch from 906aabb to 029f54c Compare February 28, 2026 05:14
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.

2 participants