-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflake.nix
More file actions
155 lines (130 loc) Β· 4.14 KB
/
flake.nix
File metadata and controls
155 lines (130 loc) Β· 4.14 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
description = "Enola AI; see https://enola.dev";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
deadnix.url = "github:astro/deadnix";
deadnix.inputs.nixpkgs.follows = "nixpkgs";
bazel.url = "github:vorburger/bazel-nix";
bazel.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
flake-utils,
deadnix,
bazel,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
jdk' = pkgs.jdk21;
buildTools = with pkgs; [
# https://github.com/NixOS/nixfmt/issues/335
nix
python312
curl
clang-tools # clang-format
git
go
jq
# TODO Finish switch from Bazelisk to Bazel package
# by cleaning up all scripts etc. which still use
# bazelisk, and then rm this, and .bazelversion
bazelisk
shellcheck
twilio-cli
nixpkgs-fmt
unzip
nodejs
maven
jdk'
graphviz
protobuf
protoc-gen-grpc-java
protolint
which
statix
bun
deadnix.packages.${system}.default
bazel.packages.${system}.default
];
# NB: This doesn't actually use tools/version/version-out.bash (like the non-Nix build does)
gitRev = toString (self.shortRev or self.dirtyShortRev or self.lastModified or "DEVELOPMENT");
in
{
# TODO: for https://nix-bazel.build, replace with mkShellNoCC.
devShells.default = pkgs.mkShell {
packages = buildTools;
# Python venv. Warning: impure! We mitigate impurity through
# specifying exact package versions in requirements.txt
venvDir = "./.venv";
postVenvCreation = ''
pip install -r requirements.txt
'';
buildInputs = with pkgs.python312Packages; [
venvShellHook
];
# A hook run every time you enter the environment
postShellHook = ''
# TODO Huh, why is this ugly hack required!?
export PATH="${pkgs.protoc-gen-grpc-java}/bin:$PATH"
echo Welcome to contributing to Enola.dev! You can now run e.g. ./enola or ./test.bash etc. here.
'';
};
packages = rec {
# $ nix run
# $ nix build .#enola
# $ result/bin/enola --help
default = enola;
enola = pkgs.stdenv.mkDerivation {
pname = "enola";
version = gitRev;
buildInputs = [ jdk' ];
nativeBuildInputs = buildTools ++ [
pkgs.cacert
pkgs.makeWrapper
pkgs.which
];
src = ./.;
buildPhase = ''
runHook preBuild
# class dev.enola.common.Version reads VERSION
echo -n "${gitRev}" >tools/version/VERSION
# See https://github.com/NixOS/nix/issues/14024
bash tools/protoc/protoc.bash
# https://github.com/enola-dev/enola/issues/1876
export HOME="$PWD/.built/HOME"
mkdir -p "$HOME"
bazel build //java/dev/enola/cli:enola_deploy.jar
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/share/java"
cp bazel-bin/java/dev/enola/cli/enola_deploy.jar "$out/share/java"
makeWrapper ${jdk'}/bin/java $out/bin/enola \
--add-flags "-jar $out/share/java/enola_deploy.jar"
runHook postInstall
'';
};
};
apps = {
test = {
type = "app";
program = "${
pkgs.writeShellApplication {
name = "test";
runtimeInputs = buildTools;
text = builtins.readFile ./test.bash;
}
}/bin/test";
};
};
formatter = pkgs.nixfmt-tree;
}
);
}