-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
100 lines (94 loc) · 3.48 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
{
description = "Chopsticks";
inputs = {
hotPot.url = "github:shopstic/nix-hot-pot";
nixpkgs.follows = "hotPot/nixpkgs";
flakeUtils.follows = "hotPot/flakeUtils";
fdb.follows = "hotPot/fdbPkg";
};
outputs = { self, nixpkgs, flakeUtils, hotPot, fdb }:
flakeUtils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
maven = prev.maven.override {
jdk = prev.jdk11;
};
})
];
};
hotPotPkgs = hotPot.packages.${system};
chopsticksSystem = if system == "aarch64-linux" then "x86_64-linux" else system;
chopsticksPkgs = import nixpkgs { system = chopsticksSystem; };
fdbLib = fdb.packages.${system}.fdb_7.lib;
jdkArgs = [
"--set DYLD_LIBRARY_PATH ${fdbLib}"
"--set LD_LIBRARY_PATH ${fdbLib}"
"--set FDB_NETWORK_OPTION_EXTERNAL_CLIENT_DIRECTORY ${fdbLib}"
# "--set FDB_NETWORK_OPTION_CLIENT_THREADS_PER_VERSION 3"
# "--set FDB_NETWORK_OPTION_TRACE_FORMAT json"
# "--set FDB_NETWORK_OPTION_TRACE_ENABLE /Users/nktpro/Downloads/fdb7"
''--set JDK_JAVA_OPTIONS "-DFDB_LIBRARY_PATH_FDB_JAVA=${fdbLib}/libfdb_java.${if pkgs.stdenv.isDarwin then "jnilib" else "so"}"''
];
jdk = pkgs.callPackage hotPot.lib.wrapJdk {
jdk = pkgs.jdk11;
args = pkgs.lib.concatStringsSep " " (jdkArgs ++ [''--run "if [[ -f ./.env ]]; then source ./.env; fi"'']);
};
sbt = pkgs.sbt.override {
jre = {
home = jdk;
};
};
jdkPrefix = "chopsticks-";
updateIntellij = pkgs.writeShellScript "update-intellij" ''
set -euo pipefail
THIS_PATH=$(realpath .)
find ~/Library/Application\ Support/JetBrains/ -mindepth 1 -maxdepth 1 -name "IntelliJIdea*" -type d | \
xargs -I%%%% bash -c "echo \"Adding ${jdkPrefix}jdk to %%%%/options/jdk.table.xml\" && ${hotPotPkgs.intellij-helper}/bin/intellij-helper \
update-jdk-table-xml \
--name ${jdkPrefix}jdk \
--jdkPath \"''${THIS_PATH}\"/.dev-sdks/jdk \
--jdkTableXmlPath \"%%%%/options/jdk.table.xml\" \
--inPlace=true"
'';
devSdks = pkgs.linkFarm "dev-sdks" [
{ name = "jdk"; path = jdk; }
{ name = "update-intellij"; path = updateIntellij; }
];
chopsticksDeps = chopsticksPkgs.callPackage ./nix/deps.nix {
inherit sbt;
jdk = pkgs.jdk11;
};
chopsticks = chopsticksPkgs.callPackage ./nix/chopsticks.nix {
inherit sbt;
jdk = pkgs.jdk11;
inherit chopsticksDeps;
};
in
rec {
defaultPackage = chopsticks;
packages = {
coursierCache = chopsticksDeps;
};
devShell = pkgs.mkShellNoCC rec {
shellHook = ''
ln -Tfs ${devSdks} ./.dev-sdks
if [[ -f ./.env ]]; then source ./.env; fi
'';
buildInputs = builtins.attrValues
{
inherit jdk sbt;
inherit (pkgs)
jq
parallel
maven
gnupg
;
};
};
}
);
}