From 857ea436946745c6077790fa62d3b7a171b58551 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Sun, 8 May 2022 21:57:40 +0530 Subject: [PATCH 1/5] add flake.nix and other required files for nix build --- .gitignore | 3 +- default.nix | 42 ++++++++++ flake.lock | 162 ++++++++++++++++++++++++++++++++++++ flake.nix | 30 +++++++ nix-build/default.nix | 42 ++++++++++ nix-build/fix-makefile.diff | 36 ++++++++ 6 files changed, 314 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix-build/default.nix create mode 100644 nix-build/fix-makefile.diff diff --git a/.gitignore b/.gitignore index f45eb5bbb..7beae6427 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ CTestTestfile.cmake _deps build/ +result/ /.vscode/ *.o @@ -17,4 +18,4 @@ build/ *-protocol.h .ccls-cache -hyprctl/hyprctl \ No newline at end of file +hyprctl/hyprctl diff --git a/default.nix b/default.nix new file mode 100644 index 000000000..42a8191d4 --- /dev/null +++ b/default.nix @@ -0,0 +1,42 @@ +{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm +, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols +, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }: + +stdenv.mkDerivation { + pname = "hyprland"; + inherit src version; + + nativeBuildInputs = [ cmake ninja pkg-config wayland ] + ++ lib.optional xwaylandSupport xwayland; + + buildInputs = [ + libdrm + libinput + libxcb + libxkbcommon + mesa + pango + wayland-protocols + wayland-scanner + wlroots + xcbutilwm + ]; + + dontBuild = true; + dontInstall = true; + + patches = [ ./fix-makefile.diff ]; + + postPatch = '' + mkdir -p $out/bin + make install PREFIX=$out + ''; + + 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; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..de779e0be --- /dev/null +++ b/flake.lock @@ -0,0 +1,162 @@ +{ + "nodes": { + "cachix": { + "locked": { + "lastModified": 1651865313, + "narHash": "sha256-fLnmcBaVpJukNIzXZETxtJKLSSTf4LnBCWa/DwyGJBU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ad667404474314806d8071eec4c8ec0db95c17e4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-21.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "lib-aggregate": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1652011770, + "narHash": "sha256-ZX+aDa9db1lNbLI44KK0EjTV2X6gyIqpcuN9RUCy9iI=", + "owner": "nix-community", + "repo": "lib-aggregate", + "rev": "89056ca8a9c74ea4440dc53bebcd9c74fc0e1f15", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "lib-aggregate", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1651927509, + "narHash": "sha256-fGVGUdEsriuAL1vkUh29FlOQmEkPRnSfRGImWYaVjos=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1651970744, + "narHash": "sha256-3X/96C8I5alTCP0FHEx01/YOIvVmjkYoUPX/1Y4Bdsw=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "da23418cffc1763e30dba3383eac541afe3e4e70", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-wayland": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat", + "lib-aggregate": "lib-aggregate", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1652015544, + "narHash": "sha256-YFjSavZSf6NZFRt2QB5mBccPYd8wrJGKHVH9p75vZtM=", + "owner": "nix-community", + "repo": "nixpkgs-wayland", + "rev": "2d9bc7f3261cc1c2a46d121f94ed483f35d194c2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs-wayland", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1651726670, + "narHash": "sha256-dSGdzB49SEvdOJvrQWfQYkAefewXraHIV08Vz6iDXWQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c777cdf5c564015d5f63b09cc93bef4178b19b01", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-wayland": "nixpkgs-wayland", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..39a761796 --- /dev/null +++ b/flake.nix @@ -0,0 +1,30 @@ +# Based on fortuneteller2k's (https://github.com/fortuneteller2k/nixpkgs-f2k) package repo +{ + description = + "Hyprland is a dynamic tiling Wayland compositor that doesn't sacrifice on its looks."; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland"; + }; + + outputs = { self, nixpkgs, utils, nixpkgs-wayland }: + utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = "git"; + in rec { + packages = { + hyprland = pkgs.callPackage ./nix-build { + inherit version; + src = self; + inherit (nixpkgs-wayland.packages.${system}) wlroots; + }; + }; + defaultPackage = packages.hyprland; + apps.hyprland = utils.lib.mkApp { drv = packages.hyprland; }; + defaultApp = apps.hyprland; + apps.default = + utils.lib.mkApp { drv = self.packages."${system}".default; }; + }); +} diff --git a/nix-build/default.nix b/nix-build/default.nix new file mode 100644 index 000000000..42a8191d4 --- /dev/null +++ b/nix-build/default.nix @@ -0,0 +1,42 @@ +{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm +, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols +, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }: + +stdenv.mkDerivation { + pname = "hyprland"; + inherit src version; + + nativeBuildInputs = [ cmake ninja pkg-config wayland ] + ++ lib.optional xwaylandSupport xwayland; + + buildInputs = [ + libdrm + libinput + libxcb + libxkbcommon + mesa + pango + wayland-protocols + wayland-scanner + wlroots + xcbutilwm + ]; + + dontBuild = true; + dontInstall = true; + + patches = [ ./fix-makefile.diff ]; + + postPatch = '' + mkdir -p $out/bin + make install PREFIX=$out + ''; + + 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; + }; +} diff --git a/nix-build/fix-makefile.diff b/nix-build/fix-makefile.diff new file mode 100644 index 000000000..036dafad0 --- /dev/null +++ b/nix-build/fix-makefile.diff @@ -0,0 +1,36 @@ +diff --git a/Makefile b/Makefile +index bcf3a10..0a5b335 100644 +--- a/Makefile ++++ b/Makefile +@@ -97,14 +97,14 @@ all: + + install: + make all +- mkdir -p /usr/share/wayland-sessions +- cp ./example/hyprland.desktop /usr/share/wayland-sessions/ +- cp ./build/Hyprland /usr/bin +- cp ./hyprctl/hyprctl /usr/bin +- mkdir -p /usr/share/hyprland +- cp ./assets/wall_2K.png /usr/share/hyprland +- cp ./assets/wall_4K.png /usr/share/hyprland +- cp ./assets/wall_8K.png /usr/share/hyprland ++ mkdir -p $(PREFIX)/share/wayland-sessions ++ cp ./example/hyprland.desktop $(PREFIX)/share/wayland-sessions/ ++ cp ./build/Hyprland $(PREFIX)/bin ++ cp ./hyprctl/hyprctl $(PREFIX)/bin ++ mkdir -p $(PREFIX)/share/hyprland ++ cp ./assets/wall_2K.png $(PREFIX)/share/hyprland ++ cp ./assets/wall_4K.png $(PREFIX)/share/hyprland ++ cp ./assets/wall_8K.png $(PREFIX)/share/hyprland + + uninstall: + rm -f /usr/share/wayland-sessions/hyprland.desktop +diff --git a/config.mk b/config.mk +index 91aca81..c40930e 100644 +--- a/config.mk ++++ b/config.mk +@@ -1,4 +1,4 @@ +-PREFIX = /usr/local ++PREFIX = @out@ + CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement + CFLAGS += -DXWAYLAND From aca5dba7a12ce7511c3dba03c5fa5c0f7e160409 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Sun, 8 May 2022 22:22:02 +0530 Subject: [PATCH 2/5] make changes to makefile a bit so it follows config.mk --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index bcf3a10c8..ce5e53f36 100644 --- a/Makefile +++ b/Makefile @@ -98,18 +98,18 @@ all: install: make all mkdir -p /usr/share/wayland-sessions - cp ./example/hyprland.desktop /usr/share/wayland-sessions/ - cp ./build/Hyprland /usr/bin - cp ./hyprctl/hyprctl /usr/bin - mkdir -p /usr/share/hyprland - cp ./assets/wall_2K.png /usr/share/hyprland - cp ./assets/wall_4K.png /usr/share/hyprland - cp ./assets/wall_8K.png /usr/share/hyprland + cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions/ + cp ./build/Hyprland ${PREFIX}/bin + cp ./hyprctl/hyprctl ${PREFIX}/bin + mkdir -p ${PREFIX}/share/hyprland + cp ./assets/wall_2K.png ${PREFIX}/share/hyprland + cp ./assets/wall_4K.png ${PREFIX}/share/hyprland + cp ./assets/wall_8K.png ${PREFIX}/share/hyprland uninstall: - rm -f /usr/share/wayland-sessions/hyprland.desktop - rm -f /usr/bin/Hyprland - rm -f /usr/bin/hyprctl - rm -rf /usr/share/hyprland + rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop + rm -f ${PREFIX}/bin/Hyprland + rm -f ${PREFIX}/bin/hyprctl + rm -rf ${PREFIX}/share/hyprland config: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o wlr-screencopy-unstable-v1-protocol.o idle-protocol.o ext-workspace-unstable-v1-protocol.o pointer-constraints-unstable-v1-protocol.o From 2342b6a10f1f7d238e60a4ff1c33a0ab0dee0e39 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Sun, 8 May 2022 22:53:49 +0530 Subject: [PATCH 3/5] remove patch and move default.nix --- .gitignore | 2 +- Makefile | 2 +- default.nix | 3 --- flake.nix | 2 +- nix-build/default.nix | 42 ------------------------------------- nix-build/fix-makefile.diff | 36 ------------------------------- 6 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 nix-build/default.nix delete mode 100644 nix-build/fix-makefile.diff diff --git a/.gitignore b/.gitignore index 7beae6427..d24d0e6db 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ CTestTestfile.cmake _deps build/ -result/ +result /.vscode/ *.o diff --git a/Makefile b/Makefile index ce5e53f36..0d04bd8f3 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ all: install: make all - mkdir -p /usr/share/wayland-sessions + mkdir -p ${PREFIX}/share/wayland-sessions cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions/ cp ./build/Hyprland ${PREFIX}/bin cp ./hyprctl/hyprctl ${PREFIX}/bin diff --git a/default.nix b/default.nix index 42a8191d4..b958c3e21 100644 --- a/default.nix +++ b/default.nix @@ -25,10 +25,7 @@ stdenv.mkDerivation { dontBuild = true; dontInstall = true; - patches = [ ./fix-makefile.diff ]; - postPatch = '' - mkdir -p $out/bin make install PREFIX=$out ''; diff --git a/flake.nix b/flake.nix index 39a761796..b8a461ba2 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ version = "git"; in rec { packages = { - hyprland = pkgs.callPackage ./nix-build { + hyprland = pkgs.callPackage self { inherit version; src = self; inherit (nixpkgs-wayland.packages.${system}) wlroots; diff --git a/nix-build/default.nix b/nix-build/default.nix deleted file mode 100644 index 42a8191d4..000000000 --- a/nix-build/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm -, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols -, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }: - -stdenv.mkDerivation { - pname = "hyprland"; - inherit src version; - - nativeBuildInputs = [ cmake ninja pkg-config wayland ] - ++ lib.optional xwaylandSupport xwayland; - - buildInputs = [ - libdrm - libinput - libxcb - libxkbcommon - mesa - pango - wayland-protocols - wayland-scanner - wlroots - xcbutilwm - ]; - - dontBuild = true; - dontInstall = true; - - patches = [ ./fix-makefile.diff ]; - - postPatch = '' - mkdir -p $out/bin - make install PREFIX=$out - ''; - - 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; - }; -} diff --git a/nix-build/fix-makefile.diff b/nix-build/fix-makefile.diff deleted file mode 100644 index 036dafad0..000000000 --- a/nix-build/fix-makefile.diff +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/Makefile b/Makefile -index bcf3a10..0a5b335 100644 ---- a/Makefile -+++ b/Makefile -@@ -97,14 +97,14 @@ all: - - install: - make all -- mkdir -p /usr/share/wayland-sessions -- cp ./example/hyprland.desktop /usr/share/wayland-sessions/ -- cp ./build/Hyprland /usr/bin -- cp ./hyprctl/hyprctl /usr/bin -- mkdir -p /usr/share/hyprland -- cp ./assets/wall_2K.png /usr/share/hyprland -- cp ./assets/wall_4K.png /usr/share/hyprland -- cp ./assets/wall_8K.png /usr/share/hyprland -+ mkdir -p $(PREFIX)/share/wayland-sessions -+ cp ./example/hyprland.desktop $(PREFIX)/share/wayland-sessions/ -+ cp ./build/Hyprland $(PREFIX)/bin -+ cp ./hyprctl/hyprctl $(PREFIX)/bin -+ mkdir -p $(PREFIX)/share/hyprland -+ cp ./assets/wall_2K.png $(PREFIX)/share/hyprland -+ cp ./assets/wall_4K.png $(PREFIX)/share/hyprland -+ cp ./assets/wall_8K.png $(PREFIX)/share/hyprland - - uninstall: - rm -f /usr/share/wayland-sessions/hyprland.desktop -diff --git a/config.mk b/config.mk -index 91aca81..c40930e 100644 ---- a/config.mk -+++ b/config.mk -@@ -1,4 +1,4 @@ --PREFIX = /usr/local -+PREFIX = @out@ - CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement - CFLAGS += -DXWAYLAND From 7c6fc3c6ad0537888265fb2e3a4e1455d90a68d2 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Sun, 8 May 2022 23:48:13 +0530 Subject: [PATCH 4/5] add xwayland disabling support to flake.nix --- Makefile | 1 + default.nix | 42 +++++++++++++++++++++++++++++++----------- flake.nix | 5 +---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 0d04bd8f3..b185eb90a 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,7 @@ install: make all mkdir -p ${PREFIX}/share/wayland-sessions cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions/ + mkdir -p ${PREFIX}/bin cp ./build/Hyprland ${PREFIX}/bin cp ./hyprctl/hyprctl ${PREFIX}/bin mkdir -p ${PREFIX}/share/hyprland diff --git a/default.nix b/default.nix index b958c3e21..6b08017c7 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,13 @@ -{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm -, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols -, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }: +{ lib, stdenv, fetchFromGitHub, src, pkg-config, cmake, ninja, libdrm, libinput +, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols +, wayland-scanner, wlroots, xcbutilwm, xwayland, enableXWayland ? true }: -stdenv.mkDerivation { +stdenv.mkDerivation rec { pname = "hyprland"; - inherit src version; + version = "git"; + inherit src; - nativeBuildInputs = [ cmake ninja pkg-config wayland ] - ++ lib.optional xwaylandSupport xwayland; + nativeBuildInputs = [ cmake ninja pkg-config wayland xwayland ]; buildInputs = [ libdrm @@ -19,14 +19,34 @@ stdenv.mkDerivation { wayland-protocols wayland-scanner wlroots + (wlroots.override { inherit enableXWayland; }) xcbutilwm ]; - dontBuild = true; - dontInstall = true; + cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" ] + ++ lib.optional (!enableXWayland) "-DNO_XWAYLAND=true"; - postPatch = '' - make install PREFIX=$out + prePatch = '' + make config + ''; + + postBuild = '' + pushd ../hyprctl + make all + popd + ''; + + installPhase = '' + cd ../ + mkdir -p $out/share/wayland-sessions + cp ./example/hyprland.desktop $out/share/wayland-sessions/ + mkdir -p $out/bin + cp ./build/Hyprland $out/bin + cp ./hyprctl/hyprctl $out/bin + mkdir -p $out/share/hyprland + cp ./assets/wall_2K.png $out/share/hyprland + cp ./assets/wall_4K.png $out/share/hyprland + cp ./assets/wall_8K.png $out/share/hyprland ''; meta = with lib; { diff --git a/flake.nix b/flake.nix index b8a461ba2..002bf09bd 100644 --- a/flake.nix +++ b/flake.nix @@ -10,13 +10,10 @@ outputs = { self, nixpkgs, utils, nixpkgs-wayland }: utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - version = "git"; + let pkgs = nixpkgs.legacyPackages.${system}; in rec { packages = { hyprland = pkgs.callPackage self { - inherit version; src = self; inherit (nixpkgs-wayland.packages.${system}) wlroots; }; From dc6702ea58ad73ef87037e9f442cad10e4ad55e9 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Mon, 9 May 2022 00:37:41 +0530 Subject: [PATCH 5/5] small fix for nativebuildinputs --- default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 6b08017c7..e15f9174f 100644 --- a/default.nix +++ b/default.nix @@ -7,7 +7,8 @@ stdenv.mkDerivation rec { version = "git"; inherit src; - nativeBuildInputs = [ cmake ninja pkg-config wayland xwayland ]; + nativeBuildInputs = [ cmake ninja pkg-config wayland ] + ++ lib.optional enableXWayland xwayland; buildInputs = [ libdrm