nixcfg/lib/file/default.nix

26 lines
480 B
Nix
Raw Normal View History

2024-03-21 15:00:36 +01:00
{ lib, ... }:
rec {
## Append text to the contents of a file
##
## ```nix
## fileWithText ./some.txt "appended text"
## ```
##
#@ Path -> String -> String
fileWithText = file: text: ''
${builtins.readFile file}
${text}'';
## Prepend text to the contents of a file
##
## ```nix
## fileWithText' ./some.txt "prepended text"
## ```
##
#@ Path -> String -> String
fileWithText' = file: text: ''
${text}
${builtins.readFile file}'';
}