From 846fcd3683383a27163a80259527d89a4099549a Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Thu, 20 Jun 2024 18:43:55 -0600 Subject: [PATCH] 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. --- nix/default.nix | 12 +++++++++++- nix/overlays.nix | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/nix/default.nix b/nix/default.nix index a2302688..bfcabf55 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -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 = '' diff --git a/nix/overlays.nix b/nix/overlays.nix index cc66e1b5..ef7e9e02 100644 --- a/nix/overlays.nix +++ b/nix/overlays.nix @@ -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;};