Add kdeEnv and kdeWrapper

This commit is contained in:
Thomas Tuegel 2016-07-30 16:16:36 -05:00
parent 795cfd578a
commit c122f791c9
6 changed files with 158 additions and 107 deletions

View file

@ -11,5 +11,7 @@ kdeApp {
maintainers = [ lib.maintainers.ttuegel ];
};
nativeBuildInputs = [ ecm kdoctools ];
propagatedBuildInputs = [ dolphin kdelibs4support ki18n kio kxmlgui ];
propagatedBuildInputs = [
dolphin.unwrapped kdelibs4support ki18n kio kxmlgui
];
}

View file

@ -1,26 +1,31 @@
{
kdeApp, lib,
kdeApp, lib, kdeWrapper,
ecm, kdoctools, makeQtWrapper,
baloo, baloo-widgets, kactivities, kbookmarks, kcmutils, kcompletion, kconfig,
kcoreaddons, kdelibs4support, kdbusaddons, kfilemetadata, ki18n, kiconthemes,
kinit, kio, knewstuff, knotifications, kparts, ktexteditor, kwindowsystem,
phonon, solid
baloo, baloo-widgets, dolphin-plugins, kactivities, kbookmarks, kcmutils,
kcompletion, kconfig, kcoreaddons, kdelibs4support, kdbusaddons,
kfilemetadata, ki18n, kiconthemes, kinit, kio, knewstuff, knotifications,
kparts, ktexteditor, kwindowsystem, phonon, solid
}:
kdeApp {
name = "dolphin";
meta = {
license = with lib.licenses; [ gpl2 fdl12 ];
maintainers = [ lib.maintainers.ttuegel ];
};
nativeBuildInputs = [ ecm kdoctools makeQtWrapper ];
propagatedBuildInputs = [
baloo baloo-widgets kactivities kbookmarks kcmutils kcompletion kconfig
kcoreaddons kdelibs4support kdbusaddons kfilemetadata ki18n kiconthemes
kinit kio knewstuff knotifications kparts ktexteditor kwindowsystem phonon
solid
];
postInstall = ''
wrapQtProgram "$out/bin/dolphin"
'';
let
unwrapped =
kdeApp {
name = "dolphin";
meta = {
license = with lib.licenses; [ gpl2 fdl12 ];
maintainers = [ lib.maintainers.ttuegel ];
};
nativeBuildInputs = [ ecm kdoctools makeQtWrapper ];
propagatedBuildInputs = [
baloo baloo-widgets kactivities kbookmarks kcmutils kcompletion kconfig
kcoreaddons kdelibs4support kdbusaddons kfilemetadata ki18n kiconthemes
kinit kio knewstuff knotifications kparts ktexteditor kwindowsystem
phonon solid
];
};
in
kdeWrapper unwrapped
{
targets = [ "bin/dolphin" ];
paths = [ dolphin-plugins ];
}

View file

@ -24,7 +24,10 @@ let
let
in stdenv.mkDerivation (args // {
outputs = args.outputs or [ "dev" "out" ];
outputs = args.outputs or [ "dev" "out" "bin" ];
propagatedUserEnvPkgs =
builtins.map lib.getBin (args.propagatedBuildInputs or []);
cmakeFlags =
(args.cmakeFlags or [])
@ -50,6 +53,17 @@ let
} // (args.meta or {});
});
kdeEnv = import ./kde-env.nix {
inherit (pkgs) stdenv lib;
inherit (pkgs.xorg) lndir;
inherit ecmNoHooks;
};
kdeWrapper = import ./kde-wrapper.nix {
inherit (pkgs) stdenv lib makeWrapper;
inherit kdeEnv;
};
attica = callPackage ./attica.nix {};
baloo = callPackage ./baloo.nix {};
bluez-qt = callPackage ./bluez-qt.nix {};

View file

@ -0,0 +1,34 @@
{ stdenv, lib, lndir, ecmNoHooks }:
name: pkgs:
let
inherit (builtins.parseDrvName ecmNoHooks.name) version;
in
stdenv.mkDerivation {
name = "kde-env-${name}";
nativeBuildInputs = [ lndir ];
propagatedUserEnvPkgs = builtins.map lib.getBin pkgs;
unpackPhase = "true";
configurePhase = "runHook preConfigure; runHook postConfigure";
buildPhase = "true";
installPhase = ''
runHook preInstall
propagated=""
for i in $propagatedUserEnvPkgs; do
findInputs $i propagated propagated-user-env-packages
done
for tgt in bin etc/xdg lib/libexec lib/qt5 share; do
mkdir -p "$out/$tgt"
for p in $propagated; do
if [ -d "$p/$tgt" ]; then
lndir -silent "$p/$tgt" "$out/$tgt" >/dev/null 2>&1
fi
done
done
runHook postInstall
'';
}

View file

@ -0,0 +1,47 @@
{ stdenv, lib, makeWrapper, kdeEnv }:
drv:
{ targets, paths }:
let
env = kdeEnv drv.name ([ drv ] ++ paths);
in
stdenv.mkDerivation {
inherit (drv) name;
drv = lib.getBin drv;
inherit env targets;
passthru = { unwrapped = drv; };
nativeBuildInputs = [ makeWrapper ];
unpackPhase = "true";
configurePhase = "runHook preConfigure; runHook postConfigure";
buildPhase = "true";
installPhase = ''
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/etc/xdg" \
--prefix XDG_DATA_DIRS : "$env/share" \
--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"
exit 1
fi
done
for s in applications dbus-1 desktop-directories icons mime polkit-1; do
if [ -d "$env/share/$s" ]; then
mkdir -p "$out/share"
ln -s "$env/share/$s" "$out/share/$s"
fi
done
'';
}

View file

@ -1,60 +1,9 @@
_ecmSetXdgDirs() {
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
addToSearchPathOnce XDG_CONFIG_DIRS "$1/etc/xdg"
addToSearchPathOnce RUNTIME_XDG_CONFIG_DIRS "$1/etc/xdg"
}
_ecmSharePaths=( \
"appdata" \
"applications" \
"config.cfg" \
"dbus-1" \
"desktop-directories" \
"doc" \
"icons" \
"kconf_update" \
"kservices5" \
"kservicetypes5" \
"knotifications5" \
"kxmlgui5" \
"locale" \
"mime" \
"polkit-1" \
"sounds" \
"templates" \
"wallpapers" )
_ecmPropagateNative() {
local target
for dir in ${_ecmSharePaths[@]}; do
target=$(readlink -m "$1/share/$dir")
if [ "$target" != "$1/share" ] && [ -d "$target" ]; then
propagateOnce propagatedNativeBuildInputs "$1"
if [ -z "$crossConfig" ]; then
propagateOnce propagatedUserEnvPkgs "$1"
addToSearchPathOnce RUNTIME_XDG_DATA_DIRS "$1/share"
fi
break
fi
done
}
envHooks+=(_ecmSetXdgDirs _ecmPropagate)
_ecmPropagate() {
local target
for dir in ${_ecmSharePaths[@]}; do
target=$(readlink -m "$1/share/$dir")
if [ "$target" != "$1/share" ] && [ -d "$target" ]; then
propagateOnce propagatedBuildInputs "$1"
propagateOnce propagatedUserEnvPkgs "$1"
addToSearchPathOnce RUNTIME_XDG_DATA_DIRS "$1/share"
break
fi
done
}
crossEnvHooks+=(_ecmPropagate)
envHooks+=(_ecmSetXdgDirs)
_ecmConfig() {
# Because we need to use absolute paths here, we must set *all* the paths.
@ -62,41 +11,41 @@ _ecmConfig() {
cmakeFlags+=" -DKDE_INSTALL_BINDIR=${!outputBin}/bin"
cmakeFlags+=" -DKDE_INSTALL_SBINDIR=${!outputBin}/sbin"
cmakeFlags+=" -DKDE_INSTALL_LIBDIR=${!outputLib}/lib"
cmakeFlags+=" -DKDE_INSTALL_LIBEXECDIR=${!outputLib}/lib/libexec"
cmakeFlags+=" -DKDE_INSTALL_LIBEXECDIR=${!outputBin}/lib/libexec"
cmakeFlags+=" -DKDE_INSTALL_CMAKEPACKAGEDIR=${!outputDev}/lib/cmake"
cmakeFlags+=" -DKDE_INSTALL_QTPLUGINDIR=${!outputLib}/lib/qt5/plugins"
cmakeFlags+=" -DKDE_INSTALL_PLUGINDIR=${!outputLib}/lib/qt5/plugins"
cmakeFlags+=" -DKDE_INSTALL_QTQUICKIMPORTSDIR=${!outputLib}/lib/qt5/imports"
cmakeFlags+=" -DKDE_INSTALL_QMLDIR=${!outputLib}/lib/qt5/qml"
cmakeFlags+=" -DKDE_INSTALL_QTPLUGINDIR=${!outputBin}/lib/qt5/plugins"
cmakeFlags+=" -DKDE_INSTALL_PLUGINDIR=${!outputBin}/lib/qt5/plugins"
cmakeFlags+=" -DKDE_INSTALL_QTQUICKIMPORTSDIR=${!outputBin}/lib/qt5/imports"
cmakeFlags+=" -DKDE_INSTALL_QMLDIR=${!outputBin}/lib/qt5/qml"
cmakeFlags+=" -DKDE_INSTALL_INCLUDEDIR=${!outputInclude}/include"
cmakeFlags+=" -DKDE_INSTALL_LOCALSTATEDIR=/var"
cmakeFlags+=" -DKDE_INSTALL_DATAROOTDIR=${!outputLib}/share"
cmakeFlags+=" -DKDE_INSTALL_DATADIR=${!outputLib}/share"
cmakeFlags+=" -DKDE_INSTALL_DOCBUNDLEDIR=${!outputLib}/share/doc/HTML"
cmakeFlags+=" -DKDE_INSTALL_KCFGDIR=${!outputLib}/share/config.kcfg"
cmakeFlags+=" -DKDE_INSTALL_KCONFUPDATEDIR=${!outputLib}/share/kconf_update"
cmakeFlags+=" -DKDE_INSTALL_KSERVICES5DIR=${!outputLib}/share/kservices5"
cmakeFlags+=" -DKDE_INSTALL_KSERVICETYPES5DIR=${!outputLib}/share/kservicetypes5"
cmakeFlags+=" -DKDE_INSTALL_KXMLGUI5DIR=${!outputLib}/share/kxmlgui5"
cmakeFlags+=" -DKDE_INSTALL_KNOTIFY5RCDIR=${!outputLib}/share/knotifications5"
cmakeFlags+=" -DKDE_INSTALL_ICONDIR=${!outputLib}/share/icons"
cmakeFlags+=" -DKDE_INSTALL_LOCALEDIR=${!outputLib}/share/locale"
cmakeFlags+=" -DKDE_INSTALL_SOUNDDIR=${!outputLib}/share/sounds"
cmakeFlags+=" -DKDE_INSTALL_TEMPLATEDIR=${!outputLib}/share/templates"
cmakeFlags+=" -DKDE_INSTALL_WALLPAPERDIR=${!outputLib}/share/wallpapers"
cmakeFlags+=" -DKDE_INSTALL_APPDIR=${!outputLib}/share/applications"
cmakeFlags+=" -DKDE_INSTALL_DESKTOPDIR=${!outputLib}/share/desktop-directories"
cmakeFlags+=" -DKDE_INSTALL_MIMEDIR=${!outputLib}/share/mime/packages"
cmakeFlags+=" -DKDE_INSTALL_METAINFODIR=${!outputLib}/share/appdata"
cmakeFlags+=" -DKDE_INSTALL_MANDIR=${!outputLib}/share/man"
cmakeFlags+=" -DKDE_INSTALL_INFODIR=${!outputLib}/share/info"
cmakeFlags+=" -DKDE_INSTALL_DBUSDIR=${!outputLib}/share/dbus-1"
cmakeFlags+=" -DKDE_INSTALL_DBUSINTERFACEDIR=${!outputLib}/share/dbus-1/interfaces"
cmakeFlags+=" -DKDE_INSTALL_DBUSSERVICEDIR=${!outputLib}/share/dbus-1/services"
cmakeFlags+=" -DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputLib}/share/dbus-1/system-services"
cmakeFlags+=" -DKDE_INSTALL_SYSCONFDIR=${!outputLib}/etc"
cmakeFlags+=" -DKDE_INSTALL_CONFDIR=${!outputLib}/etc/xdg"
cmakeFlags+=" -DKDE_INSTALL_AUTOSTARTDIR=${!outputLib}/etc/xdg/autostart"
cmakeFlags+=" -DKDE_INSTALL_DATAROOTDIR=${!outputBin}/share"
cmakeFlags+=" -DKDE_INSTALL_DATADIR=${!outputBin}/share"
cmakeFlags+=" -DKDE_INSTALL_DOCBUNDLEDIR=${!outputBin}/share/doc/HTML"
cmakeFlags+=" -DKDE_INSTALL_KCFGDIR=${!outputBin}/share/config.kcfg"
cmakeFlags+=" -DKDE_INSTALL_KCONFUPDATEDIR=${!outputBin}/share/kconf_update"
cmakeFlags+=" -DKDE_INSTALL_KSERVICES5DIR=${!outputBin}/share/kservices5"
cmakeFlags+=" -DKDE_INSTALL_KSERVICETYPES5DIR=${!outputBin}/share/kservicetypes5"
cmakeFlags+=" -DKDE_INSTALL_KXMLGUI5DIR=${!outputBin}/share/kxmlgui5"
cmakeFlags+=" -DKDE_INSTALL_KNOTIFY5RCDIR=${!outputBin}/share/knotifications5"
cmakeFlags+=" -DKDE_INSTALL_ICONDIR=${!outputBin}/share/icons"
cmakeFlags+=" -DKDE_INSTALL_LOCALEDIR=${!outputBin}/share/locale"
cmakeFlags+=" -DKDE_INSTALL_SOUNDDIR=${!outputBin}/share/sounds"
cmakeFlags+=" -DKDE_INSTALL_TEMPLATEDIR=${!outputBin}/share/templates"
cmakeFlags+=" -DKDE_INSTALL_WALLPAPERDIR=${!outputBin}/share/wallpapers"
cmakeFlags+=" -DKDE_INSTALL_APPDIR=${!outputBin}/share/applications"
cmakeFlags+=" -DKDE_INSTALL_DESKTOPDIR=${!outputBin}/share/desktop-directories"
cmakeFlags+=" -DKDE_INSTALL_MIMEDIR=${!outputBin}/share/mime/packages"
cmakeFlags+=" -DKDE_INSTALL_METAINFODIR=${!outputBin}/share/appdata"
cmakeFlags+=" -DKDE_INSTALL_MANDIR=${!outputBin}/share/man"
cmakeFlags+=" -DKDE_INSTALL_INFODIR=${!outputBin}/share/info"
cmakeFlags+=" -DKDE_INSTALL_DBUSDIR=${!outputBin}/share/dbus-1"
cmakeFlags+=" -DKDE_INSTALL_DBUSINTERFACEDIR=${!outputBin}/share/dbus-1/interfaces"
cmakeFlags+=" -DKDE_INSTALL_DBUSSERVICEDIR=${!outputBin}/share/dbus-1/services"
cmakeFlags+=" -DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputBin}/share/dbus-1/system-services"
cmakeFlags+=" -DKDE_INSTALL_SYSCONFDIR=${!outputBin}/etc"
cmakeFlags+=" -DKDE_INSTALL_CONFDIR=${!outputBin}/etc/xdg"
cmakeFlags+=" -DKDE_INSTALL_AUTOSTARTDIR=${!outputBin}/etc/xdg/autostart"
}
preConfigureHooks+=(_ecmConfig)