Allow options with type "package" to be store paths

For example, this allows writing

  nix.package = /nix/store/786mlvhd17xvcp2r4jmmay6jj4wj6b7f-nix-1.10pre4206_896428c;

Also, document types.package in the manual.
This commit is contained in:
Eelco Dolstra
2015-08-07 03:09:57 +02:00
parent fa7a0f24a4
commit 214d4fb73c
4 changed files with 30 additions and 4 deletions
+10
View File
@@ -221,6 +221,16 @@ rec {
isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
/* Convert a store path to a fake derivation. */
toDerivation = path:
let path' = builtins.storePath path; in
{ type = "derivation";
name = builtins.unsafeDiscardStringContext (builtins.substring 33 (-1) (baseNameOf path'));
outPath = path';
outputs = [ "out" ];
};
/* If the Boolean `cond' is true, return the attribute set `as',
otherwise an empty attribute set. */
optionalAttrs = cond: as: if cond then as else {};