diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix index bd57d2b6518f..19e5081009de 100644 --- a/pkgs/lib/misc.nix +++ b/pkgs/lib/misc.nix @@ -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)]; diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix index df4a0ce81023..87be974ca969 100644 --- a/pkgs/misc/misc.nix +++ b/pkgs/misc/misc.nix @@ -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: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d39d23a0b3a2..2dfb001bdf5f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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.