NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.46k stars 13.66k forks source link

Hyprland compositor / wayland window manager #168392

Closed Ashe closed 2 years ago

Ashe commented 2 years ago

Project description

Hyprland is a Dynamic Tiling Wayland Compositor in early development stages.

It recently received a lot of attention on reddit as a fresh window manager for wayland (video can be found here).

It would be quite nice to have it as a package so that we can experience it's development and provide feedback!

Metadata

fedoranvar commented 2 years ago

was able to build it on my local machine

will leave derivation file,, (lately will edit it)

{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, ninja
, cmake
, wayland
, wayland-protocols
, cairo
, glm
, libevdev
, freetype
, libinput
, pixman
, libxkbcommon
, libdrm
, libjpeg
, libpng
, libGL
, mesa
, libcap

, xcbutilerrors
, xcbutilwm

, libxml2
, libuuid
, seatd
, xorg
, xwayland
, doctest
, pango
, vulkan-headers
, vulkan-loader
, glslang
, buildDocs ? true
, my
, unstable
, pkgs
}:

let
  metadata = import ./metadata.nix;
in
stdenv.mkDerivation rec {
  pname = "hyprland";
  version = metadata.rev;
  name = "${pname}-${version}";

  src = fetchFromGitHub {
    owner = "vaxerski";
    repo = "Hyprland";
    rev = version;
    sha256 = metadata.sha256;
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    pkg-config
    ninja
    cmake
    doctest
  ];
  buildInputs = [
    xorg.xcbutilerrors
    xorg.xcbutilwm
    xorg.xcbutilrenderutil
    xorg.libX11.dev
    xorg.libXft
    xorg.xcbutil
    xorg.libXfixes
    wayland
    wayland-protocols
    cairo
    glm
    libevdev
    freetype
    libinput
    pixman
    libxkbcommon
    libdrm
    libjpeg
    libpng
    libGL
    mesa
    libcap
    libxml2
    libuuid
    seatd
    xwayland
    doctest
    pango
    vulkan-headers
    vulkan-loader
    glslang
    my.wlroots
    unstable.wlr-protocols
    # my.wlr-protocols
  ];

  patches = [ ./build.patch ];

  buildPhase = "
    make config
    # make release
    make legacyrenderer
    cd ./hyprctl && make all && cd ..
  ";
  installPhase = "
    mkdir -p $out/bin
    cp ./build/Hyprland $out/bin
    cp ./hyprctl/hyprctl $out/bin
  ";

  hardeningDisable = [ "all" ];

  dontUseCmakeConfigure = true;
  # mesonBuildType = "release";
  enableParallelBuilding = true;

  meta = with lib; {
    description = "3D wayland compositor";
    homepage = "https://wayfire.org/";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ colemickens ];
  };
}
Ashe commented 2 years ago

Thank you for your hard work :) are you going to consider submitting it as a package?

wozeparrot commented 2 years ago

I also did an attempt at building it. Had to work around the makefile a bit, and it also requires wlroots git.

{ lib
, stdenv
, fetchFromGitHub
, cmake
, pkg-config
, libdrm
, libinput
, libxcb
, libxkbcommon
, mesa
, pango
, wayland
, wayland-protocols
, wlroots
}:

stdenv.mkDerivation rec {
  pname = "hyprland";
  version = "unstable-12-04-2022";

  src = fetchFromGitHub {
    owner = "vaxerski";
    repo = pname;
    rev = "277b899e0e6a619a3d20a7bde2ad4c6a5ae43989";
    sha256 = "sha256-VYwEGqtZgL4rM3h0XF889IgOA2KONanerUi2XSQ6YoM=";
  };

  nativeBuildInputs = [
    cmake
    pkg-config

    wayland
  ];

  buildInputs = [
    libdrm
    libinput
    libxcb
    libxkbcommon
    mesa
    pango
    wayland-protocols
    wlroots
  ];

  postPatch = ''
    make config
  '';

  postBuild = ''
    pushd ../hyprctl
    g++ -std=c++20 -w ./main.cpp -o ./hyprctl
    popd
  '';

  installPhase = ''
    mkdir -p $out/bin
    install Hyprland $out/bin
    install -m755 ../hyprctl/hyprctl $out/bin
  '';

  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;
    maintainers = with maintainers; [ wozeparrot ];
  };
}
fedoranvar commented 2 years ago

@Ashe yes, i'm planning to

@wozeparrot i'm using git wlroots (by building derivation on my machine). but maybe it will work with unstable.

with recent Hyprland-master, no patches needed,
lately will try to push PR (that's my first time, so i don't know how long it will take)

wozeparrot commented 2 years ago

master only has wlroots 0.15.1 which does not work with Hyprland as it requires wlroots git. So you would also have to package wlroots git.

selastingeorge commented 2 years ago

building wlroots is totally a mess, it requires many packages. most of the time my system end up in a boot loop or any other issue. since wlroots current development (0.16.0) version requires latest packages, i use Debian Sid repository to obtain the packages. so i created a bash script to automate installation of all the dependencies for building wlroots. i tried running script today, and the build succeed.

warning : Use at your own risk

sudo apt update
sudo apt install -y git
sudo apt install -y libwacom-common
sudo apt install -y libwacom2
sudo apt install -y libinput-dev

sudo apt install -y software-properties-common debian-archive-keyring dirmngr
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 648ACFD622F3D138
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0E98404D386FA1D9
sudo add-apt-repository "deb http://ftp.de.debian.org/debian sid main"
sudo apt update

sudo apt install -y python3 python3-pip cmake
sudo pip3 install meson
sudo pip3 install ninja

sudo apt install -y libegl-dev libgles2-mesa-dev libxcb-render-util0-dev libxcb-icccm4-dev libpng-dev libxcb-shm0-dev

sudo apt-get install -y libwayland-dev libxkbcommon-dev libdrm-dev libegl-mesa0 libgbm-dev libudev-dev libpixman-1-dev wayland-protocols libseat-dev libxcb-dri3-dev libxcb-present-dev libxcb-xinput-dev libvulkan-dev glslang-tools

git clone https://git.sr.ht/~kennylevinsen/seatd
cd seatd
meson build
ninja -C build install

sudo apt install -y libavutil-dev libavcodec-dev libavformat-dev

sudo apt install -y libxcb-composite0-dev libxcb-res0-dev xwayland

sudo apt install -y autoconf
sudo apt install -y xutils-dev
sudo apt install -y libtool
sudo apt install -y xcb-proto

git clone https://gitlab.freedesktop.org/xorg/lib/libxcb-errors.git
cd libxcb-errors
git submodule update --init
./autogen.sh
sudo make install
cd ..

echo "Installation Completed successfully :)"

Don't forget to remove Sid repo once installation is completed.

wozeparrot commented 2 years ago

On nix it was pretty simple for me to build wlroots-git, just take the 0.15 wlroots nix derivation, copy it, change the commit and hash and it just built.

selastingeorge commented 2 years ago

On Ubuntu, it was a headache. In nix all the wlroots dependencies were already installed.

wozeparrot commented 2 years ago

I do have hyprland packaged in nixpkgs here: https://github.com/wozeparrot/nixpkgs/tree/hyprland. I don't know if @fedoranvar still wants to continue with their packaging, cuz if not I'll just make a pr.

fedoranvar commented 2 years ago

@wozeparrot it'll be good if you'll make a PR