3
0
Fork 0
forked from mirrors/nixpkgs

add versionedDerivation

This commit is contained in:
Marc Weber 2013-05-05 17:05:59 +02:00 committed by Evgeny Egorochkin
parent e0fab80c27
commit b50b9bf2b7
3 changed files with 13 additions and 3 deletions

View file

@ -321,12 +321,12 @@ rec {
#
# This function is best explained by an example:
#
# {version ? "2.0"} :
# {version ? "2.x"} :
#
# mkDerivation (mergeAttrsByVersion "package-name" version
# { # version specific settings
# "git" = { src = ..; preConfigre = "autogen.sh"; buildInputs = [automake autoconf libtool]; };
# "2.0" = { src = ..; };
# "2.x" = { src = ..; };
# }
# { // shared settings
# buildInputs = [ common build inputs ];
@ -347,7 +347,12 @@ rec {
# Very often it just happens that the "shared" code is the bigger part.
# Then using this function might be appropriate.
#
# Be aware that its easy to cause recompilations in all versions when using this function
# Be aware that its easy to cause recompilations in all versions when using
# this function - also if derivations get too complex splitting into multiple
# files is the way to go.
#
# See misc.nix -> versionedDerivation
# discussion: nixpkgs: pull/310
mergeAttrsByVersion = name: version: attrsByVersion: base:
mergeAttrsByFuncDefaultsClean [ { name = "${name}-${version}"; } base (maybeAttr version (throw "bad version ${version} for ${name}") attrsByVersion)];

View file

@ -6,6 +6,10 @@ in
{
# description see mergeAttrsByVersion in lib/misc.nix
versionedDerivation = name: version: attrsByVersion: base:
pkgs.stdenv.mkDerivation (stdenv.lib.mergeAttrsByVersion name version attrsByVersion base);
/*
Usage example creating a derivation installing ruby, sup and a lib:

View file

@ -187,6 +187,7 @@ let
inherit lib config stdenvAdapters;
inherit (lib) lowPrio hiPrio appendToName makeOverridable;
inherit (misc) versionedDerivation;
# Applying this to an attribute set will cause nix-env to look
# inside the set for derivations.