-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC 184] versioned flakes references #184
Open
domenkozar
wants to merge
1
commit into
NixOS:master
Choose a base branch
from
domenkozar:rfc-183
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
feature: versioned-flakes | ||
start-date: 2024-11-25 | ||
author: domenkozar | ||
co-authors: None | ||
shepherd-team: None | ||
shepherd-leader: None | ||
related-issues: None | ||
--- | ||
## Summary | ||
|
||
Introduce a standardized versioning schema for Nix flakes using [SemVer](https://semver.org/), | ||
following lessons learned from [RFC 144](https://github.com/NixOS/rfcs/pull/144/files). | ||
|
||
Adds to flakes: | ||
|
||
- `version` attribute to `inputs` in the top-level of `flake.nix` to specify version of the input to be resolved. | ||
- An attribute `version` in the top-level of `flake.nix`. | ||
|
||
## Motivation | ||
|
||
Currently, Flakes lack a formal versioning mechanism, leading to potential duplication of dependencies and inefficient evaluations. | ||
|
||
By adopting a versioning schema similar to Rust's Cargo system, we can utilize a SAT solver to manage dependencies more effectively, minimizing redundancy and improving performance. | ||
|
||
## Explanation | ||
|
||
- **Version Schema:** Implement a versioning system for flakes that follows SemVer conventions (e.g., `1.0.0`, `2.1.3`). | ||
- **Input Versioning:** Allow flake inputs to specify version constraints (e.g., `inputs.nixpkgs.version = "^3.0.0";`) following [Rust Caret Requirement Syntax]([https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#version-requirement-syntax](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements)). | ||
- **Dependency Resolution:** Integrate a SAT solver to resolve dependencies based on specified versions, ensuring compatibility and reducing duplication. | ||
|
||
### Examples | ||
|
||
**Defining a Flake with a Version:** | ||
|
||
```nix | ||
{ | ||
version = "1.0.0"; | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs"; | ||
nixpkgs.version = "^1.0.55"; | ||
}; | ||
outputs = { self, nixpkgs }: { /* ... */ }; | ||
} | ||
``` | ||
|
||
### Implementation | ||
|
||
Nix would resolve versions as part of the evaluation, shipping a SAT version resolver. | ||
|
||
`flake-compat` wouldn't support version resolving. | ||
|
||
[flakestry.dev](https://github.com/flakestry/flakestry.dev) would provide an HTTP API for resolving by preevaluating flakes. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem in semver:
It is more reliable if: any package update will trigger "full-rebuilds" for those dependent on it.
I just feel a little bit strange about introducing "SemVer" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, isn't this RFC about versioning flakes, not packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the interesting paradox: if we don't use semantic versioning (SemVer) for packages, why should we use SemVer for flakes?
If there are valid reasons for using SemVer with 'flake' dependencies, why wouldn't those same reasons apply to packages as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will you apply semver to nixpkgs flake?