Open nrdxp opened 1 week ago
This solution is interesting. I can see the pros it would bring, but it also has some cons:
- Building locally after making a change (uncommitted) still requires
nix build '.?submodules=1'
.- However, if you commit (but not push) the changes, it's impossible to build hyprland anymore.
- The repo is downloaded twice (first without submodules, second with).
Actually, now that you point this out, I wonder if it is possible to use builtins.fetchGit
on a local path. That would potentially fix these issues, but since flakes strip the .git
directory, I'm not sure it would work. Maybe there is some way to do it though :thinking:
Actually, now that you point this out, I wonder if it is possible to use
builtins.fetchGit
on a local path. That would potentially fix these issues, but since flakes strip the.git
directory, I'm not sure it would work. Maybe there is some way to do it though 🤔
I've tried this for the "dirty" case, and Nix complains that we require a hash:
error: in pure evaluation mode, 'fetchTree' requires a locked input, at «none»:0
When passing --impure
, git fails with exit code 128.
Describe your PR, what does it fix/add?
Currently, it isn't possible to fetch submodules on
inputs.self
of a Nix flake. As a workaround, usebuiltins.fetchGit
withself.rev
of the current checkout to include submodules.This implementation defers submodule fetching to build time instead of before the flake evaluation begins, which would be the case if it were possible to specify submodule fetching in the
inputs
ofself
as with other inputs. This way, when interacting with the other outputs of the flake, the cost of fetching submodules is avoided.Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Unfortunately, since the flake.lock format does not encode information about a canonical remote location for
inputs.self
, the url must be hardcoded.Is it ready for merging, or does it need work?
I believe this is likely the best workaround, currently, to fix the build. We could alternately use one of the nixpkgs fetchers to make the source an FOD, however the benefit of the builtin is that we only need specify a git
rev
as the integrity hash.