nix-community.nixvim/lib/builders.nix

30 lines
547 B
Nix
Raw Permalink Normal View History

2024-05-05 19:39:35 +02:00
{ lib, pkgs }:
2024-04-13 08:40:47 +01:00
{
/*
2024-05-05 19:39:35 +02:00
Write a lua file to the nix store, formatted using stylua.
2024-04-13 08:40:47 +01:00
2024-05-05 19:39:35 +02:00
# Type
2024-04-13 08:40:47 +01:00
2024-05-05 19:39:35 +02:00
```
writeLua :: String -> String -> Derivation
```
2024-04-13 08:40:47 +01:00
2024-05-05 19:39:35 +02:00
# Arguments
2024-04-13 08:40:47 +01:00
2024-05-05 19:39:35 +02:00
- [name] The name of the derivation
- [text] The content of the lua file
2024-04-13 08:40:47 +01:00
*/
2024-05-05 19:39:35 +02:00
writeLua =
name: text:
pkgs.runCommand name { inherit text; } ''
2024-04-13 08:40:47 +01:00
echo -n "$text" > "$out"
${lib.getExe pkgs.stylua} \
--no-editorconfig \
--line-endings Unix \
--indent-type Spaces \
--indent-width 4 \
"$out"
'';
}