Nix: clean up derivation

This commit is contained in:
Mihai Fufezan 2024-09-21 14:27:13 +03:00
parent 9232bc2c00
commit 8579066c7a
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg

View file

@ -48,25 +48,32 @@
nvidiaPatches ? false, nvidiaPatches ? false,
hidpiXWayland ? false, hidpiXWayland ? false,
}: let }: let
adapters = lib.flatten [ inherit (builtins) baseNameOf foldl';
inherit (lib.asserts) assertMsg;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten concatLists optional optionals;
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix makeBinPath optionalString mesonBool mesonEnable;
adapters = flatten [
stdenvAdapters.useMoldLinker stdenvAdapters.useMoldLinker
]; ];
customStdenv = builtins.foldl' (acc: adapter: adapter acc) stdenv adapters; customStdenv = foldl' (acc: adapter: adapter acc) stdenv adapters;
in in
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed."; assert assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert lib.assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed."; assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert lib.assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland"; assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
customStdenv.mkDerivation { customStdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}"; pname = "hyprland${optionalString debug "-debug"}";
inherit version; inherit version;
src = lib.cleanSourceWith { src = cleanSourceWith {
filter = name: type: let filter = name: type: let
baseName = baseNameOf (toString name); baseName = baseNameOf (toString name);
in in
! (lib.hasSuffix ".nix" baseName); ! (hasSuffix ".nix" baseName);
src = lib.cleanSource ../.; src = cleanSource ../.;
}; };
postPatch = '' postPatch = ''
@ -79,7 +86,7 @@ in
COMMITS = revCount; COMMITS = revCount;
DATE = date; DATE = date;
DIRTY = lib.optionalString (commit == "") "dirty"; DIRTY = optionalString (commit == "") "dirty";
HASH = commit; HASH = commit;
depsBuildBuild = [ depsBuildBuild = [
@ -104,36 +111,29 @@ in
"dev" "dev"
]; ];
buildInputs = lib.concatLists [ buildInputs = concatLists [
[ [
aquamarine aquamarine
cairo cairo
# expat
# fribidi
git git
hyprcursor hyprcursor
hyprlang hyprlang
hyprutils hyprutils
# libdatrie
libdrm libdrm
libGL libGL
libinput libinput
# libselinux
# libsepol
# libthai
libuuid libuuid
libxkbcommon libxkbcommon
mesa mesa
pango pango
pciutils pciutils
# pcre2
tomlplusplus tomlplusplus
wayland wayland
wayland-protocols wayland-protocols
xorg.libXcursor xorg.libXcursor
] ]
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo]) (optionals customStdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [ (optionals enableXWayland [
xorg.libxcb xorg.libxcb
xorg.libXdmcp xorg.libXdmcp
xorg.xcbutilerrors xorg.xcbutilerrors
@ -141,7 +141,7 @@ in
xorg.xcbutilwm xorg.xcbutilwm
xwayland xwayland
]) ])
(lib.optionals withSystemd [systemd]) (optional withSystemd systemd)
]; ];
mesonBuildType = mesonBuildType =
@ -152,17 +152,19 @@ in
# we want as much debug info as possible # we want as much debug info as possible
dontStrip = debug; dontStrip = debug;
mesonFlags = [ mesonFlags = flatten [
(lib.mesonEnable "xwayland" enableXWayland) (mapAttrsToList mesonEnable {
(lib.mesonEnable "legacy_renderer" legacyRenderer) "xwayland" = enableXWayland;
(lib.mesonEnable "systemd" withSystemd) "legacy_renderer" = legacyRenderer;
"-Db_pch=false" "systemd" = withSystemd;
})
(mesonBool "b_pch" false)
]; ];
postInstall = '' postInstall = ''
${lib.optionalString wrapRuntimeDeps '' ${optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \ wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [ --suffix PATH : ${makeBinPath [
binutils binutils
pciutils pciutils
pkgconf pkgconf