python312Packages.icontract: relax deps (#380554)
[NixPkgs.git] / pkgs / by-name / hy / hyprland / package.nix
blobeca4e58f5761b9159e9a8715daca1aac525948b1
2   lib,
3   stdenv,
4   stdenvAdapters,
5   fetchFromGitHub,
6   pkg-config,
7   makeWrapper,
8   cmake,
9   meson,
10   ninja,
11   aquamarine,
12   binutils,
13   cairo,
14   epoll-shim,
15   git,
16   glaze,
17   hyprcursor,
18   hyprgraphics,
19   hyprland-qtutils,
20   hyprlang,
21   hyprutils,
22   hyprwayland-scanner,
23   libGL,
24   libdrm,
25   libexecinfo,
26   libinput,
27   libuuid,
28   libxkbcommon,
29   libgbm,
30   pango,
31   pciutils,
32   pkgconf,
33   python3,
34   re2,
35   systemd,
36   tomlplusplus,
37   wayland,
38   wayland-protocols,
39   wayland-scanner,
40   xorg,
41   xwayland,
42   debug ? false,
43   enableXWayland ? true,
44   legacyRenderer ? false,
45   withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
46   wrapRuntimeDeps ? true,
47   # deprecated flags
48   nvidiaPatches ? false,
49   hidpiXWayland ? false,
50   enableNvidiaPatches ? false,
52 let
53   inherit (builtins)
54     foldl'
55     ;
56   inherit (lib.asserts) assertMsg;
57   inherit (lib.attrsets) mapAttrsToList;
58   inherit (lib.lists)
59     concatLists
60     optionals
61     ;
62   inherit (lib.strings)
63     makeBinPath
64     optionalString
65     mesonBool
66     mesonEnable
67     ;
68   inherit (lib.trivial)
69     importJSON
70     ;
72   info = importJSON ./info.json;
74   # possibility to add more adapters in the future, such as keepDebugInfo,
75   # which would be controlled by the `debug` flag
76   adapters = [
77     stdenvAdapters.useMoldLinker
78   ];
80   customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
82 assert assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
83 assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
84 assert assertMsg (!hidpiXWayland)
85   "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
87 customStdenv.mkDerivation (finalAttrs: {
88   pname = "hyprland" + optionalString debug "-debug";
89   version = "0.47.2";
91   src = fetchFromGitHub {
92     owner = "hyprwm";
93     repo = "hyprland";
94     fetchSubmodules = true;
95     tag = "v${finalAttrs.version}";
96     hash = "sha256-dSKR1VpjpdJVZ5dmLgIvAu3K+DYrSbohZkqxSQhjw8U=";
97   };
99   postPatch = ''
100     # Fix hardcoded paths to /usr installation
101     sed -i "s#/usr#$out#" src/render/OpenGL.cpp
103     # Remove extra @PREFIX@ to fix pkg-config paths
104     sed -i "s#@PREFIX@/##g" hyprland.pc.in
106     substituteInPlace protocols/meson.build --replace-fail \
107       "wayland_scanner = dependency('wayland-scanner')" \
108       "wayland_scanner = dependency('wayland-scanner', native: true)"
109   '';
111   # variables used by generateVersion.sh script, and shown in `hyprctl version`
112   BRANCH = info.branch;
113   COMMITS = info.commit_hash;
114   DATE = info.date;
115   DIRTY = "";
116   HASH = info.commit_hash;
117   MESSAGE = info.commit_message;
118   TAG = info.tag;
120   depsBuildBuild = [
121     # to find wayland-scanner when cross-compiling
122     pkg-config
123   ];
125   nativeBuildInputs = [
126     hyprwayland-scanner
127     makeWrapper
128     meson
129     ninja
130     pkg-config
131     wayland-scanner
132     # for udis86
133     cmake
134     python3
135   ];
137   outputs = [
138     "out"
139     "man"
140     "dev"
141   ];
143   buildInputs = concatLists [
144     [
145       aquamarine
146       cairo
147       glaze
148       git
149       hyprcursor.dev
150       hyprgraphics
151       hyprlang
152       hyprutils
153       libGL
154       libdrm
155       libinput
156       libuuid
157       libxkbcommon
158       libgbm
159       pango
160       pciutils
161       re2
162       tomlplusplus
163       wayland
164       wayland-protocols
165       xorg.libXcursor
166     ]
167     (optionals customStdenv.hostPlatform.isBSD [ epoll-shim ])
168     (optionals customStdenv.hostPlatform.isMusl [ libexecinfo ])
169     (optionals enableXWayland [
170       xorg.libxcb
171       xorg.libXdmcp
172       xorg.xcbutilerrors
173       xorg.xcbutilwm
174       xwayland
175     ])
176     (optionals withSystemd [ systemd ])
177   ];
179   mesonBuildType = if debug then "debugoptimized" else "release";
181   dontStrip = debug;
182   strictDeps = true;
184   mesonFlags = concatLists [
185     (mapAttrsToList mesonEnable {
186       "xwayland" = enableXWayland;
187       "legacy_renderer" = legacyRenderer;
188       "systemd" = withSystemd;
189     })
190     (mapAttrsToList mesonBool {
191       # PCH provides no benefits when building with Nix
192       "b_pch" = false;
193       "tracy_enable" = false;
194     })
195   ];
197   postInstall = ''
198     ${optionalString wrapRuntimeDeps ''
199       wrapProgram $out/bin/Hyprland \
200         --suffix PATH : ${
201           makeBinPath [
202             binutils
203             hyprland-qtutils
204             pciutils
205             pkgconf
206           ]
207         }
208     ''}
209   '';
211   passthru = {
212     providedSessions = [ "hyprland" ];
213     updateScript = ./update.sh;
214   };
216   meta = {
217     homepage = "https://github.com/hyprwm/Hyprland";
218     description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
219     license = lib.licenses.bsd3;
220     maintainers = lib.teams.hyprland.members;
221     mainProgram = "Hyprland";
222     platforms = lib.platforms.linux ++ lib.platforms.freebsd;
223   };