nix: fix build by deferring submodule fetching

Currently, it isn't possible to fetch submodules on `inputs.self` of a
Nix flake. As a workaround, use `builtins.fetchGit` with `self.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` of `self` as with
other inputs. This way, when interacting with the other outputs of the
flake, the cost of fetching submodules is avoided.
This commit is contained in:
Timothy DeHerrera 2024-06-20 18:43:55 -06:00
parent fabc30df52
commit 846fcd3683
No known key found for this signature in database
GPG key ID: E44213186BC9AFE2
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,5 @@
{
self,
lib,
stdenv,
pkg-config,
@ -68,7 +69,16 @@ assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been remov
baseName = baseNameOf (toString name);
in
! (lib.hasSuffix ".nix" baseName);
src = lib.cleanSource ../.;
src = lib.cleanSource (
if self ? rev
then builtins.fetchGit {
url = "https://github.com/hyprwm/Hyprland";
inherit (self) rev;
submodules = true;
allRefs = true;
}
else ../.
);
};
postPatch = ''

View file

@ -36,6 +36,7 @@ in {
version = "${props.version}+date=${date}_${self.shortRev or "dirty"}";
commit = self.rev or "";
inherit date;
inherit (inputs) self;
};
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
hyprland-debug = final.hyprland.override {debug = true;};