xdg-desktop-portal-cosmic: substitute fallback background path

The directory `/usr/share/backgrounds/pop/` is not accessible on NixOS
because the directory `/usr` does not exist on NixOS. The package
`cosmic-wallpapers` exists in nixpkgs that provides the background image
that is used in the COSMIC DE's screenshots on the first-party
website[0]. Substitute the unreachable, FHS path with a valid path of
the background image from the Nix store.

Note: We are putting in a different fallback background path alltogether
but I believe that this is okay because that is used by upstream in
their marketing materials. Meaning, after substitution, we match
marketing screenshots from upstream.

[0]: https://system76.com/cosmic/
This commit is contained in:
Pratham Patel 2025-04-11 22:54:31 +05:30 committed by Alyssa Ross
parent 5de66298aa
commit 10189aca67

View File

@ -10,6 +10,7 @@
libgbm,
pipewire,
gst_all_1,
cosmic-wallpapers,
coreutils,
nix-update-script,
nixosTests,
@ -59,8 +60,22 @@ rustPlatform.buildRustPackage (finalAttrs: {
})
];
# Also modifies the functionality by replacing 'false' with 'true' to enable the portal to start properly.
postPatch = ''
# While the `kate-hazen-COSMIC-desktop-wallpaper.png` image is present
# in the `pop-wallpapers` package, we're using the Orion Nebula image
# from NASA available in the `cosmic-wallpapers` package. Mainly because
# the previous image was used in the GNOME shell extension and the
# Orion Nebula image is widely used in the Rust-based COSMIC DE's
# marketing materials. Another reason to use the Orion Nebula image
# is that it's actually the default wallpaper as configured by the
# `cosmic-bg` package's configuration in upstream [1] [2].
#
# [1]: https://github.com/pop-os/cosmic-bg/blob/epoch-1.0.0-alpha.6/config/src/lib.rs#L142
# [2]: https://github.com/pop-os/cosmic-bg/blob/epoch-1.0.0-alpha.6/data/v1/all#L3
substituteInPlace src/screenshot.rs src/widget/screenshot.rs \
--replace-fail '/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png' '${cosmic-wallpapers}/share/backgrounds/cosmic/orion_nebula_nasa_heic0601a.jpg'
# Also modifies the functionality by replacing 'false' with 'true' to enable the portal to start properly.
substituteInPlace data/org.freedesktop.impl.portal.desktop.cosmic.service \
--replace-fail 'Exec=/bin/false' 'Exec=${lib.getExe' coreutils "true"}'
'';