mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03:00
Add isPath to trivial.nix
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
318b7e2eeb
commit
2742087bdd
@ -11,17 +11,6 @@ with import ./options.nix;
|
||||
with import ./properties.nix;
|
||||
|
||||
rec {
|
||||
|
||||
# Unfortunately this can also be a string.
|
||||
isPath = x: !(
|
||||
builtins.isFunction x
|
||||
|| builtins.isAttrs x
|
||||
|| builtins.isInt x
|
||||
|| builtins.isBool x
|
||||
|| builtins.isList x
|
||||
);
|
||||
|
||||
|
||||
importIfPath = path:
|
||||
if isPath path then
|
||||
import path
|
||||
|
@ -35,4 +35,14 @@ rec {
|
||||
else if builtins.isAttrs x
|
||||
then deepSeqAttrs x y
|
||||
else seq x y;
|
||||
|
||||
isPath = val: with builtins; !(
|
||||
isAttrs val
|
||||
|| isList val
|
||||
|| isInt val
|
||||
|| isString val
|
||||
|| isFunction val
|
||||
|| isBool val
|
||||
|| val == null
|
||||
);
|
||||
}
|
||||
|
@ -96,8 +96,7 @@ rec {
|
||||
|
||||
path = mkOptionType {
|
||||
name = "path";
|
||||
# Hacky: there is no ‘isPath’ primop.
|
||||
check = lib.traceValIfNot (x: builtins.unsafeDiscardStringContext (builtins.substring 0 1 (toString x)) == "/");
|
||||
check = lib.traceValIfNot isPath;
|
||||
};
|
||||
|
||||
listOf = types.list;
|
||||
|
Loading…
Reference in New Issue
Block a user