From 365cb2d2625086e35c24eb8a49787055c40ea545 Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Fri, 19 Aug 2011 15:37:12 +0000 Subject: [PATCH] kde-4.7: let nix-env and hydra find all modules List of changes: * All individual packages moved to the top-level kde47 namespace. * Utility functions moved back to kde-package/default.nix nix-env will not find kde-4.7 modules unless you add something like 'kde4 = pkgs.recurseIntoAttrs pkgs.kde47;' to your packageOverrides. This is done because kde-4.7.0 on NixOS is not ready yet. svn path=/nixpkgs/trunk/; revision=28693 --- pkgs/desktops/kde-4.7/default.nix | 104 +++------------ pkgs/desktops/kde-4.7/kde-package/default.nix | 120 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 3 files changed, 136 insertions(+), 89 deletions(-) create mode 100644 pkgs/desktops/kde-4.7/kde-package/default.nix diff --git a/pkgs/desktops/kde-4.7/default.nix b/pkgs/desktops/kde-4.7/default.nix index a6f94c9e82e..219d0e97ec5 100644 --- a/pkgs/desktops/kde-4.7/default.nix +++ b/pkgs/desktops/kde-4.7/default.nix @@ -1,92 +1,25 @@ -{ callPackage, runCommand, stdenv, fetchurl, qt47, cmake, automoc4 }: +{ callPackage, callPackageOrig, stdenv, qt47 }: let release = "4.7.0"; - manifest = import (./kde-package + "/${release}.nix"); - - kdesrc = name: fetchurl { - url = "mirror://kde/" + (if manifest.stable then "" else "un") - + "stable/${release}/src/${name}-${release}.tar.bz2"; - sha256 = builtins.getAttr name manifest.hashes; + # Need callPackageOrig to avoid infinite cycle + kde = callPackageOrig ./kde-package { + inherit release ignoreList extraSubpkgs callPackage; }; - mergeMeta = meta: - { - homepage = http://www.kde.org; - inherit (qt47.meta) platforms maintainers; - } // meta; - - kdeMonoPkg = name: a@{meta, ...}: - stdenv.mkDerivation ({ - name = "${name}-${release}"; - src = kdesrc name; - meta = mergeMeta meta; - } // (builtins.removeAttrs a [ "meta" ])); - kdeMonolithic = name: path: callPackage path { kde = kdeMonoPkg name; }; - - kdeSubdirPkg = module: - {name, subdir ? name, sane ? name}: - let name_ = name; in - a@{cmakeFlags ? [], name ? name_, ...}: - stdenv.mkDerivation ({ - name = "${name}-${release}"; - src = kdesrc module; - cmakeFlags = ["-DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE" - "-DBUILD_doc=TRUE" "-DBUILD_${subdir}=TRUE"] ++ cmakeFlags; - } // (removeAttrs a [ "name" "cmakeFlags" ])); - - kdeSplittedPkg = module: {name, sane ? name}: kdeMonoPkg name; - - combinePkgs = pkgFun: module: pkgs: - let - f = p@{name, ...}: - callPackage (./. + "/${module}/${name}.nix") { kde = pkgFun module p; }; - list = map f pkgs; - attrs = builtins.listToAttrs (map - ({name, sane ? name, ...}@p: { name = sane; value = f p; }) - pkgs); - in - runCommand "${module}-${release}" - ({passthru = attrs // { - propagatedUserEnvPackages = list; - recurseForDerivations = true; - projects = attrs; - };}) - '' - mkdir -pv $out/nix-support - echo "${toString list}" | tee $out/nix-support/propagated-user-env-packages - ''; - - kdeModule = { module, sane ? module, split, pkgs ? [] }: - let pkgs_ = filterPkgs module pkgs; in - { - name = sane; - value = - # Module is splitted by upstream - if split then combinePkgs kdeSplittedPkg module pkgs_ - # Monolithic module - else if pkgs == [] then kdeMonolithic module (./. + "/${module}.nix") - # Module is splitted by us - else combinePkgs kdeSubdirPkg module pkgs_; - }; - - kdepkgs = builtins.listToAttrs (map kdeModule manifest.modules); - - filterPkgs = module: (p: - removeNames (stdenv.lib.attrByPath [module] [] ignoreList) p - ++ (stdenv.lib.attrByPath [module] [] extraSubpkgs)); - -# List difference, big - subst; optimised for empty subst - removeNames = subst: big: stdenv.lib.fold (s: out: stdenv.lib.filter (x: x.name != s) out) big subst; - + # The list of igored individual modules ignoreList = { + # kdeadmin/strigi-analyzer has no real code kdeadmin = [ "strigi-analyzer" ]; + # kdesdk/kioslave is splitted into kioslave-svn and kioslave-git kdesdk = [ "kioslave" ]; + # Most of kdebindings do not compile due to a bug in the buildsystem kdebindings = [ "kimono" "korundum" "kross-interpreters" "perlkde" "perlqt" "qtruby" "qyoto" "smokekde" ]; }; + # Extra subpackages in the manifest format extraSubpkgs = { kdesdk = [ @@ -104,29 +37,22 @@ let }; in -kdepkgs // kdepkgs.kdebase // + +kde.modules // kde.individual // { + inherit (kde) manifest modules individual splittedModuleList; recurseForRelease = true; + akonadi = callPackage ./support/akonadi { }; soprano = callPackage ./support/soprano { }; qt4 = qt47; - kdebase_workspace = kdepkgs.kdebase.kde_workspace; - -# Propagate some libraries to the top-level - inherit (kdepkgs.kdegraphics) libkdcraw libkipi libkexiv2 libksane; - inherit (kdepkgs.kdebindings) pykde4; - inherit (kdepkgs.kdeedu) libkdeedu; + kdebase_workspace = kde.individual.kde_workspace; inherit release; -# nix-instantiate /etc/nixos/nixpkgs -A kde47.moduleNames --strict to see -# available packages - moduleNames = stdenv.lib.mapAttrs - (n: v: if v ? projects then builtins.attrNames v.projects else null) kdepkgs; - - full = stdenv.lib.attrValues kdepkgs; + full = stdenv.lib.attrValues kde.modules; l10n = callPackage ./l10n { inherit release; }; } diff --git a/pkgs/desktops/kde-4.7/kde-package/default.nix b/pkgs/desktops/kde-4.7/kde-package/default.nix new file mode 100644 index 00000000000..cd1cd5be9b9 --- /dev/null +++ b/pkgs/desktops/kde-4.7/kde-package/default.nix @@ -0,0 +1,120 @@ +{ callPackage, runCommand, stdenv, fetchurl, qt4, cmake, automoc4 +, release, ignoreList, extraSubpkgs +}: + +let + inherit (stdenv.lib) filter fold; + inherit (builtins) getAttr hasAttr remoteAttrs listToAttrs tail head; +in +rec { + manifest = import (./. + "/${release}.nix"); + + # src attribute for $name tarball + kdesrc = name: fetchurl { + url = "mirror://kde/" + (if manifest.stable then "" else "un") + + "stable/${release}/src/${name}-${release}.tar.bz2"; + sha256 = getAttr name manifest.hashes; + }; + + # Default meta attribute + defMeta = { + homepage = http://www.kde.org; + inherit (qt4.meta) platforms 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; in a@{meta, name ? n_, ...}: + stdenv.mkDerivation ({ + name = "${name}-${release}"; + src = kdesrc name; + meta = defMeta // meta; + } // (removeAttrs a [ "meta" "name" ])); + + # kdeMonoPkg wrapper for modules splitted upstream. Used in TODO + kdeSplittedPkg = module: {name, sane ? name}: kdeMonoPkg name; + + # Build subdirectory ${subdir} of tarball ${module}-${release}.tar.bz2 + kdeSubdirPkg = module: + {name, subdir ? name, sane ? name}: + let name_ = name; in + a@{cmakeFlags ? [], name ? name_, ...}: + stdenv.mkDerivation ({ + name = "${name}-${release}"; + src = kdesrc module; + cmakeFlags = ["-DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE" + "-DBUILD_doc=TRUE" "-DBUILD_${subdir}=TRUE"] ++ cmakeFlags; + } // (removeAttrs a [ "cmakeFlags" ])); + + # 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; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6715f989fbf..af3781fa1d6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7838,6 +7838,7 @@ let kde47 = callPackage ../desktops/kde-4.7 { callPackage = newScope pkgs.kde47; + callPackageOrig = callPackage; }; redshift = callPackage ../applications/misc/redshift {