cosmic-bg: use mold linker

This commit is contained in:
Heitor Augusto
2025-03-02 19:20:31 -03:00
parent beb9682f36
commit 0ee2449821
+53 -45
View File
@@ -1,6 +1,7 @@
{
lib,
stdenv,
stdenvAdapters,
fetchFromGitHub,
rustPlatform,
just,
@@ -8,58 +9,65 @@
makeBinaryWrapper,
libxkbcommon,
wayland,
withMoldLinker ? stdenv.targetPlatform.isLinux,
}:
rustPlatform.buildRustPackage rec {
pname = "cosmic-bg";
version = "1.0.0-alpha.6";
rustPlatform.buildRustPackage.override
{ stdenv = if withMoldLinker then stdenvAdapters.useMoldLinker stdenv else stdenv; }
rec {
pname = "cosmic-bg";
version = "1.0.0-alpha.6";
src = fetchFromGitHub {
owner = "pop-os";
repo = pname;
rev = "epoch-${version}";
hash = "sha256-4b4laUXTnAbdngLVh8/dD144m9QrGReSEjRZoNR6Iks=";
};
src = fetchFromGitHub {
owner = "pop-os";
repo = pname;
rev = "epoch-${version}";
hash = "sha256-4b4laUXTnAbdngLVh8/dD144m9QrGReSEjRZoNR6Iks=";
};
useFetchCargoVendor = true;
cargoHash = "sha256-GLXooTjcGq4MsBNnlpHBBUJGNs5UjKMQJGJuj9UO2wk=";
useFetchCargoVendor = true;
cargoHash = "sha256-GLXooTjcGq4MsBNnlpHBBUJGNs5UjKMQJGJuj9UO2wk=";
postPatch = ''
substituteInPlace justfile --replace-fail '#!/usr/bin/env' "#!$(command -v env)"
'';
postPatch = ''
substituteInPlace justfile --replace-fail '#!/usr/bin/env' "#!$(command -v env)"
'';
nativeBuildInputs = [
just
pkg-config
makeBinaryWrapper
];
buildInputs = [
libxkbcommon
wayland
];
nativeBuildInputs = [
just
pkg-config
makeBinaryWrapper
];
buildInputs = [
libxkbcommon
wayland
];
dontUseJustBuild = true;
dontUseJustBuild = true;
justFlags = [
"--set"
"prefix"
(placeholder "out")
"--set"
"bin-src"
"target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-bg"
];
justFlags = [
"--set"
"prefix"
(placeholder "out")
"--set"
"bin-src"
"target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-bg"
];
postInstall = ''
wrapProgram $out/bin/cosmic-bg \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ wayland ]}"
'';
env."CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" =
lib.optionalString withMoldLinker "-C link-arg=-fuse-ld=mold";
meta = with lib; {
homepage = "https://github.com/pop-os/cosmic-bg";
description = "Applies Background for the COSMIC Desktop Environment";
license = licenses.mpl20;
maintainers = with maintainers; [ nyabinary ];
platforms = platforms.linux;
mainProgram = "cosmic-bg";
};
}
postInstall = ''
wrapProgram $out/bin/cosmic-bg \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ wayland ]}"
'';
meta = with lib; {
homepage = "https://github.com/pop-os/cosmic-bg";
description = "Applies Background for the COSMIC Desktop Environment";
license = licenses.mpl20;
maintainers = with maintainers; [ nyabinary ];
platforms = platforms.linux;
mainProgram = "cosmic-bg";
};
}