-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: support managing submodules via inputs.self #7862
base: master
Are you sure you want to change the base?
Conversation
3636d49
to
6d4c2ce
Compare
Provides special handling for inputs.self. If submodule is set to true, will re-call getFlake as if the original reference was set. The intended behavior is for CLI management of the parameter overrides any direct flake.nix settings.
6d4c2ce
to
6ebe06a
Compare
406319c
to
5fd671f
Compare
bca2a7b
to
6a05394
Compare
if (originalRef.input.attrs.count("submodules") == 0) { | ||
auto self = flake.inputs.find("self"); | ||
if (self != flake.inputs.end() && self->second.hasSubmodules) { |
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.
This comparison is a little ad hoc. It should be described in more general terms. My understanding of the process is:
- Nix makes a guess what the
self
input is - Nix checks that its guess matches the declared
self
input - Adjust
None of this is specific to git or submodules, so it should be done through virtual methods.
Other than that, I think lazy trees #6530 should make this specific parameter conceptually redundant, and enable it by default, as submodules should be fetched lazily.
However, that's not a reason not to have this mechanism, as we'll need it for at least a git-crypt
parameter.
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.
A general mechanism (but also with submodules
as the motivating case) is described and discussed in
@@ -114,6 +114,8 @@ reference types: | |||
|
|||
* `ref`: A Git or Mercurial branch or tag name. | |||
|
|||
* `submodules`: A boolean supporting Git submodules. |
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.
What's the default?
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.
* `submodules`: A boolean supporting Git submodules. | |
* `submodules`: Whether to also include Git submodules. Defaults to `false`. | |
@@ -405,6 +421,7 @@ LockedFlake lockFlake( | |||
necessary (i.e. if they're new or the flakeref changed | |||
from what's in the lock file). */ | |||
for (auto & [id, input2] : flakeInputs) { | |||
if (id == "self") continue; |
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.
Needs a note, and docs, about the “self” input being special.
Hm, it seems pretty ugly to add a git-specific |
Yeah it isn't fancy. We just implemented it overnight in a call yesterday. We're not even sure if this is even a good idea to have. The thing is that the git-specific |
Triaged in the Nix team meeting:
|
I believe that used to be the case but it was reverted because it was fetching when people didn't want it. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-02-24-nix-team-meeting-minutes-35/25757/1 |
To chime in, I've seen C++ projects before where certain submodules are optional except for special cases like testing. While enabling by default would be helpful, I can also imagine a feature like Either way, this feature as implemented in this PR or submodules by default would be incredibly useful for me. |
I think we should consider closing this, because the non-libgit fetching has too many problems and a more elegant replacement is in progress in #6530. |
Discussed in the Nix team meeting: We recommend instead to build a Nix language function that re-fetches an input by adding Complete discussion
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-03-20-nix-team-meeting-minutes-42/26615/1 |
What's the status here? I'd really like not to have to specify |
EDIT: added to team discussion queue for Friday. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/get-nix-flake-to-include-git-submodule/30324/13 |
Is this available on nix version 2.20 onwards? I would very much like an example of how I can build a derivation using a local submodule |
@amfaber , not a contributor/maintainer, but it doesn't seem like it based on the release notes |
It is not.
We're still exploring the solution space for efficiently fetching from a forge such as GitHub, which can return a tarball as a significantly quicker operation, so it's hard to tell whether changing the default setting would make sense. I do think we'll need a configurable |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/get-nix-flake-to-include-git-submodule/30324/14 |
Lack of support for submodules for current( |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Must be built with `nix build '.?submodules=1'` until this is merged: NixOS/nix#7862
Any update on this? |
Provides special handling for inputs.self. If submodule is set to true, will re-call getFlake as if the original reference was set. The intended behavior is for CLI management of the parameter overrides any direct flake.nix settings.
Thanks to: @x10an14, @aaronchall, @mrene
Motivation
Context
Provides a mechanism for
inputs.self.submodules
to control the availability of submodules in a local flake.Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*