-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflake.nix
90 lines (75 loc) · 2 KB
/
flake.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "Ready-made templates for easily creating flake-driven environments";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }: {
templates = {
go = {
path = ./go;
description = "Go development environment";
};
node = {
path = ./node;
description = "Nodejs development environment";
};
node18 = {
path = ./node18;
description = "Nodejs (v18)";
};
node16 = {
path = ./node16;
description = "Nodejs (v16)";
};
node14 = {
path = ./node14;
description = "Nodejs (v14)";
};
python = {
path = ./python;
description = "Python development environment";
};
# react-native = {
# path = ./react-native;
# description = "React Native development environment";
# };
};
} // utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell writeScriptBin;
run = pkg: "${pkgs.${pkg}}/bin/${pkg}";
dvt = writeScriptBin "dvt" ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
fi
TEMPLATE=$1
${run "nix"} \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:telkomdev/env#''${TEMPLATE}"
'';
format = writeScriptBin "format" ''
${run "nixpkgs-fmt"} **/*.nix
'';
update = writeScriptBin "update" ''
for dir in `ls -d */`; do
(
cd $dir
${run "nix"} flake update # Update flake.lock
${run "nix"} develop $dir # Make sure this work after update
)
done
'';
in
{
devShells.default = mkShell { buildInputs = [ format update ]; };
packages = {
default = dvt;
inherit dvt;
};
});
}