Skip to content

Commit

Permalink
cosmic-settings,wrapCosmicAppsHook: fully wrap settings and generaliz…
Browse files Browse the repository at this point in the history
…e fallback xdg dirs
  • Loading branch information
lilyinstarlight committed Mar 8, 2024
1 parent c1f1dc2 commit 5560fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
17 changes: 8 additions & 9 deletions pkgs/cosmic-settings/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
, stdenv
, fetchFromGitHub
, rustPlatform
, makeBinaryWrapper
, buildPackages
, cmake
, cosmic-icons
, cosmic-randr
, expat
, fontconfig
, freetype
, just
, libinput
, libxkbcommon
, pkg-config
, udev
, util-linux
, wayland
}:

let
wrapCosmicAppsHook' = buildPackages.wrapCosmicAppsHook.override { cosmic-settings = null; };
in

rustPlatform.buildRustPackage {
pname = "cosmic-settings";
version = "0-unstable-2024-03-07";
Expand Down Expand Up @@ -50,8 +51,8 @@ rustPlatform.buildRustPackage {
};
};

nativeBuildInputs = [ makeBinaryWrapper cmake just pkg-config util-linux ];
buildInputs = [ expat fontconfig freetype libxkbcommon libinput udev wayland ];
nativeBuildInputs = [ wrapCosmicAppsHook' cmake just pkg-config util-linux ];
buildInputs = [ expat fontconfig freetype libinput udev ];

dontUseJustBuild = true;

Expand All @@ -65,9 +66,7 @@ rustPlatform.buildRustPackage {
];

postInstall = ''
wrapProgram "$out/bin/cosmic-settings" \
--prefix PATH : '${lib.makeBinPath [ cosmic-randr ]}' \
--suffix XDG_DATA_DIRS : '${placeholder "out"}/share:${cosmic-icons}/share'
cosmicAppsWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ cosmic-randr ]})
'';

meta = with lib; {
Expand Down
3 changes: 1 addition & 2 deletions pkgs/wrapCosmicAppsHook/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ makeSetupHook {
];

substitutions = {
cosmicIcons = cosmic-icons;
cosmicSettings = cosmic-settings;
fallbackXdgDirs = "${lib.optionalString (cosmic-settings != null) "${cosmic-settings}/share:"}${cosmic-icons}/share";

cargoLinkerVar = stdenv.hostPlatform.rust.cargoEnvVarTarget;
cargoLinkLibs = lib.escapeShellArgs ([
Expand Down
6 changes: 3 additions & 3 deletions pkgs/wrapCosmicAppsHook/wrap-cosmic-apps-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cosmicAppsVergenHook() {
}

cosmicAppsLinkerArgsHook() {
# Force linking to libEGL, which is always dlopen()ed.
# Force linking to certain libraries like libEGL, which are always dlopen()ed
local flags="CARGO_TARGET_@cargoLinkerVar@_RUSTFLAGS"

export "$flags"="${!flags-} -C link-arg=-Wl,--push-state,--no-as-needed"
Expand All @@ -21,7 +21,7 @@ preConfigurePhases+=" cosmicAppsVergenHook cosmicAppsLinkerArgsHook"

cosmicAppsWrapperArgsHook() {
# add fallback schemas, icons, and settings paths
cosmicAppsWrapperArgs+=(--suffix XDG_DATA_DIRS : "@cosmicSettings@/share:@cosmicIcons@/share")
cosmicAppsWrapperArgs+=(--suffix XDG_DATA_DIRS : "@fallbackXdgDirs@")

if [ -d "${prefix:?}/share" ]; then
cosmicAppsWrapperArgs+=(--prefix XDG_DATA_DIRS : "$prefix/share")
Expand All @@ -36,7 +36,7 @@ wrapCosmicApp() {
wrapProgram "$program" "${cosmicAppsWrapperArgs[@]}" "$@"
}

# Note: $cosmicAppsWrapperArgs still gets defined even if ${dontWrapCosmicApps-} is set.
# Note: $cosmicAppsWrapperArgs still gets defined even if ${dontWrapCosmicApps-} is set
wrapCosmicAppsHook() {
# guard against running multiple times (e.g. due to propagation)
[ -z "$wrapCosmicAppsHookHasRun" ] || return 0
Expand Down

0 comments on commit 5560fe8

Please sign in to comment.