@@ -34,16 +34,21 @@ lib.fix (builders: {
34
34
*/
35
35
writeLuaWith =
36
36
pkgs : name : text :
37
- pkgs . runCommand name { inherit text ; } ''
38
- echo -n "$text" > "$out"
39
-
40
- ${ lib . getExe pkgs . stylua } \
41
- --no-editorconfig \
42
- --line-endings Unix \
43
- --indent-type Spaces \
44
- --indent-width 4 \
45
- "$out"
46
- '' ;
37
+ pkgs . runCommand name
38
+ {
39
+ nativeBuildInputs = [ pkgs . stylua ] ;
40
+ passAsFile = [ "text" ] ;
41
+ inherit text ;
42
+ }
43
+ ''
44
+ install -m 644 -T "$textPath" "$out"
45
+ stylua \
46
+ --no-editorconfig \
47
+ --line-endings Unix \
48
+ --indent-type Spaces \
49
+ --indent-width 4 \
50
+ "$out"
51
+ '' ;
47
52
48
53
/*
49
54
Write a byte compiled lua file to the nix store.
@@ -62,11 +67,15 @@ lib.fix (builders: {
62
67
*/
63
68
writeByteCompiledLuaWith =
64
69
pkgs : name : text :
65
- pkgs . runCommandLocal name { inherit text ; } ''
66
- echo -n "$text" > "$out"
67
-
68
- ${ lib . getExe' pkgs . luajit "luajit" } -bd -- "$out" "$out"
69
- '' ;
70
+ pkgs . runCommandLocal name
71
+ {
72
+ nativeBuildInputs = [ pkgs . luajit ] ;
73
+ passAsFile = [ "text" ] ;
74
+ inherit text ;
75
+ }
76
+ ''
77
+ luajit -bd -- "$textPath" "$out"
78
+ '' ;
70
79
71
80
/*
72
81
Get a source lua file and write a byte compiled copy of it
@@ -86,9 +95,14 @@ lib.fix (builders: {
86
95
*/
87
96
byteCompileLuaFileWith =
88
97
pkgs : name : src :
89
- pkgs . runCommandLocal name { inherit src ; } ''
90
- ${ lib . getExe' pkgs . luajit "luajit" } -bd -- "$src" "$out"
91
- '' ;
98
+ pkgs . runCommandLocal name
99
+ {
100
+ nativeBuildInputs = [ pkgs . luajit ] ;
101
+ inherit src ;
102
+ }
103
+ ''
104
+ luajit -bd -- "$src" "$out"
105
+ '' ;
92
106
93
107
# Setup hook to byte compile all lua files in the output directory.
94
108
# Invalid lua files are ignored.
0 commit comments