-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.nix
More file actions
37 lines (37 loc) · 1.12 KB
/
Copy pathlib.nix
File metadata and controls
37 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{pkgs, ...}: {
_module.args = {
helpers = rec {
templateFile = name: template: data:
with pkgs;
stdenv.mkDerivation {
name = "${name}";
nativeBuildInpts = [mustache-go];
passAsFile = ["jsonData"];
jsonData = builtins.toJSON data;
phases = ["buildPhase" "installPhase"];
buildPhase = ''
${mustache-go}/bin/mustache $jsonDataPath ${template} > rendered_file
'';
installPhase = ''
mkdir -p $out
cp rendered_file $out/${name}
'';
};
templateSourceVimScript = name: template: data: let
fileName = "${name}.vim";
in ''
source ${templateFile fileName template data}/${fileName}
'';
templateSourceLua = name: template: data: let
fileName = "${name}.lua";
in ''
lua << EOF
local current_path = package.path
package.path = current_path .. ";${templateFile fileName template data}/?.lua"
require("${name}")
package.path = current_path
EOF
'';
};
};
}