about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/upower/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/upower/default.nix')
-rw-r--r--pkgs/os-specific/linux/upower/default.nix32
1 files changed, 18 insertions, 14 deletions
diff --git a/pkgs/os-specific/linux/upower/default.nix b/pkgs/os-specific/linux/upower/default.nix
index 36d8a3b9c45f8..b0b7b4f6776c0 100644
--- a/pkgs/os-specific/linux/upower/default.nix
+++ b/pkgs/os-specific/linux/upower/default.nix
@@ -3,7 +3,6 @@
 , fetchFromGitLab
 , makeWrapper
 , pkg-config
-, rsync
 , libxslt
 , meson
 , ninja
@@ -69,7 +68,6 @@ stdenv.mkDerivation (finalAttrs: {
     libxslt
     makeWrapper
     pkg-config
-    rsync
     glib
   ] ++ lib.optionals withIntrospection [
     gobject-introspection
@@ -138,7 +136,6 @@ stdenv.mkDerivation (finalAttrs: {
     # 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"
   '';
@@ -159,21 +156,28 @@ stdenv.mkDerivation (finalAttrs: {
     # meson rebuild during install and it is not used at runtime anyway.
     sed -Ei 's~#!.+/bin/python3~#!/usr/bin/python3~' \
       ../src/linux/integration-test.py
+
+    # Undo preCheck installation since DESTDIR hack expects outputs to not exist.
+    rm "$out/lib/libupower-glib.so.3"
+    rmdir "$out/lib" "$out"
   '';
 
   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 installedTests; do
-        rsync --archive "$DESTDIR/''${!o}" "$(dirname "''${!o}")"
-        rm --recursive "$DESTDIR/''${!o}"
+    for o in $(getAllOutputNames); do
+        # devdoc is created later by _multioutDocs hook.
+        if [[ "$o" = "devdoc" ]]; then continue; fi
+        mv "$DESTDIR''${!o}" "$(dirname "''${!o}")"
     done
-    # Ensure the DESTDIR is removed.
-    rmdir "$DESTDIR/nix/store" "$DESTDIR/nix" "$DESTDIR"
+
+    mv "$DESTDIR/var" "$out"
+    # The /etc already exist so we need to merge it.
+    cp --recursive "$DESTDIR/etc" "$out"
+    rm --recursive "$DESTDIR/etc"
+
+    # Ensure we did not forget to install anything.
+    rmdir --parents --ignore-fail-on-non-empty "$DESTDIR${builtins.storeDir}"
+    ! test -e "$DESTDIR"
   '';
 
   postFixup = ''
@@ -194,7 +198,7 @@ stdenv.mkDerivation (finalAttrs: {
     # 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";
+    DESTDIR = "dest";
   };
 
   passthru = {