Skip to content

Commit

Permalink
Nix: clean up derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
fufexan committed Sep 14, 2024
1 parent fb6c5c7 commit a495234
Showing 1 changed file with 36 additions and 29 deletions.
65 changes: 36 additions & 29 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,32 @@
nvidiaPatches ? false,
hidpiXWayland ? false,
}: let
adapters = [stdenvAdapters.useMoldLinker] ++ (lib.optional debug stdenvAdapters.keepDebugInfo);
inherit (lib.asserts) assertMsg;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) concatLists foldr optional optionals;
inherit (lib.sources) cleanSource cleanSourceWith;
inherit (lib.strings) cmakeBool hasSuffix makeBinPath optionalString;

customStdenv = lib.lists.foldr (adapter: acc: adapter acc) stdenv adapters;
adapters = concatLists [
[stdenvAdapters.useMoldLinker]
(optional debug stdenvAdapters.keepDebugInfo)
];

customStdenv = foldr (adapter: acc: adapter acc) stdenv adapters;
in
assert lib.assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert lib.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 (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hyprland.org/Configuring/XWayland";
customStdenv.mkDerivation {
pname = "hyprland${lib.optionalString debug "-debug"}";
pname = "hyprland${optionalString debug "-debug"}";
inherit version;

src = lib.cleanSourceWith {
src = cleanSourceWith {
filter = name: type: let
baseName = baseNameOf (toString name);
in
! (lib.hasSuffix ".nix" baseName);
src = lib.cleanSource ../.;
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};

patches = [
Expand All @@ -82,7 +91,7 @@ in

COMMITS = revCount;
DATE = date;
DIRTY = lib.optionalString (commit == "") "dirty";
DIRTY = optionalString (commit == "") "dirty";
HASH = commit;

depsBuildBuild = [
Expand All @@ -105,7 +114,7 @@ in
"dev"
];

buildInputs = lib.concatLists [
buildInputs = concatLists [
[
aquamarine
cairo
Expand All @@ -126,40 +135,38 @@ in
wayland-protocols
xorg.libXcursor
]
(lib.optionals stdenv.hostPlatform.isMusl [libexecinfo])
(lib.optionals enableXWayland [
(optionals stdenv.hostPlatform.isMusl [libexecinfo])
(optionals enableXWayland [
xorg.libxcb
xorg.libXdmcp
xorg.xcbutilerrors
xorg.xcbutilrenderutil
xorg.xcbutilwm
xwayland
])
(lib.optionals withSystemd [systemd])
(optionals withSystemd [systemd])
];

cmakeBuildType =
if debug
then "Debug"
else "RelWithDebInfo";

cmakeFlags = [
cmakeFlags = mapAttrsToList cmakeBool {
# precompiled headers are useless in Nix
"-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON"
(lib.cmakeBool "NO_XWAYLAND" (!enableXWayland))
(lib.cmakeBool "LEGACY_RENDERER" legacyRenderer)
(lib.cmakeBool "NO_SYSTEMD" (!withSystemd))
];
"CMAKE_DISABLE_PRECOMPILE_HEADERS" = true;
"LEGACY_RENDERER" = legacyRenderer;
"NO_SYSTEMD" = !withSystemd;
"NO_XWAYLAND" = !enableXWayland;
};

postInstall = ''
${lib.optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${lib.makeBinPath [
binutils
pciutils
pkgconf
]}
''}
postInstall = optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${makeBinPath [
binutils
pciutils
pkgconf
]}
'';

passthru.providedSessions = ["hyprland"];
Expand Down

0 comments on commit a495234

Please sign in to comment.