Skip to content

Commit d9344e9

Browse files
cosmic-settings: use mold linker
1 parent 4c7f122 commit d9344e9

File tree

1 file changed

+73
-65
lines changed

1 file changed

+73
-65
lines changed
Lines changed: 73 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
lib,
33
stdenv,
4+
stdenvAdapters,
45
fetchFromGitHub,
56
rustPlatform,
67
cmake,
@@ -18,83 +19,90 @@
1819
cosmic-randr,
1920
xkeyboard_config,
2021
nix-update-script,
22+
23+
withMoldLinker ? stdenv.targetPlatform.isLinux,
2124
}:
2225
let
2326
libcosmicAppHook' = (libcosmicAppHook.__spliced.buildHost or libcosmicAppHook).override {
2427
includeSettings = false;
2528
};
2629
in
27-
rustPlatform.buildRustPackage rec {
28-
pname = "cosmic-settings";
29-
version = "1.0.0-alpha.6";
30+
rustPlatform.buildRustPackage.override
31+
{ stdenv = if withMoldLinker then stdenvAdapters.useMoldLinker stdenv else stdenv; }
32+
rec {
33+
pname = "cosmic-settings";
34+
version = "1.0.0-alpha.6";
3035

31-
src = fetchFromGitHub {
32-
owner = "pop-os";
33-
repo = "cosmic-settings";
34-
tag = "epoch-${version}";
35-
hash = "sha256-UKg3TIpyaqtynk6wLFFPpv69F74hmqfMVPra2+iFbvE=";
36-
};
36+
src = fetchFromGitHub {
37+
owner = "pop-os";
38+
repo = "cosmic-settings";
39+
tag = "epoch-${version}";
40+
hash = "sha256-UKg3TIpyaqtynk6wLFFPpv69F74hmqfMVPra2+iFbvE=";
41+
};
3742

38-
useFetchCargoVendor = true;
39-
cargoHash = "sha256-mf/Cw3/RLrCYgsk7JKCU2+oPn1VPbD+4JzkUmbd47m8=";
43+
useFetchCargoVendor = true;
44+
cargoHash = "sha256-mf/Cw3/RLrCYgsk7JKCU2+oPn1VPbD+4JzkUmbd47m8=";
4045

41-
nativeBuildInputs = [
42-
cmake
43-
just
44-
libcosmicAppHook'
45-
pkg-config
46-
rustPlatform.bindgenHook
47-
util-linux
48-
];
46+
nativeBuildInputs = [
47+
cmake
48+
just
49+
libcosmicAppHook'
50+
pkg-config
51+
rustPlatform.bindgenHook
52+
util-linux
53+
];
54+
55+
buildInputs = [
56+
expat
57+
fontconfig
58+
freetype
59+
libinput
60+
pipewire
61+
pulseaudio
62+
udev
63+
];
4964

50-
buildInputs = [
51-
expat
52-
fontconfig
53-
freetype
54-
libinput
55-
pipewire
56-
pulseaudio
57-
udev
58-
];
65+
dontUseJustBuild = true;
66+
dontUseJustCheck = true;
5967

60-
dontUseJustBuild = true;
61-
dontUseJustCheck = true;
68+
justFlags = [
69+
"--set"
70+
"prefix"
71+
(placeholder "out")
72+
"--set"
73+
"bin-src"
74+
"target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-settings"
75+
];
6276

63-
justFlags = [
64-
"--set"
65-
"prefix"
66-
(placeholder "out")
67-
"--set"
68-
"bin-src"
69-
"target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cosmic-settings"
70-
];
77+
env."CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_RUSTFLAGS" =
78+
lib.optionalString withMoldLinker "-C link-arg=-fuse-ld=mold";
7179

72-
preFixup = ''
73-
libcosmicAppWrapperArgs+=(
74-
--prefix PATH : ${lib.makeBinPath [ cosmic-randr ]}
75-
--set-default X11_BASE_RULES_XML ${xkeyboard_config}/share/X11/xkb/rules/base.xml
76-
--set-default X11_BASE_EXTRA_RULES_XML ${xkeyboard_config}/share/X11/xkb/rules/extra.xml
77-
)
78-
'';
80+
preFixup = ''
81+
libcosmicAppWrapperArgs+=(
82+
--prefix PATH : ${lib.makeBinPath [ cosmic-randr ]}
83+
--set-default X11_BASE_RULES_XML ${xkeyboard_config}/share/X11/xkb/rules/base.xml
84+
--set-default X11_BASE_EXTRA_RULES_XML ${xkeyboard_config}/share/X11/xkb/rules/extra.xml
85+
)
86+
'';
7987

80-
passthru.updateScript = nix-update-script {
81-
extraArgs = [
82-
"--version"
83-
"unstable"
84-
"--version-regex"
85-
"epoch-(.*)"
86-
];
87-
};
88+
passthru.updateScript = nix-update-script {
89+
extraArgs = [
90+
"--version"
91+
"unstable"
92+
"--version-regex"
93+
"epoch-(.*)"
94+
];
95+
};
8896

89-
meta = {
90-
description = "Settings for the COSMIC Desktop Environment";
91-
homepage = "https://github.com/pop-os/cosmic-settings";
92-
license = lib.licenses.gpl3Only;
93-
mainProgram = "cosmic-settings";
94-
maintainers = with lib.maintainers; [
95-
nyabinary
96-
HeitorAugustoLN
97-
];
98-
platforms = lib.platforms.linux;
99-
};
100-
}
97+
meta = {
98+
description = "Settings for the COSMIC Desktop Environment";
99+
homepage = "https://github.com/pop-os/cosmic-settings";
100+
license = lib.licenses.gpl3Only;
101+
mainProgram = "cosmic-settings";
102+
maintainers = with lib.maintainers; [
103+
nyabinary
104+
HeitorAugustoLN
105+
];
106+
platforms = lib.platforms.linux;
107+
};
108+
}

0 commit comments

Comments
 (0)