nixpkgs/pkgs/development/libraries/libadwaita/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

137 lines
3.4 KiB
Nix

{ lib
, stdenv
, fetchFromGitLab
, gi-docgen
, meson
, ninja
, pkg-config
, sassc
, vala
, gobject-introspection
, appstream
, fribidi
, glib
, gtk4
, gnome
, adwaita-icon-theme
, gsettings-desktop-schemas
, desktop-file-utils
, xvfb-run
, AppKit
, Foundation
, testers
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libadwaita";
version = "1.5.3";
outputs = [ "out" "dev" "devdoc" ];
outputBin = "devdoc"; # demo app
src = fetchFromGitLab {
domain = "gitlab.gnome.org";
owner = "GNOME";
repo = "libadwaita";
rev = finalAttrs.version;
hash = "sha256-NCQCd/QnJg2fEI6q5ys8HQXinGnKaoxhMUHd8rwxAmk=";
};
depsBuildBuild = [
pkg-config
];
nativeBuildInputs = [
gi-docgen
meson
ninja
pkg-config
sassc
vala
gobject-introspection
desktop-file-utils # for validate-desktop-file
];
mesonFlags = [
"-Dgtk_doc=true"
] ++ lib.optionals (!finalAttrs.finalPackage.doCheck) [
"-Dtests=false"
];
buildInputs = [
appstream
fribidi
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
AppKit
Foundation
];
propagatedBuildInputs = [
gtk4
];
nativeCheckInputs = [
adwaita-icon-theme
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
xvfb-run
];
# Tests had to be disabled on Darwin because test-button-content fails
#
# not ok /Adwaita/ButtonContent/style_class_button - Gdk-FATAL-CRITICAL:
# gdk_macos_monitor_get_workarea: assertion 'GDK_IS_MACOS_MONITOR (self)' failed
doCheck = !stdenv.hostPlatform.isDarwin;
separateDebugInfo = true;
checkPhase = ''
runHook preCheck
testEnvironment=(
# Disable portal since we cannot run it in tests.
ADW_DISABLE_PORTAL=1
# AdwSettings needs to be initialized from org.gnome.desktop.interface GSettings schema when portal is not used for color scheme.
# It will not actually be used since the color-scheme key will only have been introduced in GNOME 42, falling back to detecting theme name.
# See adw_settings_constructed function in https://gitlab.gnome.org/GNOME/libadwaita/commit/60ec69f0a5d49cad8a6d79e4ecefd06dc6e3db12
"XDG_DATA_DIRS=${glib.getSchemaDataDirPath gsettings-desktop-schemas}"
# Tests need a cache directory
"HOME=$TMPDIR"
)
env "''${testEnvironment[@]}" ${lib.optionalString (!stdenv.hostPlatform.isDarwin) "xvfb-run"} \
meson test --print-errorlogs
runHook postCheck
'';
postFixup = ''
# Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
moveToOutput "share/doc" "$devdoc"
# Put all resources related to demo app into devdoc output.
for d in applications icons metainfo; do
moveToOutput "share/$d" "$devdoc"
done
'';
passthru = {
updateScript = gnome.updateScript {
packageName = finalAttrs.pname;
};
tests.pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};
meta = with lib; {
changelog = "https://gitlab.gnome.org/GNOME/libadwaita/-/blob/${finalAttrs.src.rev}/NEWS";
description = "Library to help with developing UI for mobile devices using GTK/GNOME";
mainProgram = "adwaita-1-demo";
homepage = "https://gitlab.gnome.org/GNOME/libadwaita";
license = licenses.lgpl21Plus;
maintainers = teams.gnome.members ++ (with maintainers; [ dotlambda ]);
platforms = platforms.unix;
pkgConfigModules = [ "libadwaita-1" ];
};
})