-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
103 lines (92 loc) · 3.31 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
{
description = "The Docker LSP";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# can't update graal right now - this is from Aug '23
flake-utils.url = "github:numtide/flake-utils";
clj-nix = {
# for debugging the nix packages
# url = "path:/Users/slim/slimslenderslacks/clj-nix";
url = "github:jlesquembre/clj-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, clj-nix, devshell, ...}@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [
devshell.overlays.default
(self: super: {
clj-nix = clj-nix.packages."${system}";
})
];
# don't treat pkgs as meaning nixpkgs - treat it as all packages!
pkgs = import nixpkgs {
inherit overlays system;
};
in
{
packages = rec {
# build uber jar
clj = pkgs.clj-nix.mkCljBin {
name = "agent-graph";
projectSrc = ./.;
main-ns = "docker.main";
buildCommand = "clj -T:build uber";
jdkRunner = pkgs.jdk17_headless;
};
# create a minimal java runtime for this uberjar
custom-jdk = pkgs.clj-nix.customJdk {
cljDrv = clj;
jdkBase = pkgs.jdk17_headless;
# locales = "en";
javaOpts = [];
extraJdkModules = ["java.security.jgss" "java.security.sasl" "jdk.crypto.ec"];
};
# create some resources that will need to be copied into the final image
registries = pkgs.stdenv.mkDerivation {
name = "registries";
src = ./.;
installPhase = ''
mkdir -p $out/extractors
mkdir -p $out/functions
cp ./extractors/registry.edn $out/extractors
cp ./functions/registry.edn $out/functions
'';
};
# our application makes calls to the curl binary
# therefore, wrap the custom-jdk in a script with curl in the PATH
entrypoint = pkgs.writeShellScriptBin "entrypoint" ''
export PATH=${pkgs.lib.makeBinPath [pkgs.curl]}
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
exec ${custom-jdk}/bin/agent-graph "$@"
'';
# the final entrypoint
default = pkgs.buildEnv {
name = "agent-graph-env";
paths = [ entrypoint registries ];
};
};
devShells.default = pkgs.devshell.mkShell {
name = "agent-graph-shell";
packages = with pkgs; [ babashka clojure skopeo ];
commands = [
{
name = "lock-clojure-deps";
help = "update deps-lock.json whenever deps.edn changes";
command = "nix run github:jlesquembre/clj-nix#deps-lock";
}
{
name = "start";
help = "start the lsp server using deps.edn";
command = "clojure -M:main";
}
];
};
});
}