Nix: use mold linker

This commit is contained in:
Mihai Fufezan 2024-09-19 18:53:34 +03:00
parent dfa1bd0cd4
commit 9856378384
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
stdenv, stdenv,
stdenvAdapters,
pkg-config, pkg-config,
pkgconf, pkgconf,
makeWrapper, makeWrapper,
@ -46,130 +47,136 @@
enableNvidiaPatches ? false, enableNvidiaPatches ? false,
nvidiaPatches ? false, nvidiaPatches ? false,
hidpiXWayland ? false, hidpiXWayland ? false,
}: }: let
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed."; adapters = lib.flatten [
assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed."; stdenvAdapters.useMoldLinker
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland"; ];
stdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}";
inherit version;
src = lib.cleanSourceWith { customStdenv = builtins.foldl' (acc: adapter: adapter acc) stdenv adapters;
filter = name: type: let in
baseName = baseNameOf (toString name); assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
in assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
! (lib.hasSuffix ".nix" baseName); assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
src = lib.cleanSource ../.; customStdenv.mkDerivation {
}; pname = "hyprland${lib.optionalString debug "-debug"}";
inherit version;
postPatch = '' src = lib.cleanSourceWith {
# Fix hardcoded paths to /usr installation filter = name: type: let
sed -i "s#/usr#$out#" src/render/OpenGL.cpp baseName = baseNameOf (toString name);
in
! (lib.hasSuffix ".nix" baseName);
src = lib.cleanSource ../.;
};
# Remove extra @PREFIX@ to fix pkg-config paths postPatch = ''
sed -i "s#@PREFIX@/##g" hyprland.pc.in # Fix hardcoded paths to /usr installation
''; sed -i "s#/usr#$out#" src/render/OpenGL.cpp
COMMITS = revCount; # Remove extra @PREFIX@ to fix pkg-config paths
DATE = date; sed -i "s#@PREFIX@/##g" hyprland.pc.in
DIRTY = lib.optionalString (commit == "") "dirty"; '';
HASH = commit;
depsBuildBuild = [ COMMITS = revCount;
pkg-config DATE = date;
]; DIRTY = lib.optionalString (commit == "") "dirty";
HASH = commit;
nativeBuildInputs = [ depsBuildBuild = [
hyprwayland-scanner pkg-config
jq ];
makeWrapper
meson
cmake
ninja
pkg-config
python3 # for udis86
wayland-scanner
];
outputs = [ nativeBuildInputs = [
"out" hyprwayland-scanner
"man" jq
"dev" makeWrapper
]; meson
cmake
ninja
pkg-config
python3 # for udis86
wayland-scanner
];
buildInputs = lib.concatLists [ outputs = [
[ "out"
aquamarine "man"
cairo "dev"
# expat ];
# fribidi
git
hyprcursor
hyprlang
hyprutils
# libdatrie
libdrm
libGL
libinput
# libselinux
# libsepol
# libthai
libuuid
libxkbcommon
mesa
pango
pciutils
# pcre2
tomlplusplus
wayland
wayland-protocols
xorg.libXcursor
]
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutilerrors
xorg.xcbutilrenderutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
];
mesonBuildType = buildInputs = lib.concatLists [
if debug [
then "debug" aquamarine
else "release"; cairo
# expat
# we want as much debug info as possible # fribidi
dontStrip = debug; git
hyprcursor
mesonFlags = [ hyprlang
(lib.mesonEnable "xwayland" enableXWayland) hyprutils
(lib.mesonEnable "legacy_renderer" legacyRenderer) # libdatrie
(lib.mesonEnable "systemd" withSystemd) libdrm
"-Db_pch=false" libGL
]; libinput
# libselinux
postInstall = '' # libsepol
${lib.optionalString wrapRuntimeDeps '' # libthai
wrapProgram $out/bin/Hyprland \ libuuid
--suffix PATH : ${lib.makeBinPath [ libxkbcommon
binutils mesa
pango
pciutils pciutils
pkgconf # pcre2
]} tomlplusplus
''} wayland
''; wayland-protocols
xorg.libXcursor
]
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutilerrors
xorg.xcbutilrenderutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
];
passthru.providedSessions = ["hyprland"]; mesonBuildType =
if debug
then "debug"
else "release";
meta = { # we want as much debug info as possible
homepage = "https://github.com/hyprwm/Hyprland"; dontStrip = debug;
description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = lib.licenses.bsd3; mesonFlags = [
platforms = lib.platforms.linux; (lib.mesonEnable "xwayland" enableXWayland)
mainProgram = "Hyprland"; (lib.mesonEnable "legacy_renderer" legacyRenderer)
}; (lib.mesonEnable "systemd" withSystemd)
} "-Db_pch=false"
];
postInstall = ''
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [
binutils
pciutils
pkgconf
]}
''}
'';
passthru.providedSessions = ["hyprland"];
meta = {
homepage = "https://github.com/hyprwm/Hyprland";
description = "Dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "Hyprland";
};
}