From 0ee24498210e397f3beeefb4a3b87e43d1d5817b Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sun, 2 Mar 2025 19:20:31 -0300 Subject: [PATCH] cosmic-bg: use mold linker --- pkgs/by-name/co/cosmic-bg/package.nix | 98 +++++++++++++++------------ 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/pkgs/by-name/co/cosmic-bg/package.nix b/pkgs/by-name/co/cosmic-bg/package.nix index 5b6098a42f5f..04e7a6de2120 100644 --- a/pkgs/by-name/co/cosmic-bg/package.nix +++ b/pkgs/by-name/co/cosmic-bg/package.nix @@ -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"; + }; + }