remove enfIsAttrsUnsafe
This commit is contained in:
parent
ccd07cc07a
commit
d6ab2fdf72
2 changed files with 4 additions and 9 deletions
|
|
@ -8,7 +8,6 @@
|
|||
inherit
|
||||
(this.std)
|
||||
enfHasAttr
|
||||
enfHasAttrUnsafe
|
||||
;
|
||||
|
||||
inherit
|
||||
|
|
@ -23,7 +22,7 @@ in rec {
|
|||
|
||||
mkTrapdoorFn = decl:
|
||||
assert enfHasAttr "default" decl "mkTrapdoorFn";
|
||||
assert enfHasAttrUnsafe "unlock" decl "mkTrapdoorFn";
|
||||
assert enfHasAttr "unlock" decl "mkTrapdoorFn";
|
||||
# return trapdoor function
|
||||
(x:
|
||||
if x == masterkey
|
||||
|
|
@ -32,7 +31,7 @@ in rec {
|
|||
|
||||
mkTrapdoorSet = decl:
|
||||
assert enfHasAttr "default" decl "mkTrapdoorSet";
|
||||
assert enfHasAttrUnsafe "unlock" decl "mkTrapdoorSet";
|
||||
assert enfHasAttr "unlock" decl "mkTrapdoorSet";
|
||||
# return trapdoor set
|
||||
decl.default
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -27,13 +27,9 @@ in rec {
|
|||
in
|
||||
got == "set" || throw "${msg}: expected primitive nix type \"set\" but got \"${got}\"";
|
||||
|
||||
# NOTE: doesn't check if xs is type set, use enfHasAttr instead
|
||||
enfHasAttrUnsafe = name: xs: msg:
|
||||
hasAttr name xs || throw "${msg}: missing required attribute \"${name}\"";
|
||||
|
||||
# NOTE: use enfHasAttr' if you can guarantee xs is type set
|
||||
enfHasAttr = name: xs: msg:
|
||||
enfIsAttrs xs msg && enfHasAttrUnsafe name xs msg;
|
||||
assert enfIsAttrs xs msg;
|
||||
hasAttr name xs || throw "${msg}: missing required attribute \"${name}\"";
|
||||
|
||||
getAttrOr = name: f: xs:
|
||||
if xs ? ${name}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue