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