Skip to content
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: add XWayland hidpi option #591

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/nix-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ jobs:
nix:
name: "Build Hyprland (Nix)"
runs-on: ubuntu-latest
strategy:
matrix:
package:
- default
- hyprland-no-hidpi
steps:
- name: Clone repository
uses: actions/checkout@v3
Expand All @@ -22,4 +27,4 @@ jobs:
name: hyprland
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build Hyprland with default settings
run: nix build --print-build-logs
run: nix build .#${{ matrix.package }} --print-build-logs
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
version = mkDate (inputs.wlroots.lastModifiedDate or "19700101");
src = inputs.wlroots;
});

hyprland = prev.callPackage ./nix/default.nix {
stdenv = prev.gcc12Stdenv;
version = "0.11.1beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
wlroots = wlroots-hyprland;
};
hyprland-debug = hyprland.override {debug = true;};
hyprland-no-hidpi = hyprland.override {hidpiXWayland = false;};

waybar-hyprland = prev.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
});
Expand Down
137 changes: 74 additions & 63 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
pkg-config,
meson,
ninja,
Expand All @@ -21,78 +22,88 @@
xwayland,
debug ? false,
enableXWayland ? true,
hidpiXWayland ? true,
legacyRenderer ? false,
version ? "git",
}:
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug";
inherit version;
}: let
assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) ''
Hyprland: cannot have hidpiXWayland when enableXWayland is false.
'';
in
assert assertXWayland;
stdenv.mkDerivation {
pname = "hyprland" + lib.optionalString debug "-debug";
inherit version;

src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (
lib.hasSuffix ".nix" baseName
);
src = lib.cleanSource ../.;
};
src = lib.cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (
lib.hasSuffix ".nix" baseName
);
src = lib.cleanSource ../.;
};

nativeBuildInputs = [
meson
ninja
pkg-config
];
nativeBuildInputs = [
meson
ninja
pkg-config
];

outputs = [
"out"
"man"
];
outputs = [
"out"
"man"
];

buildInputs =
[
git
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland
wayland-protocols
wayland-scanner
(wlroots.override {inherit enableXWayland;})
xcbutilwm
]
++ lib.optional enableXWayland xwayland;
buildInputs =
[
git
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland
wayland-protocols
wayland-scanner
(
if hidpiXWayland
then (import ./hidpi_wlroots.nix {inherit wlroots xwayland fetchpatch;})
else wlroots.override {inherit enableXWayland;}
)
xcbutilwm
]
++ lib.optional enableXWayland xwayland;

mesonBuildType =
if debug
then "debug"
else "release";
mesonBuildType =
if debug
then "debug"
else "release";

mesonFlags = builtins.concatLists [
(lib.optional (!enableXWayland) "-Dxwayland=disabled")
(lib.optional legacyRenderer "-DLEGACY_RENDERER:STRING=true")
];
mesonFlags = builtins.concatLists [
(lib.optional (!enableXWayland) "-Dxwayland=disabled")
(lib.optional legacyRenderer "-DLEGACY_RENDERER:STRING=true")
];

patches = [
# make meson use the provided wlroots instead of the git submodule
./meson-build.patch
];
patches = [
# make meson use the provided wlroots instead of the git submodule
./meson-build.patch
];

# Fix hardcoded paths to /usr installation
postPatch = ''
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
'';
# Fix hardcoded paths to /usr installation
postPatch = ''
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
'';

passthru.providedSessions = ["hyprland"];
passthru.providedSessions = ["hyprland"];

meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
mainProgram = "Hyprland";
};
}
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description = "A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
mainProgram = "Hyprland";
};
}
31 changes: 31 additions & 0 deletions nix/hidpi_wlroots.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
wlroots,
xwayland,
fetchpatch,
}:
(wlroots.overrideAttrs
(old: {
patches =
(old.patches or [])
++ [
(fetchpatch {
url = "https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7.diff";
sha256 = "sha256-Eo1pTa/PIiJsRZwIUnHGTIFFIedzODVf0ZeuXb0a3TQ=";
})
(fetchpatch {
url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff";
sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI=";
revert = true;
})
];
}))
.override {
xwayland = xwayland.overrideAttrs (old: {
patches =
(old.patches or [])
++ [
./xwayland-vsync.patch
./xwayland-hidpi.patch
];
});
}
42 changes: 30 additions & 12 deletions nix/hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ self: {
}: let
cfg = config.wayland.windowManager.hyprland;
defaultHyprlandPackage = self.packages.${pkgs.system}.default.override {
enableXWayland = cfg.xwayland;
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
};
in {
options.wayland.windowManager.hyprland = {
Expand Down Expand Up @@ -41,12 +42,21 @@ in {
</itemizedlist>
'';
};
xwayland = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable xwayland.
'';
xwayland = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable XWayland.
'';
};
hidpi = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable HiDPI XWayland.
'';
};
};

extraConfig = lib.mkOption {
Expand All @@ -56,20 +66,28 @@ in {
Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
'';
};

imports = [
(
lib.mkRenamedOptionModule
["wayland" "windowManager" "hyprland" "xwayland"]
["wayland" "windowManager" "hyprland" "xwayland" "enable"]
)
];
};

config = lib.mkIf cfg.enable {
home.packages =
lib.optional (cfg.package != null) cfg.package
++ lib.optional cfg.xwayland pkgs.xwayland;
++ lib.optional cfg.xwayland.enable pkgs.xwayland;

xdg.configFile."hypr/hyprland.conf" = {
text =
(lib.optionalString cfg.systemdIntegration ''
exec-once=export XDG_SESSION_TYPE=wayland
exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
exec-once=systemctl --user start hyprland-session.target
'')
exec-once=export XDG_SESSION_TYPE=wayland
exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP
exec-once=systemctl --user start hyprland-session.target
'')
+ cfg.extraConfig;

onChange = let
Expand Down
Loading