From 214d4fb73cd5c2aab6718a38b35c8b5217f0f200 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 6 Aug 2015 19:55:42 +0200 Subject: 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. --- lib/attrsets.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/attrsets.nix') diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 20be2002402cd..2300ee9c000b4 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -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 {}; -- cgit 1.4.1