@@ -1,8 +1,13 @@
11{ lib
22, stdenv
3−, fetchurl
3+, fetchFromGitLab
44, pkg-config
5+, rsync
56, libxslt
7+, meson
8+, ninja
9+, python3
10+, gtk-doc
611, docbook_xsl
712, udev
813, libgudev
@@ -15,23 +20,31 @@
1520, libimobiledevice
1621}:
1722
18−stdenv.mkDerivation {
23+stdenv.mkDerivation rec {
1924 pname = "upower";
20− version = "0.99.13";
25+ version = "0.99.15";
2126
22− outputs = [ "out" "dev" ];
27+ outputs = [ "out" "dev" "devdoc" ];
2328
24− src = fetchurl {
25− url = "https://gitlab.freedesktop.org/upower/upower/uploads/177df5b9f9b76f25a2ad9da41aa0c1fa/upower-0.99.13.tar.xz";
26− sha256 = "sha256-XK1w+RVAzH3BIcsX4K1kXl5mPIaC9gp75C7jjNeyPXo=";
29+ src = fetchFromGitLab {
30+ domain = "gitlab.freedesktop.org";
31+ owner = "upower";
32+ repo = "upower";
33+ rev = "v${version}";
34+ sha256 = "sha256-GlLy2MPip21KOabdW8Vw6NVe3xhzsd9htxQ2xO/hZ/4=";
2735 };
2836
2937 nativeBuildInputs = [
38+ meson
39+ ninja
40+ python3
41+ gtk-doc
3042 docbook_xsl
3143 gettext
3244 gobject-introspection
3345 libxslt
3446 pkg-config
47+ rsync
3548 ];
3649
3750 buildInputs = [
@@ -39,29 +52,50 @@ stdenv.mkDerivation {
3952 libusb1
4053 udev
4154 systemd
42− ]
43− ++ lib.optional useIMobileDevice libimobiledevice
44− ;
55+ ] ++ lib.optionals useIMobileDevice [
56+ libimobiledevice
57+ ];
4558
4659 propagatedBuildInputs = [
4760 glib
4861 ];
4962
50− configureFlags = [
63+ mesonFlags = [
5164 "--localstatedir=/var"
52− "--with-backend=linux"
53− "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
54− "--with-systemdutildir=${placeholder "out"}/lib/systemd"
55− "--with-udevrulesdir=${placeholder "out"}/lib/udev/rules.d"
5665 "--sysconfdir=/etc"
66+ "-Dos_backend=linux"
67+ "-Dsystemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
68+ "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d"
5769 ];
5870
5971 doCheck = false; # fails with "env: './linux/integration-test': No such file or directory"
6072
61− installFlags = [
62− "historydir=$(TMPDIR)/foo"
63− "sysconfdir=${placeholder "out"}/etc"
64− ];
73+ postPatch = ''
74+ patchShebangs src/linux/unittest_inspector.py
75+ '';
76+
77+ postInstall = ''
78+ # Move stuff from DESTDIR to proper location.
79+ # We use rsync to merge the directories.
80+ for dir in etc var; do
81+ rsync --archive "${DESTDIR}/$dir" "$out"
82+ rm --recursive "${DESTDIR}/$dir"
83+ done
84+ for o in out dev; do
85+ rsync --archive "${DESTDIR}/''${!o}" "$(dirname "''${!o}")"
86+ rm --recursive "${DESTDIR}/''${!o}"
87+ done
88+ # Ensure the DESTDIR is removed.
89+ rmdir "${DESTDIR}/nix/store" "${DESTDIR}/nix" "${DESTDIR}"
90+ '';
91+
92+ # HACK: We want to install configuration files to $out/etc
93+ # but upower should read them from /etc on a NixOS system.
94+ # With autotools, it was possible to override Make variables
95+ # at install time but Meson does not support this
96+ # so we need to convince it to install all files to a temporary
97+ # location using DESTDIR and then move it to proper one in postInstall.
98+ DESTDIR = "${placeholder "out"}/dest";
6599
66100 meta = with lib; {
67101 homepage = "https://upower.freedesktop.org/";