-
-
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 0123] Flake names #123
base: master
Are you sure you want to change the base?
Changes from all commits
9515060
08d1fc5
bae96ea
53b1dc7
a108a3b
9acd46f
23e44a1
bb09d85
b077d31
79d2e61
0cb078f
e3b651f
7811f0e
d8c2e19
c3bdc8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,91 @@ | ||||||||||||||
--- | ||||||||||||||
feature: flake-names | ||||||||||||||
start-date: 2022-03-12 | ||||||||||||||
author: Anselm Schüler | ||||||||||||||
co-authors: None | ||||||||||||||
shepherd-team: None | ||||||||||||||
shepherd-leader: None | ||||||||||||||
related-issues: None | ||||||||||||||
--- | ||||||||||||||
|
||||||||||||||
# Summary | ||||||||||||||
[summary]: #summary | ||||||||||||||
|
||||||||||||||
Flakes can declare the field `name`. | ||||||||||||||
It represents the name of the flake. | ||||||||||||||
The store paths corresponding to a flake source are no longer called `source`, but use the flake name. | ||||||||||||||
|
||||||||||||||
# Motivation | ||||||||||||||
[motivation]: #motivation | ||||||||||||||
|
||||||||||||||
- Flakes generate store paths named “source”, and it’s difficult to navigate this when manually inspecting the store. | ||||||||||||||
- This metadata can be used to make flakes more approachable and usable, in particular, it can be output instead or with the URI, making the nix commands friendlier. | ||||||||||||||
|
||||||||||||||
# Detailed design | ||||||||||||||
[design]: #detailed-design | ||||||||||||||
|
||||||||||||||
A new supported property for flakes is introduced, `name`. | ||||||||||||||
The derivation that contains the flake’s content is called `flake-source-${name}` | ||||||||||||||
|
||||||||||||||
# Examples and Interactions | ||||||||||||||
[examples-and-interactions]: #examples-and-interactions | ||||||||||||||
|
||||||||||||||
Running `nix flake metadata` on a flake that declares this field displays it at the top. | ||||||||||||||
Running `nix flake show` on a flake that declares this field shows the name instead of the URL, followed by the URL in parentheses. | ||||||||||||||
|
||||||||||||||
Examples: | ||||||||||||||
|
||||||||||||||
File `/example/flake.nix` | ||||||||||||||
```nix | ||||||||||||||
{ | ||||||||||||||
name = "example"; | ||||||||||||||
outputs = { ... }: { | ||||||||||||||
lib.example = "example"; | ||||||||||||||
}; | ||||||||||||||
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Making the name accessible will allow flake definition libraries (flake-utils, flake-parts, etc) to automatically use it in some places. For instance when defining an anonymous (non-path-value) module, it's a good idea to use the flake name and module attribute to form the module |
||||||||||||||
} | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
Shell | ||||||||||||||
```console | ||||||||||||||
$ nix eval git+file:///example | ||||||||||||||
[…] copying flake-source-example | ||||||||||||||
"example" | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
Example of interactions: | ||||||||||||||
|
||||||||||||||
Shell (using the previous file) | ||||||||||||||
``` | ||||||||||||||
$ nix flake metadata /example | ||||||||||||||
Name: example | ||||||||||||||
Resolved URL: git+file:///example | ||||||||||||||
Locked URL: … | ||||||||||||||
$ nix flake show /example | ||||||||||||||
example (git+file:///home/anselmschueler/Code/example?rev=b0&rev=c714c8624f5d49a9d88e6e24550dd88515923c18) | ||||||||||||||
└───lib: unknown | ||||||||||||||
``` | ||||||||||||||
|
||||||||||||||
# Drawbacks | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The big drawback here (where “big” would probably need to be refined, I’ve no idea how much of an issue it is in practice) is that since the name is part of the store path, two flakes with the same content but a different name will end-up in a different place in the store − which itself means that everything that depends on them would have to be rebuild. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But flakes with a different name will necessarily have different content? Or are the flake.* files not copied to the store? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair point (I had a convoluted scenario in mind, but that’s probably way out of the scope of this RFC now that I think of it). That’s actually highlighting an interesting design challenge: There’s currently a neat separation between the fetching code and the code that knows about what the flake is.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn’t it be better to have this conversation outside the review widget? I feel like this aspect of the discussion is somewhat hidden & non-chronological. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This can be solved by adding |
||||||||||||||
[drawbacks]: #drawbacks | ||||||||||||||
|
||||||||||||||
- This may cause clutter and additional maintenance. | ||||||||||||||
- Since this changes the output of nix flake metadata and nix flake show, it might cause scripts that read this output to break. | ||||||||||||||
- This requires a significant change to the way flakes are handled. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
All changes come with an implementation cost. I don't think this RFC is special, because it seems like an addition that doesn't require action by the ecosystem, especially if the name is allowed to be unset. |
||||||||||||||
- This treats the Nix store as a user-facing part of Nix, which is generally not intended. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The store has always been user-facing. Users interact with it, store paths show up in logs, etc. Sometimes you don't have to think much about the store and that's good. How will users will have to pay more attention to the store after this change? |
||||||||||||||
|
||||||||||||||
# Alternatives | ||||||||||||||
[alternatives]: #alternatives | ||||||||||||||
|
||||||||||||||
- Flake names could be handled entirely through outside means, with things like the global registry merely pointing to flakes under names. | ||||||||||||||
|
||||||||||||||
# Unresolved questions | ||||||||||||||
[unresolved]: #unresolved-questions | ||||||||||||||
|
||||||||||||||
- The name scheme could be changed. `flake-source-${name}` could be too long. Alternatives include `source-${name}`. | ||||||||||||||
- The interactions with nix flake metadata and nix flake show are not critical to the design, which is mostly aimed at clarifying derivation names. | ||||||||||||||
|
||||||||||||||
# Future work | ||||||||||||||
[future]: #future-work | ||||||||||||||
|
||||||||||||||
- Flake usability can be improved. | ||||||||||||||
- Issues with indicipherable derivations named “source” also exist elsewhere. |
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.