Skip to content

Use same follows syntax as flake schema. - #7

Merged
vic merged 1 commit into
mainfrom
follows
Jul 15, 2025
Merged

vic merged 1 commit into
mainfrom
follows

Conversation

@vic

@vic vic commented Jul 15, 2025

Copy link
Copy Markdown
Member

This allows copy and paste of original flake inputs when migrating.

Fixes #4

Copilot AI review requested due to automatic review settings July 15, 2025 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aligns the flake-file tool’s follows syntax with the upstream Nix Flake schema, making it a direct field under inputs.<name>.inputs.<dep>.follows. Key changes include:

  • Introduces an inputsFollow mapper in write-flake.nix to emit nested follows under each input.
  • Restructures modules/options.nix to add dedicated inputs-follow-option and inputs-option for nested inputs.
  • Updates modules/allfollow.nix and the README to reflect the new nested follows syntax.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
modules/write-flake.nix Added inputsFollow stub and adjusted input expression logic.
modules/options.nix Broke out new inputs-follow-option, inputs-option, and related option wiring.
modules/allfollow.nix Changed new-input to place old follows under inputs key.
README.md Revised documentation to remove the old simplified syntax notes and update examples.
Comments suppressed due to low confidence (2)

modules/options.nix:18

  • Attribute names with hyphens aren’t valid Nix identifiers and will parse as subtraction. Use underscores or camelCase (e.g., inputsFollowOption) for option variable names.
  inputs-follow-option = lib.mkOption {

modules/options.nix:35

  • Similarly, inputs-option will be treated as inputs - option. Rename it to a valid identifier like inputsOption or inputs_option.
  inputs-option = lib.mkOption {

Comment thread modules/write-flake.nix
Comment on lines +69 to +71
{ }
// (if !input ? follows || input.follows == { } then { } else { inherit (input) follows; })
// (if !input ? inputs || input.inputs == { } then { } else { inputs = inputsFollow input.inputs; })

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

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

The inputsFollow function currently always returns an empty set because the real mapping logic is commented out. Uncomment and implement the follows logic so that nested dependencies are emitted correctly.

Suggested change
{ }
// (if !input ? follows || input.follows == { } then { } else { inherit (input) follows; })
// (if !input ? inputs || input.inputs == { } then { } else { inputs = inputsFollow input.inputs; })
let
followsPart = if !input ? follows || input.follows == { } then { } else { inherit (input) follows; };
inputsPart = if !input ? inputs || input.inputs == { } then { } else { inputs = inputsFollow input.inputs; };
in
followsPart // inputsPart

Copilot uses AI. Check for mistakes.
Comment thread modules/write-flake.nix
// (if !input ? flake || input.flake then { } else { flake = false; })
// (
if input.follows == { } then
if !input ? inputs || input.inputs == { } then

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

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

Operator precedence makes !input ? inputs ambiguous. Wrap the existence check in parentheses, e.g., if !(input ? inputs) || input.inputs == {} then, to ensure the condition evaluates as intended.

Suggested change
if !input ? inputs || input.inputs == { } then
if !(input ? inputs) || input.inputs == { } then

Copilot uses AI. Check for mistakes.
Comment thread README.md
## Available Options

Options are similar to the flake schema, with a simplified `follows` syntax. See below for details.
Options are same attributes as flake schema. See below for details.

Copilot AI Jul 15, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Improve grammar and clarity, for example: “Options use the same attributes as the Nix Flake schema. See below for details.”

Suggested change
Options are same attributes as flake schema. See below for details.
The options use the same attributes as the Nix Flake schema. See below for details.

Copilot uses AI. Check for mistakes.
@vic
vic merged commit 4ed81dc into main Jul 15, 2025
@vic
vic deleted the follows branch July 15, 2025 09:58
@ginkogruen

Copy link
Copy Markdown
Contributor

I seem to have an unfortunate timing about adopting this as I only did it an hour ago. Haha :) But thanks for the project I really like the idea.

@vic

vic commented Jul 15, 2025

Copy link
Copy Markdown
Member Author

Haha, good thing is that people do report important issues so we can fix them asap, before this gets more adoption.

So, welcome! I hope it serves you well :)

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.

Follows syntax is problematic for root follows

3 participants