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
kdeWrapper unwrapped
kdeWrapper
{
inherit unwrapped;
targets = [ "bin/kile" ];
paths = [ konsole.unwrapped ];
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,31 +1,47 @@
{ 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
good=""
for drv in $unwrapped; do
if [ -a "$drv/$t" ]; then
makeWrapper "$drv/$t" "$out/$t" \
--argv0 '"$0"' \
@ -35,19 +51,23 @@ stdenv.mkDerivation {
--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="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"
for drv in $unwrapped; do
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/"
cat "$drv/nix-support/propagated-user-env-packages" >> "$out/nix-support/propagated-user-env-packages"
fi
done
'';
}

View File

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

View File

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