Nix builtins similar to cat

Is there any nix builtins that returns the content of a file, similar to cat?

You probably want builtins.readFile which will read the contents into a string.

let
  myFileContents  = builtins.readFile ./myfile.txt;
in
...

EDIT: if your file is nix code, you could also just use import

# myFile.nix
{
  a = "some setting";
}
let
  mySetting = (import ./myFile.nix).a;
in
...
1 Like