Unverified Commit b7f73db2 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

{cosmic-randr,cosmic-bg,cosmic-launcher}: use mold linker (#386496)

parents 4c3e6ef5 1b269226
Loading
Loading
Loading
Loading
+56 −49
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  stdenvAdapters,
  fetchFromGitHub,
  rustPlatform,
  libcosmicAppHook,
  just,
  pkg-config,
  makeBinaryWrapper,
  libxkbcommon,
  wayland,
  nasm,
  nix-update-script,

  withMoldLinker ? stdenv.targetPlatform.isLinux,
}:

rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage.override
  { stdenv = if withMoldLinker then stdenvAdapters.useMoldLinker stdenv else stdenv; }
  (finalAttrs: {
    pname = "cosmic-bg";
    version = "1.0.0-alpha.6";

    src = fetchFromGitHub {
      owner = "pop-os";
    repo = pname;
    rev = "epoch-${version}";
      repo = "cosmic-bg";
      tag = "epoch-${finalAttrs.version}";
      hash = "sha256-4b4laUXTnAbdngLVh8/dD144m9QrGReSEjRZoNR6Iks=";
    };

    useFetchCargoVendor = true;
    cargoHash = "sha256-GLXooTjcGq4MsBNnlpHBBUJGNs5UjKMQJGJuj9UO2wk=";

  postPatch = ''
    substituteInPlace justfile --replace-fail '#!/usr/bin/env' "#!$(command -v env)"
  '';

    nativeBuildInputs = [
      just
    pkg-config
    makeBinaryWrapper
  ];
  buildInputs = [
    libxkbcommon
    wayland
      libcosmicAppHook
      nasm
    ];

    dontUseJustBuild = true;
    dontUseJustCheck = true;

    justFlags = [
      "--set"
@@ -49,17 +46,27 @@ rustPlatform.buildRustPackage rec {
      "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; {
    passthru.updateScript = nix-update-script {
      extraArgs = [
        "--version"
        "unstable"
        "--version-regex"
        "epoch-(.*)"
      ];
    };

    meta = {
      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;
      license = lib.licenses.mpl20;
      maintainers = with lib.maintainers; [
        nyabinary
        HeitorAugustoLN
      ];
      platforms = lib.platforms.linux;
      mainProgram = "cosmic-bg";
    };
}
  })
+52 −50
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  stdenvAdapters,
  fetchFromGitHub,
  rustPlatform,
  just,
  libcosmicAppHook,
  nix-update-script,

  withMoldLinker ? stdenv.targetPlatform.isLinux,
}:

rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage.override
  { stdenv = if withMoldLinker then stdenvAdapters.useMoldLinker stdenv else stdenv; }
  (finalAttrs: {
    pname = "cosmic-launcher";
    version = "1.0.0-alpha.6";

    src = fetchFromGitHub {
      owner = "pop-os";
      repo = "cosmic-launcher";
    tag = "epoch-${version}";
      tag = "epoch-${finalAttrs.version}";
      hash = "sha256-BtYnL+qkM/aw+Air5yOKH098V+TQByM5mh1DX7v+v+s=";
    };

@@ -39,11 +44,8 @@ rustPlatform.buildRustPackage rec {
      "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-launcher"
    ];

  postPatch = ''
    substituteInPlace justfile --replace-fail '#!/usr/bin/env' "#!$(command -v env)"
  '';

  env."CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" = "--cfg tokio_unstable";
    env."CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" =
      "--cfg tokio_unstable${lib.optionalString withMoldLinker " -C link-arg=-fuse-ld=mold"}";

    passthru.updateScript = nix-update-script {
      extraArgs = [
@@ -65,4 +67,4 @@ rustPlatform.buildRustPackage rec {
      ];
      platforms = lib.platforms.linux;
    };
}
  })
+54 −46
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  stdenvAdapters,
  fetchFromGitHub,
  rustPlatform,
  just,
  pkg-config,
  wayland,
  nix-update-script,

  withMoldLinker ? stdenv.targetPlatform.isLinux,
}:

rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage.override
  { stdenv = if withMoldLinker then stdenvAdapters.useMoldLinker stdenv else stdenv; }
  (finalAttrs: {
    pname = "cosmic-randr";
    version = "1.0.0-alpha.6";

    src = fetchFromGitHub {
      owner = "pop-os";
      repo = "cosmic-randr";
    tag = "epoch-${version}";
      tag = "epoch-${finalAttrs.version}";
      hash = "sha256-Sqxe+vKonsK9MmJGtbrZHE7frfrjkHXysm0WQt7WSU4=";
    };

@@ -42,6 +47,9 @@ rustPlatform.buildRustPackage rec {
      "target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-randr"
    ];

    env."CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" =
      lib.optionalString withMoldLinker "-C link-arg=-fuse-ld=mold";

    passthru.updateScript = nix-update-script {
      extraArgs = [
        "--version"
@@ -62,4 +70,4 @@ rustPlatform.buildRustPackage rec {
      platforms = lib.platforms.linux;
      mainProgram = "cosmic-randr";
    };
}
  })