Revert "Refactor: introduce isType reducing redundancy (trivial change)"

This reverts commit 52204af457.  It
breaks Nixpkgs evaluation.

http://hydra.nixos.org/build/5758197
This commit is contained in:
Eelco Dolstra 2013-08-22 16:39:25 +02:00
parent 57032af1ae
commit d28a189af6
4 changed files with 18 additions and 19 deletions

View File

@ -11,10 +11,10 @@ with import ./properties.nix;
rec { rec {
inherit (lib) isType; inherit (lib) typeOf;
isOption = isType "option"; isOption = attrs: (typeOf attrs) == "option";
mkOption = attrs: attrs // { mkOption = attrs: attrs // {
_type = "option"; _type = "option";
# name (this is the name of the attributem it is automatically generated by the traversal) # name (this is the name of the attributem it is automatically generated by the traversal)
@ -190,7 +190,7 @@ rec {
defValue = builtins.getAttr defName defs; defValue = builtins.getAttr defName defs;
optValue = builtins.getAttr defName opts; optValue = builtins.getAttr defName opts;
in in
if isOption defValue if typeOf defValue == "option"
then then
# `defValue' is an option. # `defValue' is an option.
if hasAttr defName opts if hasAttr defName opts

View File

@ -11,13 +11,13 @@ with import ./attrsets.nix;
rec { rec {
inherit (lib) isType; inherit (lib) typeOf;
# Tell that nothing is defined. When properties are evaluated, this type # Tell that nothing is defined. When properties are evaluated, this type
# is used to remove an entry. Thus if your property evaluation semantic # is used to remove an entry. Thus if your property evaluation semantic
# implies that you have to mute the content of an attribute, then your # implies that you have to mute the content of an attribute, then your
# property should produce this value. # property should produce this value.
isNotdef = isType "notdef"; isNotdef = attrs: (typeOf attrs) == "notdef";
mkNotdef = {_type = "notdef";}; mkNotdef = {_type = "notdef";};
# General property type, it has a property attribute and a content # General property type, it has a property attribute and a content
@ -32,7 +32,7 @@ rec {
# - onGlobalDelay: run on all copied properties. # - onGlobalDelay: run on all copied properties.
# - onEval: run on an evaluated property. # - onEval: run on an evaluated property.
# - onGlobalEval: run on a list of property stack on top of their values. # - onGlobalEval: run on a list of property stack on top of their values.
isProperty = isType "property"; isProperty = attrs: (typeOf attrs) == "property";
mkProperty = p@{property, content, ...}: p // { mkProperty = p@{property, content, ...}: p // {
_type = "property"; _type = "property";
}; };
@ -187,7 +187,7 @@ rec {
# and interpreted by the underlying system using properties (modules). # and interpreted by the underlying system using properties (modules).
# Create a "Merge" property which only contains a condition. # Create a "Merge" property which only contains a condition.
isMerge = isType "merge"; isMerge = attrs: (typeOf attrs) == "merge";
mkMerge = content: mkProperty { mkMerge = content: mkProperty {
property = { property = {
_type = "merge"; _type = "merge";
@ -204,7 +204,7 @@ rec {
# is ignore. # is ignore.
# Create a "If" property which only contains a condition. # Create a "If" property which only contains a condition.
isIf = isType "if"; isIf = attrs: (typeOf attrs) == "if";
mkIf = condition: content: mkProperty { mkIf = condition: content: mkProperty {
property = { property = {
_type = "if"; _type = "if";
@ -271,7 +271,7 @@ rec {
# priorities between values. The default priority is 100. The lowest # priorities between values. The default priority is 100. The lowest
# priorities are kept. The template argument must reproduce the same # priorities are kept. The template argument must reproduce the same
# attribute set hierarchy to override leaves of the hierarchy. # attribute set hierarchy to override leaves of the hierarchy.
isOverride = isType "override"; isOverride = attrs: (typeOf attrs) == "override";
mkOverrideTemplate = priority: template: content: mkProperty { mkOverrideTemplate = priority: template: content: mkProperty {
property = { property = {
_type = "override"; _type = "override";
@ -371,7 +371,7 @@ rec {
# of the list used by the merge function. And the highest ranked # of the list used by the merge function. And the highest ranked
# definition would be the last. Definitions which does not have any rank # definition would be the last. Definitions which does not have any rank
# value have the default rank of 100. # value have the default rank of 100.
isOrder = isType "order"; isOrder = attrs: (typeOf attrs) == "order";
mkOrder = rank: content: mkProperty { mkOrder = rank: content: mkProperty {
property = { property = {
_type = "order"; _type = "order";
@ -434,7 +434,7 @@ rec {
# properties on top of the option definition is nice for user manipulation # properties on top of the option definition is nice for user manipulation
# but require to check if the content of the property is not another # but require to check if the content of the property is not another
# property. Such testing implies to verify if this is an attribute set # property. Such testing implies to verify if this is an attribute set
# and if it possess the type 'property'. (see isProperty & typeOf/isType) # and if it possess the type 'property'. (see isProperty & typeOf)
# #
# To avoid strict evaluation of option definitions, 'mkFixStrictness' is # To avoid strict evaluation of option definitions, 'mkFixStrictness' is
# introduced. This property protects an option definition by replacing # introduced. This property protects an option definition by replacing

View File

@ -15,14 +15,14 @@ in
rec { rec {
isSignificantByte = isType "significant-byte"; isSignificantByte = x: typeOf x == "significant-byte";
significantBytes = setTypes "significant-byte" { significantBytes = setTypes "significant-byte" {
bigEndian = {}; bigEndian = {};
littleEndian = {}; littleEndian = {};
}; };
isCpuType = isType "cpu-type" isCpuType = x: typeOf x == "cpu-type"
&& elem x.bits [8 16 32 64 128] && elem x.bits [8 16 32 64 128]
&& (builtins.lessThan 8 x.bits -> isSignificantByte x.significantByte); && (builtins.lessThan 8 x.bits -> isSignificantByte x.significantByte);
@ -37,7 +37,7 @@ rec {
}; };
isExecFormat = isType "exec-format"; isExecFormat = x: typeOf x == "exec-format";
execFormats = setTypes "exec-format" { execFormats = setTypes "exec-format" {
aout = {}; # a.out aout = {}; # a.out
elf = {}; elf = {};
@ -47,7 +47,7 @@ rec {
}; };
isKernel = isType "kernel"; isKernel = x: typeOf x == "kernel";
kernels = with execFormats; kernels = with execFormats;
setTypes "kernel" { setTypes "kernel" {
cygwin = { execFormat = pe; }; cygwin = { execFormat = pe; };
@ -61,7 +61,7 @@ rec {
}; };
isArchitecture = isType "architecture"; isArchitecture = x: typeOf x == "architecture";
architectures = setTypes "architecture" { architectures = setTypes "architecture" {
apple = {}; apple = {};
pc = {}; pc = {};
@ -69,7 +69,7 @@ rec {
}; };
isSystem = isType "system" isSystem = x: typeOf x == "system"
&& isCpuType x.cpu && isCpuType x.cpu
&& isArchitecture x.arch && isArchitecture x.arch
&& isKernel x.kernel; && isKernel x.kernel;

View File

@ -10,7 +10,6 @@ with import ./trivial.nix;
rec { rec {
isType = type: x: (x._type or "") == type;
hasType = x: isAttrs x && x ? _type; hasType = x: isAttrs x && x ? _type;
typeOf = x: x._type or ""; typeOf = x: x._type or "";
@ -27,7 +26,7 @@ rec {
# hasOptions (boolean: whatever this option contains an option set) # hasOptions (boolean: whatever this option contains an option set)
# delayOnGlobalEval (boolean: should properties go through the evaluation of this option) # delayOnGlobalEval (boolean: should properties go through the evaluation of this option)
# docPath (path concatenated to the option name contained in the option set) # docPath (path concatenated to the option name contained in the option set)
isOptionType = isType "option-type"; isOptionType = attrs: typeOf attrs == "option-type";
mkOptionType = mkOptionType =
{ name { name
, check ? (x: true) , check ? (x: true)