aboutsummaryrefslogtreecommitdiffstats
path: root/lib/types.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-06-12 20:08:24 +0200
committertv <tv@krebsco.de>2018-06-12 20:08:24 +0200
commit394590c4b35edbfbb5a503923fed0c8cbb382410 (patch)
treecff9ff9e975c64a5f390fdd7f1abfffdf1861434 /lib/types.nix
import writers from stockholm 0bc2409
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/types.nix b/lib/types.nix
new file mode 100644
index 0000000..197633e
--- /dev/null
+++ b/lib/types.nix
@@ -0,0 +1,23 @@
+{ lib, ... }:
+with lib;
+rec {
+ # POSIX.1‐2013, 3.2 Absolute Pathname
+ absolute-pathname = mkOptionType {
+ name = "POSIX absolute pathname";
+ check = x: isString x && substring 0 1 x == "/" && pathname.check x;
+ merge = mergeOneOption;
+ };
+
+ file-mode = mkOptionType {
+ name = "file mode";
+ check = test "[0-7]{4}";
+ merge = mergeOneOption;
+ };
+
+ # POSIX.1‐2013, 3.278 Portable Filename Character Set
+ filename = mkOptionType {
+ name = "POSIX filename";
+ check = test "([0-9A-Za-z._])[0-9A-Za-z._-]*";
+ merge = mergeOneOption;
+ };
+}