2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-03-05 16:20:37 +00:00
|
|
|
, fetchFromGitLab
|
2022-06-26 10:26:21 +00:00
|
|
|
, fetchpatch
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2022-03-05 16:20:37 +00:00
|
|
|
, rsync
|
2020-04-24 23:36:52 +00:00
|
|
|
, libxslt
|
2022-03-05 16:20:37 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, python3
|
2022-06-26 10:26:21 +00:00
|
|
|
, dbus
|
|
|
|
, umockdev
|
|
|
|
, libeatmydata
|
2022-03-05 16:20:37 +00:00
|
|
|
, gtk-doc
|
2022-03-30 09:31:56 +00:00
|
|
|
, docbook-xsl-nons
|
2020-04-24 23:36:52 +00:00
|
|
|
, udev
|
|
|
|
, libgudev
|
|
|
|
, libusb1
|
|
|
|
, glib
|
|
|
|
, gobject-introspection
|
|
|
|
, gettext
|
|
|
|
, systemd
|
|
|
|
, useIMobileDevice ? true
|
|
|
|
, libimobiledevice
|
2022-04-27 09:35:20 +00:00
|
|
|
, withDocs ? (stdenv.buildPlatform == stdenv.hostPlatform)
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "upower";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "1.90.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
outputs = [ "out" "dev" ]
|
|
|
|
++ lib.optionals withDocs [ "devdoc" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "gitlab.freedesktop.org";
|
|
|
|
owner = "upower";
|
|
|
|
repo = "upower";
|
|
|
|
rev = "v${version}";
|
2022-08-12 12:06:08 +00:00
|
|
|
hash = "sha256-+C/4dDg6WTLpBgkpNyxjthSdqYdaTLC8vG6jG1LNJ7w=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
# Remove when this is fixed upstream:
|
|
|
|
# https://gitlab.freedesktop.org/upower/upower/-/issues/214
|
|
|
|
patches = lib.optional (stdenv.hostPlatform.system == "i686-linux")
|
|
|
|
./i686-test-remove-battery-check.patch;
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
depsBuildBuild = [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2022-03-05 16:20:37 +00:00
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
python3
|
|
|
|
gtk-doc
|
2022-03-30 09:31:56 +00:00
|
|
|
docbook-xsl-nons
|
2020-04-24 23:36:52 +00:00
|
|
|
gettext
|
|
|
|
gobject-introspection
|
|
|
|
libxslt
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2022-03-05 16:20:37 +00:00
|
|
|
rsync
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libgudev
|
|
|
|
libusb1
|
|
|
|
udev
|
|
|
|
systemd
|
2022-08-12 12:06:08 +00:00
|
|
|
# Duplicate from checkInputs until https://github.com/NixOS/nixpkgs/issues/161570 is solved
|
|
|
|
umockdev
|
2022-03-05 16:20:37 +00:00
|
|
|
] ++ lib.optionals useIMobileDevice [
|
|
|
|
libimobiledevice
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
checkInputs = [
|
|
|
|
python3.pkgs.dbus-python
|
|
|
|
python3.pkgs.python-dbusmock
|
|
|
|
python3.pkgs.pygobject3
|
|
|
|
dbus
|
|
|
|
umockdev
|
|
|
|
libeatmydata
|
|
|
|
python3.pkgs.packaging
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
glib
|
|
|
|
];
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
mesonFlags = [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--localstatedir=/var"
|
|
|
|
"--sysconfdir=/etc"
|
2022-03-05 16:20:37 +00:00
|
|
|
"-Dos_backend=linux"
|
|
|
|
"-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
|
|
|
|
"-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d"
|
2022-06-26 10:26:21 +00:00
|
|
|
"-Dudevhwdbdir=${placeholder "out"}/lib/udev/hwdb.d"
|
2022-04-27 09:35:20 +00:00
|
|
|
"-Dintrospection=${if (stdenv.buildPlatform == stdenv.hostPlatform) then "auto" else "disabled"}"
|
|
|
|
"-Dgtk-doc=${lib.boolToString withDocs}"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
doCheck = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
postPatch = ''
|
2022-06-26 10:26:21 +00:00
|
|
|
patchShebangs src/linux/integration-test.py
|
2022-03-05 16:20:37 +00:00
|
|
|
patchShebangs src/linux/unittest_inspector.py
|
|
|
|
'';
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
preCheck = ''
|
|
|
|
# Our gobject-introspection patches make the shared library paths absolute
|
|
|
|
# in the GIR files. When running tests, the library is not yet installed,
|
|
|
|
# though, so we need to replace the absolute path with a local one during build.
|
|
|
|
# We are using a symlink that will be overwitten during installation.
|
|
|
|
mkdir -p "$out/lib"
|
|
|
|
ln -s "$PWD/libupower-glib/libupower-glib.so" "$out/lib/libupower-glib.so.3"
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# Slow fsync calls can make self-test fail:
|
|
|
|
# https://gitlab.freedesktop.org/upower/upower/-/issues/195
|
|
|
|
eatmydata meson test --print-errorlogs
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
postInstall = ''
|
|
|
|
# Move stuff from DESTDIR to proper location.
|
|
|
|
# We use rsync to merge the directories.
|
|
|
|
for dir in etc var; do
|
|
|
|
rsync --archive "${DESTDIR}/$dir" "$out"
|
|
|
|
rm --recursive "${DESTDIR}/$dir"
|
|
|
|
done
|
|
|
|
for o in out dev; do
|
|
|
|
rsync --archive "${DESTDIR}/''${!o}" "$(dirname "''${!o}")"
|
|
|
|
rm --recursive "${DESTDIR}/''${!o}"
|
|
|
|
done
|
|
|
|
# Ensure the DESTDIR is removed.
|
|
|
|
rmdir "${DESTDIR}/nix/store" "${DESTDIR}/nix" "${DESTDIR}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# HACK: We want to install configuration files to $out/etc
|
|
|
|
# but upower should read them from /etc on a NixOS system.
|
|
|
|
# With autotools, it was possible to override Make variables
|
|
|
|
# at install time but Meson does not support this
|
|
|
|
# so we need to convince it to install all files to a temporary
|
|
|
|
# location using DESTDIR and then move it to proper one in postInstall.
|
|
|
|
DESTDIR = "${placeholder "out"}/dest";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://upower.freedesktop.org/";
|
2022-03-30 09:31:56 +00:00
|
|
|
changelog = "https://gitlab.freedesktop.org/upower/upower/-/blob/v${version}/NEWS";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A D-Bus service for power management";
|
2022-03-30 09:31:56 +00:00
|
|
|
maintainers = teams.freedesktop.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
};
|
|
|
|
}
|