3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/r-modules/cran-packages.nix

194 lines
4.9 KiB
Nix
Raw Normal View History

2014-11-21 13:23:36 +00:00
/* This file defines the composition for CRAN (R) packages. */
{ pkgs, overrides }:
let
2014-11-21 13:23:36 +00:00
inherit (pkgs) R fetchurl stdenv lib xvfb_run utillinux;
2014-11-21 13:23:36 +00:00
buildRPackage = import ./generic-builder.nix { inherit R xvfb_run utillinux ; };
2014-11-21 13:23:36 +00:00
# Package template
#
# some packages, e.g. cncaGUI, require X running while installation,
# so that we use xvfb-run if requireX is true.
derive = lib.makeOverridable ({
name, version, sha256,
depends ? [],
doCheck ? true,
requireX ? false,
broken ? false,
hydraPlatforms ? R.meta.hydraPlatforms
}: buildRPackage {
name = "${name}-${version}";
src = fetchurl {
urls = [
"mirror://cran/src/contrib/${name}_${version}.tar.gz"
"mirror://cran/src/contrib/Archive/${name}/${name}_${version}.tar.gz"
];
inherit sha256;
};
inherit doCheck requireX;
propagatedBuildInputs = depends;
2014-11-21 13:23:36 +00:00
nativeBuildInputs = depends;
meta.homepage = "http://cran.r-project.org/web/packages/${name}/";
meta.hydraPlatforms = hydraPlatforms;
meta.broken = broken;
2014-11-21 13:23:36 +00:00
});
2014-11-21 13:23:36 +00:00
# Overrides package definitions with nativeBuildInputs.
# For example,
#
# overrideNativeBuildInputs {
# foo = [ pkgs.bar ]
# } old
#
# results in
#
# {
# foo = old.foo.overrideDerivation (attrs: {
2014-11-21 13:23:36 +00:00
# nativeBuildInputs = attrs.nativeBuildInputs ++ [ pkgs.bar ];
# });
# }
overrideNativeBuildInputs = overrides: old:
let
attrNames = builtins.attrNames overrides;
nameValuePairs = map (name: rec {
inherit name;
nativeBuildInputs = builtins.getAttr name overrides;
value = (builtins.getAttr name old).overrideDerivation (attrs: {
2014-11-21 13:23:36 +00:00
nativeBuildInputs = attrs.nativeBuildInputs ++ nativeBuildInputs;
});
}) attrNames;
in
builtins.listToAttrs nameValuePairs;
2014-11-21 13:23:36 +00:00
# Overrides package definitions with buildInputs.
# For example,
#
# overrideBuildInputs {
# foo = [ pkgs.bar ]
# } old
#
# results in
#
# {
# foo = old.foo.overrideDerivation (attrs: {
2014-11-21 13:23:36 +00:00
# buildInputs = attrs.buildInputs ++ [ pkgs.bar ];
# });
# }
overrideBuildInputs = overrides: old:
let
attrNames = builtins.attrNames overrides;
nameValuePairs = map (name: rec {
inherit name;
buildInputs = builtins.getAttr name overrides;
value = (builtins.getAttr name old).overrideDerivation (attrs: {
2014-11-21 13:23:36 +00:00
buildInputs = attrs.buildInputs ++ buildInputs;
});
}) attrNames;
in
builtins.listToAttrs nameValuePairs;
2014-11-21 13:23:36 +00:00
# Overrides package definition requiring X running to install.
# For example,
#
# overrideRequireX [
# "foo"
# ] old
#
# results in
#
# {
# foo = old.foo.override {
# requireX = true;
# };
# }
overrideRequireX = packageNames: old:
let
nameValuePairs = map (name: {
inherit name;
value = (builtins.getAttr name old).override {
requireX = true;
};
}) packageNames;
in
builtins.listToAttrs nameValuePairs;
# Overrides package definition to skip check.
2014-11-21 13:23:36 +00:00
# For example,
#
# overrideSkipCheck [
2014-11-21 13:23:36 +00:00
# "foo"
# ] old
#
# results in
#
# {
# foo = old.foo.override {
# doCheck = false;
2014-11-21 13:23:36 +00:00
# };
# }
overrideSkipCheck = packageNames: old:
2014-11-21 13:23:36 +00:00
let
nameValuePairs = map (name: {
inherit name;
value = (builtins.getAttr name old).override {
doCheck = false;
2014-11-21 13:23:36 +00:00
};
}) packageNames;
in
builtins.listToAttrs nameValuePairs;
# Overrides package definition to mark it broken.
# For example,
#
# overrideBroken [
# "foo"
# ] old
#
# results in
#
# {
# foo = old.foo.override {
# broken = true;
# };
# }
overrideBroken = packageNames: old:
let
nameValuePairs = map (name: {
inherit name;
value = (builtins.getAttr name old).override {
broken = true;
};
}) packageNames;
in
builtins.listToAttrs nameValuePairs;
inherit (import ./default-overrides.nix stdenv pkgs)
packagesWithNativeBuildInputs
packagesWithBuildInputs
packagesRequireingX
packagesToSkipCheck
brokenPackages
otherOverrides;
2014-11-21 13:23:36 +00:00
defaultOverrides = old: new:
let old0 = old; in
let
old1 = old0 // (overrideRequireX packagesRequireingX old0);
old2 = old1 // (overrideSkipCheck packagesToSkipCheck old1);
2014-11-21 13:23:36 +00:00
old3 = old2 // (overrideNativeBuildInputs packagesWithNativeBuildInputs old2);
old4 = old3 // (overrideBuildInputs packagesWithBuildInputs old3);
old5 = old4 // (overrideBroken brokenPackages old4);
old = old5;
in old // (otherOverrides old new);
2014-11-21 13:23:36 +00:00
# Recursive override pattern.
# `_self` is a collection of packages;
# `self` is `_self` with overridden packages;
# packages in `_self` may depends on overridden packages.
self = (defaultOverrides _self self) // overrides;
2014-11-21 13:23:36 +00:00
_self = import ./sources.nix { inherit self derive; };
in
self