diff options
author | Eric Sagnes <eric.sagnes@gmail.com> | 2016-07-29 17:15:37 +0900 |
---|---|---|
committer | Eric Sagnes <eric.sagnes@gmail.com> | 2016-08-01 18:35:25 +0900 |
commit | 56575cc0ac289d1f50358297cb72d9cd73f24630 (patch) | |
tree | 5411de81e8141581fcf7b38b75c3cba19d26b4b6 /lib/strings.nix | |
parent | 0804f67024f21a75a710e41423561cc0d3472e2f (diff) | |
download | nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar.gz nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar.bz2 nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar.lz nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar.xz nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.tar.zst nixlib-56575cc0ac289d1f50358297cb72d9cd73f24630.zip |
lib: add fileContents function
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 5e5f7b378667..daf845839343 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -479,4 +479,14 @@ rec { absolutePaths = builtins.map (path: builtins.toPath (root + "/" + path)) relativePaths; in absolutePaths; + + /* Read the contents of a file removing the trailing \n + + Example: + $ echo "1.0" > ./version + + fileContents ./version + => "1.0" + */ + fileContents = file: removeSuffix "\n" (builtins.readFile file); } |