output: format init.lua

This commit is contained in:
Matt Sturgeon 2024-04-13 08:40:47 +01:00
parent 3a4de0bb2f
commit 21c233919d
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 34 additions and 1 deletions

30
lib/builders.nix Normal file
View file

@ -0,0 +1,30 @@
{
lib,
pkgs,
}: {
/*
Write a lua file to the nix store, formatted using stylua.
# Type
```
writeLua :: String -> String -> Derivation
```
# Arguments
- [name] The name of the derivation
- [text] The content of the lua file
*/
writeLua = name: text:
pkgs.runCommand name {inherit text;} ''
echo -n "$text" > "$out"
${lib.getExe pkgs.stylua} \
--no-editorconfig \
--line-endings Unix \
--indent-type Spaces \
--indent-width 4 \
"$out"
'';
}