nixpkgs-suyu/pkgs/desktops/kde-4.14/kde-package/default.nix

135 lines
4.6 KiB
Nix
Raw Normal View History

{ callPackage, runCommand, stdenv, fetchurl, qt4, cmake-2_8, automoc4, perl, pkgconfig
2014-09-20 11:09:11 +02:00
, release, branch, ignoreList, extraSubpkgs
}:
let
inherit (stdenv.lib) filter fold;
inherit (builtins) getAttr hasAttr remoteAttrs listToAttrs tail head;
cmake = cmake-2_8;
2014-09-20 11:09:11 +02:00
in
rec {
manifest = import (./. + "/${release}.nix");
# src attribute for $name tarball
kdesrc = name: version: fetchurl {
2014-09-20 11:09:11 +02:00
url = "mirror://kde/" + (if manifest.stable then "" else "un")
+ "stable/${release}/src/${name}-${version}.tar.xz";
2014-09-20 11:09:11 +02:00
sha256 = getAttr name manifest.hashes;
};
# Default meta attribute
defMeta = {
homepage = http://www.kde.org;
inherit branch;
platforms = stdenv.lib.platforms.linux;
inherit (qt4.meta) maintainers;
};
# KDE package built from the whole tarball
# This function is used both for monolithic modules and modules which are
# released as individual tarballs
kdeMonoPkg = name:
let n_ = name; v_ = getAttr name manifest.versions; in
a@{meta, name ? n_, version ? v_, nativeBuildInputs ? [], ...}:
2014-09-20 11:09:11 +02:00
stdenv.mkDerivation ({
name = "${name}-${version}";
src = kdesrc name version;
nativeBuildInputs = nativeBuildInputs ++ [ automoc4 cmake perl pkgconfig ];
2014-09-20 11:09:11 +02:00
meta = defMeta // meta;
enableParallelBuilding = true;
} // (removeAttrs a [ "meta" "name" "nativeBuildInputs" ]));
2014-09-20 11:09:11 +02:00
# kdeMonoPkg wrapper for modules splitted upstream compatible with combinePkgs
# API.
kdeSplittedPkg = module: {name, sane ? name}: kdeMonoPkg name;
# Build subdirectory ${subdir} of tarball ${module}-${release}.tar.xz
kdeSubdirPkg = module:
{name, subdir ? name, sane ? name}:
let name_ = name; version_ = getAttr module manifest.versions; in
a@{cmakeFlags ? [], name ? name_, version ? version_, meta ? {}, nativeBuildInputs ? [], ...}:
2014-09-20 11:09:11 +02:00
stdenv.mkDerivation ({
name = "${name}-${release}";
src = kdesrc module version;
nativeBuildInputs = nativeBuildInputs ++ [ automoc4 cmake perl pkgconfig ];
2014-09-20 11:09:11 +02:00
cmakeFlags =
[ "-DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE"
"-DBUILD_doc=TRUE"
"-DBUILD_${subdir}=TRUE"
] ++ cmakeFlags;
meta = defMeta // meta;
enableParallelBuilding = module.enableParallelBuilding or true;
} // (removeAttrs a [ "meta" "name" "cmakeFlags" "nativeBuildInputs" ]));
2014-09-20 11:09:11 +02:00
# A KDE monolithic module
kdeMonoModule = name: path: callPackage path { kde = kdeMonoPkg name; };
# Combine packages in one module.
# Arguments:
# * pkgFun --- a function of the following signature:
# module: manifest_attrs: manual_attrs: derivation;
# * module --- name of the module
# * pkgs --- list of packages in manifest format
combinePkgs = pkgFun: module: pkgs:
let
f = p@{name, ...}:
callPackage (./.. + "/${module}/${name}.nix") { kde = pkgFun module p; };
list = map f pkgs;
attrs = listToAttrs (map
({name, sane ? name, ...}@p: { name = sane; value = f p; })
pkgs);
in
runCommand "${module}-${release}"
({passthru = attrs // {
propagatedUserEnvPackages = list;
projects = attrs;
};})
''
mkdir -pv $out/nix-support
echo "${toString list}" | tee $out/nix-support/propagated-user-env-packages
'';
# Given manifest module data, return the module
kdeModule = { module, sane ? module, split, pkgs ? [] }:
let
pkgs_ = filterPkgs module pkgs;
in
# Module is splitted by upstream
if split then combinePkgs kdeSplittedPkg module pkgs_
# Monolithic module
else if pkgs == [] then kdeMonoModule module (./.. + "/${module}.nix")
# Module is splitted by us
else combinePkgs kdeSubdirPkg module pkgs_;
# The same, as nameValuePair with sane name
kdeModuleNV = a@{ module, sane ? module, ... }:
{ name = sane; value = kdeModule a; };
filterPkgs = module: (p:
removeNames (stdenv.lib.attrByPath [module] [] ignoreList) p
++ (stdenv.lib.attrByPath [module] [] extraSubpkgs));
# Remove attrsets with x.name in subst. Optimized for empty subst.
removeNames = subst: big:
fold (s: out: filter (x: x.name != s) out) big subst;
modules = listToAttrs (map kdeModuleNV manifest.modules);
splittedModuleList =
let
splitted = filter (a: a ? pkgs) manifest.modules;
names = map ({module, sane ? module, ...}: sane) splitted;
in
map (m: m.projects) (stdenv.lib.attrVals names modules);
individual =
stdenv.lib.zipAttrsWith
(
name: list:
if tail list == []
then head list
else abort "Multiple modules define ${name}"
)
splittedModuleList;
}