diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-08-06 19:55:42 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-08-07 03:09:57 +0200 |
commit | 214d4fb73cd5c2aab6718a38b35c8b5217f0f200 (patch) | |
tree | f78ea308807277211b91f5d692eedce3a842501d /lib/attrsets.nix | |
parent | fa7a0f24a4c8e02789be6b5c9c83c4c3ee6948a5 (diff) | |
download | nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar.gz nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar.bz2 nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar.lz nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar.xz nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.tar.zst nixpkgs-214d4fb73cd5c2aab6718a38b35c8b5217f0f200.zip |
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.
Diffstat (limited to 'lib/attrsets.nix')
-rw-r--r-- | lib/attrsets.nix | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 20be2002402..2300ee9c000 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 {}; |