-
-
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
nix flakes: add support for git submodules #4423
Comments
I think this is a duplicate of #4357 |
Apparently closed by #4435 |
I think there is still one piece missing: the flake itself is not being fetched using submodules. |
Yes, perhaps it's worth closing this issue, and opening the original one (since this is a duplicate)? Also, I am not sure how to go about requiring a flake itself to pull its own submodules. If a flake only has inputs and outputs, and an external definition determines the method for downloading it (a flake can be a local folder, too, or a tarball, can't it?), then where's the compromise? A flake is assumed to be a git repo, so it would make sense for a universal "fetch submodules" option, perhaps as an |
What would be a good & concise way to present the design decision abstract primitives still in question to @edolstra / the maintainers? (possibly on another issue for proper framing) |
I made an ugly patch where submodules are always fetched: L-as@ce0a547 The idea is that if a flake has submodules, they should probably always be fetched (why would you add them otherwise?). |
@L-as yeah that's just turning it on for everything. If you look at the constructor for one of the classes for the |
It has to work with all nix commands though, and I can't see the use in being forced to manually write |
Consider a public NixOS config repo with a private submodule. One may want to be able to build the config even without access to the private parts. |
You could make it so that failure to clone the submodules is a non-fatal error. |
I'm not sure that's desirable behaviour. It's nondeterministic, then |
We should enable submodules by default and make sure they work for top-level flakes. |
Are there any work-arounds for top flake? nix build '.?submodules=1#nixosConfigurations.myhost.config.system.build.toplevel' Doesn't work. Inside of |
I currently just use flake_input_fixed = builtins.fetchGit {
url = "<your-url>";
inherit (flake_input) rev;
ref = "<branch>"; # optional if not default
submodules = true;
}; @ony: You might be able to do the same with EDIT: It should be noted that |
Blocked on NixOS/nix#4423, build doesn't see submodules.
I'm having trouble fitting flakes to the use case of developing a git repo (e.g. My use case is as follows: I have a top level flake (and git repo) with a bunch of git submodules. I want to change these submodules and have those changes show up when I build outputs of the top level flake. Maybe I'm going about this wrong? Is there an easy way to get this sort of workflow? I see the listing all submodule directories as Another solution could be a flag that specifies whether or not to fetch |
The only usable way I see is to get all the submodule hashes and print them in Ideally one can then extract already existing However I am not sure, what guarantees |
Is top-level flake supported? I'm using a submodule inside my flake repo, in nixos, I can use nixos-install/rebuild to build it without any issue. But for the github workflow, it's using ubuntu and only has nix binary. I'm build the system with this [command])https://github.com/ztlevi/dotty-nix/blob/main/.github/workflows/build.yml#L45). But it pops submodule error. The submodule here is call See my build failure here Since the issue is closed, @edolstra to add some visibility. |
Strawman question: have you tried a more recent version of Just to add in my 2 cents: I've built flake attributes that use git submodules on yesterday's |
@DieracDelta How am I able to test the latest nix build in the github workflow? ttps://github.com/ztlevi/dotty-nix/blob/main/.github/workflows/build.yml#L45 The nix release is too old |
EDIT ncfaviers solution is better. |
@jakubgs I don't even know how to get it to work in CLI. How do you do that? |
Exactly as shown in #4423 (comment). |
@jakubgs but how do we set type="git" to self? |
* this is because flake doesn't support git submodules yet- NixOS/nix#4423
In case anyone is interested in using submodules on flake inputs , not just the flake directory itself, you have to specifically use Example:
C.f. Lines 270 to 271 in 31ffd0c
|
This issue 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/1 |
Update: Be careful, fetching from a git with submodules is not deterministic and you will get narhash clashes. See NixOS/nixpkgs#100498 for workarounds using e.g. |
This way we can actually build and run a node using just: ```sh nix build github:status-im/nimbus-eth2?submodules=1 ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run github:status-im/nimbus-eth2?submodules=1 ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run github:status-im/nimbus-eth2?submodules=1 ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way we can actually build and run a node using just: ```sh nix run 'github:status-im/nimbus-eth2?submodules=1' ``` The `?submodules=1` part should eventually not be necessary. For more details see: NixOS/nix#4423 Signed-off-by: Jakub Sokołowski <jakub@status.im>
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
I recently learned about Nix Flakes, and I tried out making my blog a perfectly reproducible build. The trouble is, my blog uses a Git submodule to reference some code that I then present in my blog posts. This is fine and all, but I run into an issue - although I can fetch my blog source using Flakes'
input
attribute, it doesn't fetch submodules! This means that the code that I reference in my build process is simply not there.This seems to be almost possible; from a brief glance around Nix's source code, I discovered that a flake input gets turned into a "regular" input, which can point to a git repo and have a
submodules
attribute that, I think, would do what I want. It feels as though it was intended that this would work, but it doesn't.It doesn't work because, for a reason unknown to me, a flake input's attributes must all be strings (except for
flake
). Here's the code that rejects non-string arguments:nix/src/libexpr/flake/flake.cc
Lines 123 to 127 in 724b7f4
If non-string arguments were not rejected, a
submodules
field could be forwarded to the Git input scheme, which I suspect would make this work. Is there a reason that Flakes rejects all non-string "third party" attributes? It puts them into an attribute set anyway. Right now, I'm falling into a rather amusing loop:If
submodules
is a string, it's rejected by the Git input scheme. But if it's abool
, it's rejected by the Flake code.The text was updated successfully, but these errors were encountered: