-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv.nix
53 lines (49 loc) · 1.38 KB
/
devenv.nix
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{ pkgs, ... }:
{
# https://devenv.sh/packages/
packages = with pkgs;
[
nodejs
yarn
dprint
graphviz
nodePackages.ts-node
];
# https://devenv.sh/scripts/
scripts = with pkgs; {
run-format.exec = "${dprint}/bin/dprint fmt";
run-repl.exec = "${nodePackages.ts-node}/bin/ts-node";
run-clean.exec = "rm -rf dist";
# @remarks Needs chromium installed
# @param {string} to src file
run-deps.exec = ''
if [ -z $1 ]; then echo "req path parameter"; exit 1; fi
tfile=$(mktemp --suffix=.html)
${nodejs}/bin/npx depcruise $1 \
-X "node_modules" --highlight "lib" \
-T dot --prefix $PWD \
| ${graphviz}/bin/dot -T svg \
| ${nodejs}/bin/npx depcruise-wrap-stream-in-html > $tfile
chromium $tfile 2>/dev/null
'';
# @param {string} name of new package
run-template.exec = ''
if [ -z $1 ]; then echo "req package name"; exit 1; fi
cp -r @blueprint@ $1;
sed -i "s/--placeholder--/$1/g" $(find $1 -type f)
'';
};
# https://devenv.sh/languages/
languages.typescript.enable = true;
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
dprint = {
enable = true;
name = "dprint";
description = "Multi-language code formatter";
entry = "${pkgs.dprint}/bin/dprint fmt";
pass_filenames = false;
types = [ "text" ];
};
};
}