diff options
author | Luca Bruno <lethalman88@gmail.com> | 2015-11-25 21:31:09 +0100 |
---|---|---|
committer | Luca Bruno <lethalman88@gmail.com> | 2015-11-25 21:37:30 +0100 |
commit | a41292792498e03024d682d092947c2153290073 (patch) | |
tree | b937402b60ea79cfa0e5562dad3268127a491d81 /lib/strings.nix | |
parent | 8a664fd5bc6b170bdf809030de6871fd6a454f5a (diff) | |
parent | b34a6c96ee14518b82648c5a8c1b29225c15d9df (diff) | |
download | nixpkgs-a41292792498e03024d682d092947c2153290073.tar nixpkgs-a41292792498e03024d682d092947c2153290073.tar.gz nixpkgs-a41292792498e03024d682d092947c2153290073.tar.bz2 nixpkgs-a41292792498e03024d682d092947c2153290073.tar.lz nixpkgs-a41292792498e03024d682d092947c2153290073.tar.xz nixpkgs-a41292792498e03024d682d092947c2153290073.tar.zst nixpkgs-a41292792498e03024d682d092947c2153290073.zip |
Merge remote-tracking branch 'origin/master' into closure-size
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 372c8833c32..4b6b91cbf0c 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -225,4 +225,12 @@ rec { # Check whether a value is a store path. isStorePath = x: builtins.substring 0 1 (toString x) == "/" && dirOf (builtins.toPath x) == builtins.storeDir; + # Convert string to int + # Obviously, it is a bit hacky to use fromJSON that way. + toInt = str: + let may_be_int = builtins.fromJSON str; in + if builtins.isInt may_be_int + then may_be_int + else throw "Could not convert ${str} to int."; + } |