diff options
author | Shea Levy <shea@shealevy.com> | 2013-05-02 14:03:43 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2013-05-02 14:03:43 -0400 |
commit | 2742087bdd092d77083dc99cdafb6e93444fba3e (patch) | |
tree | 18c75048808fcb49baa59c46b9e6d4b049178bc9 /pkgs/lib | |
parent | 318b7e2eeb092c37688c3bdf09e70b7683dad11d (diff) | |
download | nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar.gz nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar.bz2 nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar.lz nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar.xz nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.tar.zst nixlib-2742087bdd092d77083dc99cdafb6e93444fba3e.zip |
Add isPath to trivial.nix
Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/modules.nix | 11 | ||||
-rw-r--r-- | pkgs/lib/trivial.nix | 10 | ||||
-rw-r--r-- | pkgs/lib/types.nix | 3 |
3 files changed, 11 insertions, 13 deletions
diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 286178a0fa70..4c00728a9a58 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -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 diff --git a/pkgs/lib/trivial.nix b/pkgs/lib/trivial.nix index 8af3474f2a67..b2304ff7a17e 100644 --- a/pkgs/lib/trivial.nix +++ b/pkgs/lib/trivial.nix @@ -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 + ); } diff --git a/pkgs/lib/types.nix b/pkgs/lib/types.nix index 6ddac61d91bf..eac76917c2d2 100644 --- a/pkgs/lib/types.nix +++ b/pkgs/lib/types.nix @@ -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; |