kdeWrapper: allow wrapping several packages

This commit is contained in:
Nikolay Amiantov 2017-01-03 02:33:15 +03:00
parent 5ba7f33e3a
commit e908442693
23 changed files with 108 additions and 53 deletions

View File

@ -60,8 +60,9 @@ let
}; };
}; };
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/kile" ]; targets = [ "bin/kile" ];
paths = [ konsole.unwrapped ]; paths = [ konsole.unwrapped ];
} }

View File

@ -55,9 +55,9 @@ let
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/yakuake" ]; targets = [ "bin/yakuake" ];
paths = [ konsole.unwrapped ]; paths = [ konsole.unwrapped ];
} }

View File

@ -75,7 +75,8 @@ let
homepage = https://konversation.kde.org; homepage = https://konversation.kde.org;
}; };
}; };
in kdeWrapper unwrapped { in kdeWrapper {
inherit unwrapped;
targets = [ "bin/konversation" ]; targets = [ "bin/konversation" ];
} }

View File

@ -36,7 +36,8 @@ let
}; };
}; };
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/ark" ]; targets = [ "bin/ark" ];
} }

View File

@ -24,8 +24,9 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/dolphin" ]; targets = [ "bin/dolphin" ];
paths = [ dolphin-plugins konsole.unwrapped ]; paths = [ dolphin-plugins konsole.unwrapped ];
} }

View File

@ -18,4 +18,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/filelight" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/filelight" ];
}

View File

@ -20,7 +20,8 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/gwenview" ]; targets = [ "bin/gwenview" ];
paths = [ kipi-plugins ]; paths = [ kipi-plugins ];
} }

View File

@ -24,8 +24,9 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/kate" "bin/kwrite" ]; targets = [ "bin/kate" "bin/kwrite" ];
paths = [ konsole.unwrapped ]; paths = [ konsole.unwrapped ];
} }

View File

@ -18,4 +18,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/kcalc" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/kcalc" ];
}

View File

@ -15,4 +15,7 @@ let
propagatedBuildInputs = [ ki18n kwidgetsaddons kxmlgui ]; propagatedBuildInputs = [ ki18n kwidgetsaddons kxmlgui ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/kcolorchooser" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/kcolorchooser" ];
}

View File

@ -74,8 +74,9 @@ unwrapped = kdeApp {
}; };
}; };
in in
kdeWrapper unwrapped kdeWrapper
{ {
inherit unwrapped;
targets = [ "bin/kdenlive" ]; targets = [ "bin/kdenlive" ];
paths = [ kinit ]; paths = [ kinit ];
} }

View File

@ -18,4 +18,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/kdf" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/kdf" ];
}

View File

@ -16,4 +16,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/khelpcenter" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/khelpcenter" ];
}

View File

@ -15,4 +15,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/kompare" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/kompare" ];
}

View File

@ -24,4 +24,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { targets = [ "bin/konsole" ]; } kdeWrapper {
inherit unwrapped;
targets = [ "bin/konsole" ];
}

View File

@ -30,6 +30,7 @@ let
kxmlgui kxmlgui
]; ];
}; };
in kdeWrapper unwrapped { in kdeWrapper {
inherit unwrapped;
targets = ["bin/kwalletmanager5"]; targets = ["bin/kwalletmanager5"];
} }

View File

@ -18,7 +18,8 @@ let
enableParallelBuilding = true; enableParallelBuilding = true;
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/marble-qt" ]; targets = [ "bin/marble-qt" ];
paths = [ unwrapped ]; paths = [ unwrapped ];
} }

View File

@ -25,6 +25,7 @@ let
}; };
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/okular" ]; targets = [ "bin/okular" ];
} }

View File

@ -18,7 +18,8 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/spectacle" ]; targets = [ "bin/spectacle" ];
paths = [ kipi-plugins ]; paths = [ kipi-plugins ];
} }

View File

@ -15,6 +15,7 @@ let
]; ];
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/oxygen-demo5" "bin/oxygen-settings5" ]; targets = [ "bin/oxygen-demo5" "bin/oxygen-settings5" ];
} }

View File

@ -1,31 +1,47 @@
{ stdenv, lib, makeWrapper, buildEnv }: { stdenv, lib, makeWrapper, buildEnv }:
drv: packages:
{ targets, paths ? [] }:
let 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 { env = buildEnv {
inherit (drv) name meta; inherit name meta;
paths = builtins.map lib.getBin ([drv] ++ paths); paths = builtins.map lib.getBin (unwrapped ++ paths);
pathsToLink = [ "/bin" "/share" "/lib/qt5" "/etc/xdg" ]; pathsToLink = [ "/bin" "/share" "/lib/qt5" "/etc/xdg" ];
}; };
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit (drv) name meta; inherit name meta;
preferLocalBuild = true; preferLocalBuild = true;
paths = builtins.map lib.getBin ([drv] ++ paths); inherit unwrapped env targets;
inherit drv env targets;
passthru = { unwrapped = drv; }; passthru = {
inherit targets paths;
unwrapped = if builtins.length unwrapped == 1 then lib.head unwrapped else unwrapped;
};
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
builder = builtins.toFile "builder.sh" '' buildCommand = ''
. $stdenv/setup
for t in $targets; do for t in $targets; do
good=""
for drv in $unwrapped; do
if [ -a "$drv/$t" ]; then if [ -a "$drv/$t" ]; then
makeWrapper "$drv/$t" "$out/$t" \ makeWrapper "$drv/$t" "$out/$t" \
--argv0 '"$0"' \ --argv0 '"$0"' \
@ -35,19 +51,23 @@ stdenv.mkDerivation {
--set QML_IMPORT_PATH "$env/lib/qt5/imports" \ --set QML_IMPORT_PATH "$env/lib/qt5/imports" \
--set QML2_IMPORT_PATH "$env/lib/qt5/qml" \ --set QML2_IMPORT_PATH "$env/lib/qt5/qml" \
--set QT_PLUGIN_PATH "$env/lib/qt5/plugins" --set QT_PLUGIN_PATH "$env/lib/qt5/plugins"
else good="1"
echo "no such file or directory: $drv/$t" break
fi
done
if [ -z "$good" ]; then
echo "file or directory not found in derivations: $t"
exit 1 exit 1
fi fi
done done
if [ -a "$drv/share" ]; then ln -s "$env/share" "$out"
ln -s "$drv/share" "$out"
fi
for drv in $unwrapped; do
if [ -a "$drv/nix-support/propagated-user-env-packages" ]; then if [ -a "$drv/nix-support/propagated-user-env-packages" ]; then
mkdir -p "$out/nix-support" mkdir -p "$out/nix-support"
ln -s "$drv/nix-support/propagated-user-env-packages" "$out/nix-support/" cat "$drv/nix-support/propagated-user-env-packages" >> "$out/nix-support/propagated-user-env-packages"
fi fi
done
''; '';
} }

View File

@ -23,6 +23,7 @@ let
propagatedBuildInputs = [ kconfig kinit ]; propagatedBuildInputs = [ kconfig kinit ];
}; };
in in
kdeWrapper unwrapped { kdeWrapper {
inherit unwrapped;
targets = [ "bin/kronometer" ]; targets = [ "bin/kronometer" ];
} }

View File

@ -37,6 +37,7 @@ let
}; };
in kdeWrapper unwrapped { in kdeWrapper {
inherit unwrapped;
targets = [ "bin/peruse" ]; targets = [ "bin/peruse" ];
} }