mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 07:05:58 +01:00
Nix: fix recursion in package overlays (#2210)
* nix: flake: fix improperly using prev.callPackage * flake: cleanup with let blocks * flake: make overlays use recursive packages flake: separate overlays into multiple, combine into default * nix: overlays: extract to own file * flake: devShells: remove stdenv override * overlays: hl-pkgs: xdph: remove needless overlay Since the packages are now built with the overlays combined from inputs and self, overriding specific dependencies (anywhere) is no longer necessary. * nix: overlays: extras: include xdph and share-picker * nix: overlays: hl-pkgs: remove stdenv override
This commit is contained in:
parent
79791c9ed4
commit
80b2ac1cc5
3 changed files with 142 additions and 84 deletions
110
flake.nix
110
flake.nix
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
wlroots = {
|
wlroots = {
|
||||||
url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org";
|
url = "gitlab:wlroots/wlroots?host=gitlab.freedesktop.org";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
lib = nixpkgs.lib.extend (import ./nix/lib.nix);
|
||||||
genSystems = lib.genAttrs [
|
genSystems = lib.genAttrs [
|
||||||
# Add more systems if they are supported
|
# Add more systems if they are supported
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
@ -36,103 +37,44 @@
|
||||||
import nixpkgs {
|
import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [
|
overlays = [
|
||||||
(_: prev: {
|
self.overlays.hyprland-packages
|
||||||
wayland = prev.wayland.overrideAttrs (old: rec {
|
self.overlays.wlroots-hyprland
|
||||||
version = "1.22.0";
|
self.overlays.wayland-latest
|
||||||
src = prev.fetchurl {
|
inputs.hyprland-protocols.overlays.default
|
||||||
url = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/${version}/downloads/${old.pname}-${version}.tar.xz";
|
|
||||||
hash = "sha256-FUCvHqaYpHHC2OnSiDMsfg/TYMjx0Sk267fny8JCWEI=";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
props = builtins.fromJSON (builtins.readFile ./props.json);
|
|
||||||
|
|
||||||
mkDate = longDate: (lib.concatStringsSep "-" [
|
|
||||||
(builtins.substring 0 4 longDate)
|
|
||||||
(builtins.substring 4 2 longDate)
|
|
||||||
(builtins.substring 6 2 longDate)
|
|
||||||
]);
|
|
||||||
in {
|
in {
|
||||||
overlays.default = _: prev: rec {
|
overlays =
|
||||||
wlroots-hyprland = prev.callPackage ./nix/wlroots.nix {
|
(import ./nix/overlays.nix {inherit self lib inputs;})
|
||||||
version = mkDate (inputs.wlroots.lastModifiedDate or "19700101") + "_" + (inputs.wlroots.shortRev or "dirty");
|
// {
|
||||||
src = inputs.wlroots;
|
default =
|
||||||
libdisplay-info = prev.libdisplay-info.overrideAttrs (old: {
|
lib.mkJoinedOverlays
|
||||||
version = "0.1.1+date=2023-03-02";
|
(with self.overlays; [
|
||||||
src = prev.fetchFromGitLab {
|
hyprland-packages
|
||||||
domain = "gitlab.freedesktop.org";
|
hyprland-extras
|
||||||
owner = "emersion";
|
wlroots-hyprland
|
||||||
repo = old.pname;
|
]);
|
||||||
rev = "147d6611a64a6ab04611b923e30efacaca6fc678";
|
|
||||||
sha256 = "sha256-/q79o13Zvu7x02SBGu0W5yQznQ+p7ltZ9L6cMW5t/o4=";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
libliftoff = prev.libliftoff.overrideAttrs (old: {
|
|
||||||
version = "0.5.0-dev";
|
|
||||||
src = prev.fetchFromGitLab {
|
|
||||||
domain = "gitlab.freedesktop.org";
|
|
||||||
owner = "emersion";
|
|
||||||
repo = old.pname;
|
|
||||||
rev = "d98ae243280074b0ba44bff92215ae8d785658c0";
|
|
||||||
sha256 = "sha256-DjwlS8rXE7srs7A8+tHqXyUsFGtucYSeq6X0T/pVOc8=";
|
|
||||||
};
|
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = toString [
|
|
||||||
"-Wno-error=sign-conversion"
|
|
||||||
];
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
hyprland = prev.callPackage ./nix/default.nix {
|
|
||||||
stdenv = prev.gcc12Stdenv;
|
|
||||||
version = props.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
|
||||||
wlroots = wlroots-hyprland;
|
|
||||||
commit = self.rev or "";
|
|
||||||
inherit (inputs.hyprland-protocols.packages.${prev.stdenv.hostPlatform.system}) hyprland-protocols;
|
|
||||||
inherit udis86;
|
|
||||||
};
|
|
||||||
hyprland-debug = hyprland.override {debug = true;};
|
|
||||||
hyprland-hidpi = hyprland.override {hidpiXWayland = true;};
|
|
||||||
hyprland-nvidia = hyprland.override {nvidiaPatches = true;};
|
|
||||||
hyprland-no-hidpi = builtins.trace "hyprland-no-hidpi was removed. Please use the default package." hyprland;
|
|
||||||
|
|
||||||
udis86 = prev.callPackage ./nix/udis86.nix {};
|
|
||||||
|
|
||||||
waybar-hyprland = prev.waybar.overrideAttrs (oldAttrs: {
|
|
||||||
postPatch = ''
|
|
||||||
# use hyprctl to switch workspaces
|
|
||||||
sed -i 's/zext_workspace_handle_v1_activate(workspace_handle_);/const std::string command = "hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());/g' src/modules/wlr/workspace_manager.cpp
|
|
||||||
'';
|
|
||||||
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
|
|
||||||
});
|
|
||||||
|
|
||||||
xdg-desktop-portal-hyprland = inputs.xdph.packages.${prev.stdenv.hostPlatform.system}.default.override {
|
|
||||||
hyprland-share-picker = inputs.xdph.packages.${prev.stdenv.hostPlatform.system}.hyprland-share-picker.override {inherit hyprland;};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
checks = genSystems (system:
|
checks = genSystems (system:
|
||||||
(lib.filterAttrs (n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n)) self.packages.${system})
|
(lib.filterAttrs
|
||||||
// {inherit (self.packages.${system}) xdg-desktop-portal-hyprland;});
|
(n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n))
|
||||||
|
self.packages.${system})
|
||||||
|
// {
|
||||||
|
inherit (self.packages.${system}) xdg-desktop-portal-hyprland;
|
||||||
|
});
|
||||||
|
|
||||||
packages = genSystems (system:
|
packages = genSystems (system:
|
||||||
(self.overlays.default null pkgsFor.${system})
|
(self.overlays.default pkgsFor.${system} pkgsFor.${system})
|
||||||
// {
|
// {
|
||||||
default = self.packages.${system}.hyprland;
|
default = self.packages.${system}.hyprland;
|
||||||
});
|
});
|
||||||
|
|
||||||
devShells = genSystems (system: {
|
devShells = genSystems (system: {
|
||||||
default = pkgsFor.${system}.mkShell.override {stdenv = pkgsFor.${system}.gcc12Stdenv;} {
|
default = pkgsFor.${system}.mkShell {
|
||||||
name = "hyprland-shell";
|
name = "hyprland-shell";
|
||||||
nativeBuildInputs = with pkgsFor.${system}; [
|
nativeBuildInputs = with pkgsFor.${system}; [cmake];
|
||||||
cmake
|
buildInputs = [self.packages.${system}.wlroots-hyprland];
|
||||||
];
|
|
||||||
buildInputs = [
|
|
||||||
self.packages.${system}.wlroots-hyprland
|
|
||||||
];
|
|
||||||
inputsFrom = [
|
inputsFrom = [
|
||||||
self.packages.${system}.wlroots-hyprland
|
self.packages.${system}.wlroots-hyprland
|
||||||
self.packages.${system}.hyprland
|
self.packages.${system}.hyprland
|
||||||
|
|
8
nix/lib.nix
Normal file
8
nix/lib.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
final: prev: let
|
||||||
|
lib = final;
|
||||||
|
|
||||||
|
mkJoinedOverlays = overlays: final: prev:
|
||||||
|
lib.foldl' (attrs: overlay: attrs // (overlay final prev)) {} overlays;
|
||||||
|
in prev // {
|
||||||
|
inherit mkJoinedOverlays;
|
||||||
|
}
|
108
nix/overlays.nix
Normal file
108
nix/overlays.nix
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
lib,
|
||||||
|
inputs,
|
||||||
|
}: let
|
||||||
|
props = builtins.fromJSON (builtins.readFile ../props.json);
|
||||||
|
|
||||||
|
mkDate = longDate: (lib.concatStringsSep "-" [
|
||||||
|
(builtins.substring 0 4 longDate)
|
||||||
|
(builtins.substring 4 2 longDate)
|
||||||
|
(builtins.substring 6 2 longDate)
|
||||||
|
]);
|
||||||
|
in {
|
||||||
|
# Packages for variations of Hyprland, and its dependencies.
|
||||||
|
hyprland-packages = final: prev: {
|
||||||
|
hyprland = final.callPackage ./default.nix {
|
||||||
|
version =
|
||||||
|
props.version
|
||||||
|
+ "+date="
|
||||||
|
+ (mkDate (self.lastModifiedDate or "19700101"))
|
||||||
|
+ "_"
|
||||||
|
+ (self.shortRev or "dirty");
|
||||||
|
wlroots = final.wlroots-hyprland;
|
||||||
|
commit = self.rev or "";
|
||||||
|
inherit (final) udis86 hyprland-protocols;
|
||||||
|
};
|
||||||
|
|
||||||
|
hyprland-debug = final.hyprland.override {debug = true;};
|
||||||
|
hyprland-hidpi = final.hyprland.override {hidpiXWayland = true;};
|
||||||
|
hyprland-nvidia = final.hyprland.override {nvidiaPatches = true;};
|
||||||
|
hyprland-no-hidpi =
|
||||||
|
builtins.trace
|
||||||
|
"hyprland-no-hidpi was removed. Please use the default package."
|
||||||
|
final.hyprland;
|
||||||
|
|
||||||
|
udis86 = final.callPackage ./udis86.nix {};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Packages for extra software recommended for usage with Hyprland,
|
||||||
|
# including forked or patched packages for compatibility.
|
||||||
|
hyprland-extras = lib.mkJoinedOverlays [
|
||||||
|
# Include any inputs' specific overlays whose attributes should
|
||||||
|
# be re-exported by the Hyprland flake.
|
||||||
|
#
|
||||||
|
inputs.xdph.overlays.default
|
||||||
|
# Provides:
|
||||||
|
# - xdg-desktop-portal-hyprland
|
||||||
|
# - hyprland-share-picker
|
||||||
|
#
|
||||||
|
# Attributes for `hyprland-extras` defined by this flake can
|
||||||
|
# go in the oberlay below.
|
||||||
|
(final: prev: {
|
||||||
|
waybar-hyprland = prev.waybar.overrideAttrs (old: {
|
||||||
|
postPatch = ''
|
||||||
|
# use hyprctl to switch workspaces
|
||||||
|
sed -i 's/zext_workspace_handle_v1_activate(workspace_handle_);/const std::string command = "hyprctl dispatch workspace " + name_;\n\tsystem(command.c_str());/g' src/modules/wlr/workspace_manager.cpp
|
||||||
|
'';
|
||||||
|
mesonFlags = old.mesonFlags ++ ["-Dexperimental=true"];
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# Patched version of wlroots for Hyprland.
|
||||||
|
# It is under a new package name so as to not conflict with
|
||||||
|
# the standard version in nixpkgs.
|
||||||
|
wlroots-hyprland = final: prev: {
|
||||||
|
wlroots-hyprland = final.callPackage ./wlroots.nix {
|
||||||
|
version =
|
||||||
|
mkDate (inputs.wlroots.lastModifiedDate or "19700101")
|
||||||
|
+ "_"
|
||||||
|
+ (inputs.wlroots.shortRev or "dirty");
|
||||||
|
src = inputs.wlroots;
|
||||||
|
libdisplay-info = prev.libdisplay-info.overrideAttrs (old: {
|
||||||
|
version = "0.1.1+date=2023-03-02";
|
||||||
|
src = final.fetchFromGitLab {
|
||||||
|
domain = "gitlab.freedesktop.org";
|
||||||
|
owner = "emersion";
|
||||||
|
repo = old.pname;
|
||||||
|
rev = "147d6611a64a6ab04611b923e30efacaca6fc678";
|
||||||
|
sha256 = "sha256-/q79o13Zvu7x02SBGu0W5yQznQ+p7ltZ9L6cMW5t/o4=";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
libliftoff = prev.libliftoff.overrideAttrs (old: {
|
||||||
|
version = "0.5.0-dev";
|
||||||
|
src = final.fetchFromGitLab {
|
||||||
|
domain = "gitlab.freedesktop.org";
|
||||||
|
owner = "emersion";
|
||||||
|
repo = old.pname;
|
||||||
|
rev = "d98ae243280074b0ba44bff92215ae8d785658c0";
|
||||||
|
sha256 = "sha256-DjwlS8rXE7srs7A8+tHqXyUsFGtucYSeq6X0T/pVOc8=";
|
||||||
|
};
|
||||||
|
|
||||||
|
NIX_CFLAGS_COMPILE = toString ["-Wno-error=sign-conversion"];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Temporary override for latest wayland version. May be useless in the future.
|
||||||
|
wayland-latest = final: prev: {
|
||||||
|
wayland = prev.wayland.overrideAttrs (old: rec {
|
||||||
|
version = "1.22.0";
|
||||||
|
src = final.fetchurl {
|
||||||
|
url = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/${version}/downloads/${old.pname}-${version}.tar.xz";
|
||||||
|
hash = "sha256-FUCvHqaYpHHC2OnSiDMsfg/TYMjx0Sk267fny8JCWEI=";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue