-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
169 lines (157 loc) · 6.14 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{
description = "Toothpick";
inputs = {
hotPot.url = "github:shopstic/nix-hot-pot";
nixpkgs.follows = "hotPot/nixpkgs";
flakeUtils.follows = "hotPot/flakeUtils";
fdbPkg.follows = "hotPot/fdbPkg";
nix2containerPkg.follows = "hotPot/nix2containerPkg";
helmet.url = "github:shopstic/helmet/1.26.7";
jetski.url = "github:shopstic/jetski/1.7.10";
};
outputs = { self, nixpkgs, flakeUtils, hotPot, fdbPkg, nix2containerPkg, helmet, jetski }:
flakeUtils.lib.eachSystem [ "aarch64-darwin" "x86_64-linux" "aarch64-linux" ]
(system:
let
pkgs = import nixpkgs { inherit system; };
hotPotPkgs = hotPot.packages.${system};
hotPotLib = hotPot.lib.${system};
nix2container = nix2containerPkg.packages.${system}.nix2container;
nonRootShadowSetup = hotPotLib.nonRootShadowSetup;
fdbLib = fdbPkg.packages.${system}.fdb_7.lib;
jdkArgs = [
"--set DYLD_LIBRARY_PATH ${fdbLib}"
"--set LD_LIBRARY_PATH ${fdbLib}"
"--set JDK_JAVA_OPTIONS -DFDB_LIBRARY_PATH_FDB_JAVA=${fdbLib}/libfdb_java.${if pkgs.stdenv.isDarwin then "jnilib" else "so"}"
];
jreArgs = [
''--run "if [[ -f ./.env ]]; then source ./.env; elif [[ -f ../.env ]]; then source ../.env; fi"''
];
jdk = pkgs.callPackage hotPotLib.wrapJdk {
jdk = hotPot.packages.${system}.jdk17;
args = pkgs.lib.concatStringsSep " " (jdkArgs ++ jreArgs);
};
jre = pkgs.callPackage hotPotLib.wrapJdk {
jdk = hotPot.packages.${system}.jre17;
args = pkgs.lib.concatStringsSep " " jreArgs;
};
compileJdk = jdk;
sbt = pkgs.sbt.override {
jre = {
home = compileJdk;
};
};
toothpick-deps = pkgs.callPackage ./nix/deps.nix {
inherit sbt jdk;
};
toothpick = pkgs.callPackage ./nix/toothpick.nix {
inherit sbt jdk toothpick-deps;
};
toothpick-server-image = pkgs.callPackage ./nix/server-image.nix
{
inherit nonRootShadowSetup toothpick fdbLib nix2container jre;
inherit (hotPotPkgs)
grpc-health-probe;
};
toothpick-runner-jre = pkgs.callPackage ./nix/runner-jre.nix {
inherit jre;
toothpickRunnerBin = "${toothpick}/bin/toothpick-runner";
};
toothpick-runner-jre-dev = pkgs.callPackage ./nix/runner-jre.nix {
inherit jre;
};
jdkPrefix = "toothpick-";
update-intellij = pkgs.writeShellScript "update-intellij" ''
set -euo pipefail
THIS_PATH=$(realpath .)
SDK_NAMES=(compile runner-dev)
for SDK_NAME in "''${SDK_NAMES[@]}"
do
find ~/Library/Application\ Support/JetBrains/ -mindepth 1 -maxdepth 1 -name "IntelliJIdea*" -type d | \
xargs -I%%%% bash -c "echo \"Adding ${jdkPrefix}''${SDK_NAME} to %%%%/options/jdk.table.xml\" && ${hotPotPkgs.intellij-helper}/bin/intellij-helper \
update-jdk-table-xml \
--name ${jdkPrefix}''${SDK_NAME} \
--jdkPath \"''${THIS_PATH}\"/.dev-sdks/\"''${SDK_NAME}\"-jdk \
--jdkTableXmlPath \"%%%%/options/jdk.table.xml\" \
--inPlace=true"
done
'';
intellij-scala-runners = pkgs.callPackage ./nix/intellij-scala-runners.nix { };
dev-sdks = pkgs.linkFarm "dev-sdks" [
{ name = "compile-jdk"; path = compileJdk; }
{ name = "runner-dev-jdk"; path = toothpick-runner-jre-dev; }
{ name = "update-intellij"; path = update-intellij; }
{ name = "intellij-scala-runners"; path = intellij-scala-runners; }
];
denoBin = hotPotPkgs.deno;
vscode-settings = pkgs.writeTextFile {
name = "vscode-settings.json";
text = builtins.toJSON {
"deno.enable" = true;
"deno.lint" = true;
"deno.path" = denoBin + "/bin/deno";
"[typescript]" = {
"editor.defaultFormatter" = "denoland.vscode-deno";
"editor.formatOnSave" = true;
};
"files.watcherExclude" = {
"**/target" = true;
};
"metals.sbtScript" = sbt + "/bin/sbt";
"nix.enableLanguageServer" = true;
"nix.formatterPath" = pkgs.nixpkgs-fmt + "/bin/nixpkgs-fmt";
"nix.serverSettings" = {
"nil" = {
"formatting" = {
"command" = [ "nixpkgs-fmt" ];
};
};
};
"nix.serverPath" = pkgs.nil + "/bin/nil";
};
};
devShell = pkgs.mkShellNoCC {
shellHook = ''
ln -Tfs ${dev-sdks} ./.dev-sdks
mkdir -p ./.vscode
cat ${vscode-settings} > ./.vscode/settings.json
if [[ -f ./.env ]]; then
source ./.env
fi
'';
buildInputs = toothpick.buildInputs ++ [
denoBin
helmet.defaultPackage.${system}
jetski.defaultPackage.${system}
] ++ builtins.attrValues {
inherit (pkgs)
# skopeo
yq-go
awscli2
kubernetes-helm
ps
amazon-ecr-credential-helper
grpcurl
;
inherit (hotPotPkgs)
manifest-tool
skopeo-nix2container
deno
;
};
};
in
{
inherit devShell;
defaultPackage = toothpick;
packages = {
inherit intellij-scala-runners toothpick;
devEnv = devShell.inputDerivation;
deps = toothpick-deps;
runner-jre = toothpick-runner-jre;
} // (pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
server-image = toothpick-server-image;
});
}
);
}