Skip to content

builtins.getFlake: Support path values#15290

Open
edolstra wants to merge 3 commits intomasterfrom
getflake-path
Open

builtins.getFlake: Support path values#15290
edolstra wants to merge 3 commits intomasterfrom
getflake-path

Conversation

@edolstra
Copy link
Member

Motivation

This allows getting a subflake from the current source tree by doing

builtins.getFlake ./..

instead of the hacky

builtins.getFlake (builtins.flakeRefToString { type = "path"; path = self.sourceInfo.outPath; narHash = self.narHash; });

Based on DeterminateSystems#338 and part of DeterminateSystems#337.

Context


Add 👍 to pull requests you find important.

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

This allows doing `builtins.getFlake ./subflake` instead of ugly hacks.
@edolstra edolstra changed the title Getflake path builtins.getFlake: Support path values Feb 18, 2026
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Feb 18, 2026
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Very nice!

lockFlake(const Settings & settings, EvalState & state, const SourcePath & flakeDir, const LockFlags & lockFlags)
{
/* We need a fake flakeref to put in the `Flake` struct, but it's not used for anything. */
auto fakeRef = parseFlakeRef(state.fetchSettings, "flake:get-flake");
Copy link
Member

Choose a reason for hiding this comment

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

I suppose this simply might not fly and isn't worth changing, but if it does work,

Suggested change
auto fakeRef = parseFlakeRef(state.fetchSettings, "flake:get-flake");
auto fakeRef = parseFlakeRef(state.fetchSettings, "internal:get-flake");

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately that doesn't work because it's not a support input scheme:

       error: input 'internal:get-flake' is unsupported

@edolstra edolstra requested a review from roberth February 18, 2026 21:28
@edolstra edolstra enabled auto-merge February 18, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments