From e90844269352fdd60e42f8d61dd3f7ab129d6806 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Tue, 3 Jan 2017 02:33:15 +0300 Subject: [PATCH] kdeWrapper: allow wrapping several packages --- pkgs/applications/editors/kile/frameworks.nix | 3 +- pkgs/applications/misc/yakuake/3.0.nix | 4 +- .../networking/irc/konversation/1.6.nix | 3 +- .../kde-5/applications/ark/default.nix | 3 +- pkgs/desktops/kde-5/applications/dolphin.nix | 3 +- .../desktops/kde-5/applications/filelight.nix | 5 +- pkgs/desktops/kde-5/applications/gwenview.nix | 3 +- pkgs/desktops/kde-5/applications/kate.nix | 3 +- pkgs/desktops/kde-5/applications/kcalc.nix | 5 +- .../kde-5/applications/kcolorchooser.nix | 5 +- pkgs/desktops/kde-5/applications/kdenlive.nix | 3 +- pkgs/desktops/kde-5/applications/kdf.nix | 5 +- .../kde-5/applications/khelpcenter.nix | 5 +- pkgs/desktops/kde-5/applications/kompare.nix | 5 +- pkgs/desktops/kde-5/applications/konsole.nix | 5 +- .../kde-5/applications/kwalletmanager.nix | 3 +- pkgs/desktops/kde-5/applications/marble.nix | 3 +- pkgs/desktops/kde-5/applications/okular.nix | 3 +- .../desktops/kde-5/applications/spectacle.nix | 3 +- pkgs/desktops/kde-5/plasma/oxygen.nix | 3 +- .../libraries/kde-frameworks/kde-wrapper.nix | 80 ++++++++++++------- pkgs/tools/misc/kronometer/default.nix | 3 +- pkgs/tools/misc/peruse/default.nix | 3 +- 23 files changed, 108 insertions(+), 53 deletions(-) diff --git a/pkgs/applications/editors/kile/frameworks.nix b/pkgs/applications/editors/kile/frameworks.nix index 7a02c3d3f8c6..34ea76478937 100644 --- a/pkgs/applications/editors/kile/frameworks.nix +++ b/pkgs/applications/editors/kile/frameworks.nix @@ -60,8 +60,9 @@ let }; }; in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/kile" ]; paths = [ konsole.unwrapped ]; } diff --git a/pkgs/applications/misc/yakuake/3.0.nix b/pkgs/applications/misc/yakuake/3.0.nix index 4ccef7f435a4..8bce26deefc3 100644 --- a/pkgs/applications/misc/yakuake/3.0.nix +++ b/pkgs/applications/misc/yakuake/3.0.nix @@ -55,9 +55,9 @@ let in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/yakuake" ]; paths = [ konsole.unwrapped ]; } - diff --git a/pkgs/applications/networking/irc/konversation/1.6.nix b/pkgs/applications/networking/irc/konversation/1.6.nix index c68764054627..9724ae5f4bf0 100644 --- a/pkgs/applications/networking/irc/konversation/1.6.nix +++ b/pkgs/applications/networking/irc/konversation/1.6.nix @@ -75,7 +75,8 @@ let homepage = https://konversation.kde.org; }; }; -in kdeWrapper unwrapped { +in kdeWrapper { + inherit unwrapped; targets = [ "bin/konversation" ]; } diff --git a/pkgs/desktops/kde-5/applications/ark/default.nix b/pkgs/desktops/kde-5/applications/ark/default.nix index 249027570663..6b471614f5a6 100644 --- a/pkgs/desktops/kde-5/applications/ark/default.nix +++ b/pkgs/desktops/kde-5/applications/ark/default.nix @@ -36,7 +36,8 @@ let }; }; in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/ark" ]; } diff --git a/pkgs/desktops/kde-5/applications/dolphin.nix b/pkgs/desktops/kde-5/applications/dolphin.nix index 4e636ae31863..9be40e9439b6 100644 --- a/pkgs/desktops/kde-5/applications/dolphin.nix +++ b/pkgs/desktops/kde-5/applications/dolphin.nix @@ -24,8 +24,9 @@ let ]; }; in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/dolphin" ]; paths = [ dolphin-plugins konsole.unwrapped ]; } diff --git a/pkgs/desktops/kde-5/applications/filelight.nix b/pkgs/desktops/kde-5/applications/filelight.nix index acc5808b4a34..e3d9172145c8 100644 --- a/pkgs/desktops/kde-5/applications/filelight.nix +++ b/pkgs/desktops/kde-5/applications/filelight.nix @@ -18,4 +18,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/filelight" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/filelight" ]; +} diff --git a/pkgs/desktops/kde-5/applications/gwenview.nix b/pkgs/desktops/kde-5/applications/gwenview.nix index 18f5036127d0..b97e4ce3bd6e 100644 --- a/pkgs/desktops/kde-5/applications/gwenview.nix +++ b/pkgs/desktops/kde-5/applications/gwenview.nix @@ -20,7 +20,8 @@ let ]; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/gwenview" ]; paths = [ kipi-plugins ]; } diff --git a/pkgs/desktops/kde-5/applications/kate.nix b/pkgs/desktops/kde-5/applications/kate.nix index ab0087930c01..03cc0e1fe33b 100644 --- a/pkgs/desktops/kde-5/applications/kate.nix +++ b/pkgs/desktops/kde-5/applications/kate.nix @@ -24,8 +24,9 @@ let ]; }; in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/kate" "bin/kwrite" ]; paths = [ konsole.unwrapped ]; } diff --git a/pkgs/desktops/kde-5/applications/kcalc.nix b/pkgs/desktops/kde-5/applications/kcalc.nix index f6d87e3e6e97..10164692f770 100644 --- a/pkgs/desktops/kde-5/applications/kcalc.nix +++ b/pkgs/desktops/kde-5/applications/kcalc.nix @@ -18,4 +18,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/kcalc" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/kcalc" ]; +} diff --git a/pkgs/desktops/kde-5/applications/kcolorchooser.nix b/pkgs/desktops/kde-5/applications/kcolorchooser.nix index 45a72a0bbc1b..1dc6ccbc44c4 100644 --- a/pkgs/desktops/kde-5/applications/kcolorchooser.nix +++ b/pkgs/desktops/kde-5/applications/kcolorchooser.nix @@ -15,4 +15,7 @@ let propagatedBuildInputs = [ ki18n kwidgetsaddons kxmlgui ]; }; in -kdeWrapper unwrapped { targets = [ "bin/kcolorchooser" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/kcolorchooser" ]; +} diff --git a/pkgs/desktops/kde-5/applications/kdenlive.nix b/pkgs/desktops/kde-5/applications/kdenlive.nix index 00826060b69b..071ec21bbd01 100644 --- a/pkgs/desktops/kde-5/applications/kdenlive.nix +++ b/pkgs/desktops/kde-5/applications/kdenlive.nix @@ -74,8 +74,9 @@ unwrapped = kdeApp { }; }; in -kdeWrapper unwrapped +kdeWrapper { + inherit unwrapped; targets = [ "bin/kdenlive" ]; paths = [ kinit ]; } diff --git a/pkgs/desktops/kde-5/applications/kdf.nix b/pkgs/desktops/kde-5/applications/kdf.nix index 835f0344da74..c73eadc1df44 100644 --- a/pkgs/desktops/kde-5/applications/kdf.nix +++ b/pkgs/desktops/kde-5/applications/kdf.nix @@ -18,4 +18,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/kdf" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/kdf" ]; +} diff --git a/pkgs/desktops/kde-5/applications/khelpcenter.nix b/pkgs/desktops/kde-5/applications/khelpcenter.nix index 934f13425e8a..3f13d131c77a 100644 --- a/pkgs/desktops/kde-5/applications/khelpcenter.nix +++ b/pkgs/desktops/kde-5/applications/khelpcenter.nix @@ -16,4 +16,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/khelpcenter" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/khelpcenter" ]; +} diff --git a/pkgs/desktops/kde-5/applications/kompare.nix b/pkgs/desktops/kde-5/applications/kompare.nix index 3b2143af615c..45789edbfcc8 100644 --- a/pkgs/desktops/kde-5/applications/kompare.nix +++ b/pkgs/desktops/kde-5/applications/kompare.nix @@ -15,4 +15,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/kompare" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/kompare" ]; +} diff --git a/pkgs/desktops/kde-5/applications/konsole.nix b/pkgs/desktops/kde-5/applications/konsole.nix index bf3a497fefaa..2dfd305b46b2 100644 --- a/pkgs/desktops/kde-5/applications/konsole.nix +++ b/pkgs/desktops/kde-5/applications/konsole.nix @@ -24,4 +24,7 @@ let ]; }; in -kdeWrapper unwrapped { targets = [ "bin/konsole" ]; } +kdeWrapper { + inherit unwrapped; + targets = [ "bin/konsole" ]; +} diff --git a/pkgs/desktops/kde-5/applications/kwalletmanager.nix b/pkgs/desktops/kde-5/applications/kwalletmanager.nix index a7a7ba47f432..03c2ab3853a1 100644 --- a/pkgs/desktops/kde-5/applications/kwalletmanager.nix +++ b/pkgs/desktops/kde-5/applications/kwalletmanager.nix @@ -30,6 +30,7 @@ let kxmlgui ]; }; -in kdeWrapper unwrapped { +in kdeWrapper { + inherit unwrapped; targets = ["bin/kwalletmanager5"]; } diff --git a/pkgs/desktops/kde-5/applications/marble.nix b/pkgs/desktops/kde-5/applications/marble.nix index 8d6ee5a0f7c5..5b8a82dbf098 100644 --- a/pkgs/desktops/kde-5/applications/marble.nix +++ b/pkgs/desktops/kde-5/applications/marble.nix @@ -18,7 +18,8 @@ let enableParallelBuilding = true; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/marble-qt" ]; paths = [ unwrapped ]; } diff --git a/pkgs/desktops/kde-5/applications/okular.nix b/pkgs/desktops/kde-5/applications/okular.nix index faebf3e679b2..499e8cc93681 100644 --- a/pkgs/desktops/kde-5/applications/okular.nix +++ b/pkgs/desktops/kde-5/applications/okular.nix @@ -25,6 +25,7 @@ let }; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/okular" ]; } diff --git a/pkgs/desktops/kde-5/applications/spectacle.nix b/pkgs/desktops/kde-5/applications/spectacle.nix index aa618ffcde11..4c3a5246b2e7 100644 --- a/pkgs/desktops/kde-5/applications/spectacle.nix +++ b/pkgs/desktops/kde-5/applications/spectacle.nix @@ -18,7 +18,8 @@ let ]; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/spectacle" ]; paths = [ kipi-plugins ]; } diff --git a/pkgs/desktops/kde-5/plasma/oxygen.nix b/pkgs/desktops/kde-5/plasma/oxygen.nix index f880f2e3ab23..ca63c8d7a377 100644 --- a/pkgs/desktops/kde-5/plasma/oxygen.nix +++ b/pkgs/desktops/kde-5/plasma/oxygen.nix @@ -15,6 +15,7 @@ let ]; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/oxygen-demo5" "bin/oxygen-settings5" ]; } diff --git a/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix b/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix index 890ec1e4eec3..9ab6f7a10898 100644 --- a/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix +++ b/pkgs/development/libraries/kde-frameworks/kde-wrapper.nix @@ -1,53 +1,73 @@ { stdenv, lib, makeWrapper, buildEnv }: -drv: - -{ targets, paths ? [] }: +packages: let + packages_ = if builtins.isList packages then packages else [packages]; + + unwrapped = lib.concatMap (p: if builtins.isList p.unwrapped then p.unwrapped else [p.unwrapped]) packages_; + targets = lib.concatMap (p: p.targets) packages_; + paths = lib.concatMap (p: p.paths or []) packages_; + + name = + if builtins.length unwrapped == 1 + then (lib.head unwrapped).name + else "kde-application"; + meta = + if builtins.length unwrapped == 1 + then (lib.head unwrapped).meta + else {}; + env = buildEnv { - inherit (drv) name meta; - paths = builtins.map lib.getBin ([drv] ++ paths); + inherit name meta; + paths = builtins.map lib.getBin (unwrapped ++ paths); pathsToLink = [ "/bin" "/share" "/lib/qt5" "/etc/xdg" ]; }; in stdenv.mkDerivation { - inherit (drv) name meta; + inherit name meta; preferLocalBuild = true; - paths = builtins.map lib.getBin ([drv] ++ paths); - inherit drv env targets; - passthru = { unwrapped = drv; }; + inherit unwrapped env targets; + + passthru = { + inherit targets paths; + unwrapped = if builtins.length unwrapped == 1 then lib.head unwrapped else unwrapped; + }; nativeBuildInputs = [ makeWrapper ]; - builder = builtins.toFile "builder.sh" '' - . $stdenv/setup - + buildCommand = '' for t in $targets; do - if [ -a "$drv/$t" ]; then - makeWrapper "$drv/$t" "$out/$t" \ - --argv0 '"$0"' \ - --suffix PATH : "$env/bin" \ - --prefix XDG_CONFIG_DIRS : "$env/share" \ - --prefix XDG_DATA_DIRS : "$env/etc/xdg" \ - --set QML_IMPORT_PATH "$env/lib/qt5/imports" \ - --set QML2_IMPORT_PATH "$env/lib/qt5/qml" \ - --set QT_PLUGIN_PATH "$env/lib/qt5/plugins" - else - echo "no such file or directory: $drv/$t" + good="" + for drv in $unwrapped; do + if [ -a "$drv/$t" ]; then + makeWrapper "$drv/$t" "$out/$t" \ + --argv0 '"$0"' \ + --suffix PATH : "$env/bin" \ + --prefix XDG_CONFIG_DIRS : "$env/share" \ + --prefix XDG_DATA_DIRS : "$env/etc/xdg" \ + --set QML_IMPORT_PATH "$env/lib/qt5/imports" \ + --set QML2_IMPORT_PATH "$env/lib/qt5/qml" \ + --set QT_PLUGIN_PATH "$env/lib/qt5/plugins" + good="1" + break + fi + done + if [ -z "$good" ]; then + echo "file or directory not found in derivations: $t" exit 1 fi done - if [ -a "$drv/share" ]; then - ln -s "$drv/share" "$out" - fi + ln -s "$env/share" "$out" - if [ -a "$drv/nix-support/propagated-user-env-packages" ]; then - mkdir -p "$out/nix-support" - ln -s "$drv/nix-support/propagated-user-env-packages" "$out/nix-support/" - fi + for drv in $unwrapped; do + if [ -a "$drv/nix-support/propagated-user-env-packages" ]; then + mkdir -p "$out/nix-support" + cat "$drv/nix-support/propagated-user-env-packages" >> "$out/nix-support/propagated-user-env-packages" + fi + done ''; } diff --git a/pkgs/tools/misc/kronometer/default.nix b/pkgs/tools/misc/kronometer/default.nix index 5a3da3788d58..37399a1a4184 100644 --- a/pkgs/tools/misc/kronometer/default.nix +++ b/pkgs/tools/misc/kronometer/default.nix @@ -23,6 +23,7 @@ let propagatedBuildInputs = [ kconfig kinit ]; }; in -kdeWrapper unwrapped { +kdeWrapper { + inherit unwrapped; targets = [ "bin/kronometer" ]; } diff --git a/pkgs/tools/misc/peruse/default.nix b/pkgs/tools/misc/peruse/default.nix index 865c6b1e842a..b6727f4e63bd 100644 --- a/pkgs/tools/misc/peruse/default.nix +++ b/pkgs/tools/misc/peruse/default.nix @@ -37,6 +37,7 @@ let }; -in kdeWrapper unwrapped { +in kdeWrapper { + inherit unwrapped; targets = [ "bin/peruse" ]; }