Skip to content

Commit bcc92b9

Browse files
committed
fix: Correctly install deps into sppl container
- Python site packages - JDK modules
1 parent c3b96cc commit bcc92b9

8 files changed

Lines changed: 90 additions & 25 deletions

File tree

.github/workflows/nix.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434
-L \
3535
-o ./imgTarball \
3636
'.#ociImg'
37+
- run: |
38+
nix build \
39+
-L \
40+
-o ./imgTarball \
41+
'.#ociImgSppl'

build.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))
88

99
;; delay to defer side effects (artifact downloads)
10-
(def basis (delay (build/create-basis {:project "deps.edn"})))
10+
(def basis (delay (build/create-basis {:aliases [ :query-sppl ]})))
1111

1212
;; clean build artifacts (excludes test artifacts)
1313
(defn clean [_]

deps.edn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
:jvm-opts ["-Djdk.attach.allowAttachSelf"]}
4545

4646
:query-sppl { :extra-deps { io.github.OpenGen/GenSQL.gpm.sppl {:git/sha "718de40878766bb8d08acc2b429a76ed662a1352"}}
47+
:jvm-opts ["--add-modules" "jdk.incubator.foreign,jdk.incubator.vector"
48+
"--enable-native-access=ALL-UNNAMED"]
4749
:main-opts ["-m" "gensql.query.main"]
4850
}
4951

flake.nix

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
};
1010
};
1111

12-
outputs = inputs@{ flake-parts, systems , ... }:
12+
outputs = inputs@{ flake-parts, systems , opengen, ... }:
1313
flake-parts.lib.mkFlake { inherit inputs; } {
1414
systems = import systems;
1515

@@ -28,7 +28,10 @@
2828

2929
pname = "gensql";
3030
bin = pkgs.callPackage ./nix/bin { inherit uber pname; };
31-
binGpmSppl = pkgs.callPackage ./nix/bin/with_extra_deps.nix { inherit pname; uber = uberGpmSppl; extraDeps = [ inputs.opengen.packages.${system}.sppl ]; };
31+
binGpmSppl = pkgs.callPackage ./nix/bin/gpm-sppl.nix {
32+
inherit pname opengen;
33+
uber = uberGpmSppl;
34+
};
3235

3336
basicToolsFn = pkgs: with pkgs; [
3437
coreutils
@@ -46,16 +49,16 @@
4649
# packages (derived from inputs.nixpkgs automatically by
4750
# flake-parts), but ...
4851
ociImg = pkgs.callPackage ./nix/oci {
49-
inherit uber pname basicToolsFn depsCache;
52+
inherit uber pname basicToolsFn depsCache opengen;
5053
# ... we still must pass in the original nixpkgs because
5154
# we need access to a different system's set of packages
5255
# when compiling for linux while remaining agnostic of
5356
# the workstation platform we are running this on.
5457
nixpkgs = inputs.nixpkgs;
5558
};
5659

57-
ociImgSppl = pkgs.callPackage ./nix/oci {
58-
inherit pname basicToolsFn depsCache;
60+
ociImgSppl = pkgs.callPackage ./nix/oci/gpm-sppl.nix {
61+
inherit pname opengen basicToolsFn depsCache;
5962
uber = uberGpmSppl;
6063
# ... we still must pass in the original nixpkgs because
6164
# we need access to a different system's set of packages
@@ -97,7 +100,7 @@
97100
};
98101

99102
devShells.sppl = pkgs.mkShell {
100-
buildInputs = [ pkgs.openjdk21 pkgs.clojure pkgs.babashka depsCache inputs.opengen.sppl ] ++ (basicToolsFn pkgs);
103+
buildInputs = [ pkgs.openjdk21 pkgs.clojure pkgs.babashka depsCache inputs.opengen.packages.${system}.sppl ] ++ (basicToolsFn pkgs);
101104

102105
shellHook = mutableCacheHook;
103106
};

nix/bin/default.nix

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{ pkgs,
2+
system,
23
uber,
3-
pname,
4-
...
5-
}: import ./with_extra_deps.nix { inherit pkgs uber pname; extraDeps = []; }
4+
pname
5+
}: pkgs.stdenv.mkDerivation {
6+
name = "gensql.query";
7+
inherit pname;
8+
src = ./.;
9+
nativeBuildInputs = [ pkgs.makeWrapper ];
10+
buildInputs = [ pkgs.openjdk17 ];
11+
installPhase = ''
12+
makeWrapper ${pkgs.openjdk17}/bin/java $out/bin/${pname} \
13+
--add-flags "-jar ${uber}"
14+
'';
15+
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{ pkgs,
2+
system,
23
uber,
3-
extraDeps,
4+
opengen,
45
pname
56
}: pkgs.stdenv.mkDerivation {
67
name = "gensql.query";
78
inherit pname;
89
src = ./.;
910
nativeBuildInputs = [ pkgs.makeWrapper ];
10-
buildInputs = [ pkgs.openjdk17 ] ++ extraDeps;
11+
buildInputs = [ pkgs.openjdk17 ];
12+
propagatedBuildInputs = with opengen; [
13+
opengen.packages.${system}.sppl
14+
opengen.packages.${system}.sppl.runtimePython
15+
];
1116
installPhase = ''
1217
makeWrapper ${pkgs.openjdk17}/bin/java $out/bin/${pname} \
1318
--add-flags "-jar ${uber}"

nix/oci/default.nix

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ pkgs,
22
nixpkgs,
3+
opengen,
34
system,
45
uber,
56
pname,
@@ -13,24 +14,15 @@
1314

1415
# TODO: This can be factored out into an gensql/nix
1516
# shared package.
16-
baseImg = pkgs.dockerTools.buildLayeredImage {
17-
name = "gensql.base";
18-
contents =
19-
(basicToolsFn crossPkgsLinux) ++ (with crossPkgsLinux; [
20-
bashInteractive
21-
]);
22-
config = {
23-
Cmd = [ "${crossPkgsLinux.bashInteractive}/bin/bash" ];
24-
};
25-
};
17+
baseImg = opengen.packages.${system}.ociImgBase;
2618

27-
ociBin = crossPkgsLinux.callPackage ./../bin {inherit uber pname;};
28-
in pkgs.dockerTools.buildImage {
19+
ociBin = crossPkgsLinux.callPackage ./../bin {inherit uber pname;};
20+
in pkgs.dockerTools.buildLayeredImage {
2921
name = "probcomp/gensql.query";
3022
tag = systemWithLinux;
3123
fromImage = baseImg;
3224
# architecture
33-
copyToRoot = [ ociBin depsCache crossPkgsLinux.clojure ];
25+
contents = [ ociBin depsCache crossPkgsLinux.clojure ] ++ extraDeps;
3426
config = {
3527
Cmd = [ "${ociBin}/bin/${pname}" ];
3628
Env = [

nix/oci/gpm-sppl.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{ pkgs,
2+
nixpkgs,
3+
system,
4+
opengen,
5+
uber,
6+
pname,
7+
basicToolsFn,
8+
depsCache,
9+
}: let
10+
# in OCI context, whatever our host platform we want to build same arch but linux
11+
systemWithLinux = builtins.replaceStrings [ "darwin" ] [ "linux" ] system;
12+
13+
crossPkgsLinux = nixpkgs.legacyPackages.${systemWithLinux};
14+
15+
# TODO: This can be factored out into an gensql/nix
16+
# shared package.
17+
baseImg = opengen.packages.${system}.ociImgBase;
18+
19+
sppl = opengen.packages.${systemWithLinux}.sppl;
20+
python = opengen.packages.${systemWithLinux}.sppl.runtimePython;
21+
22+
ociBin = crossPkgsLinux.callPackage ./../bin/gpm-sppl.nix {
23+
inherit
24+
uber
25+
opengen
26+
pname
27+
;
28+
};
29+
in pkgs.dockerTools.buildLayeredImage {
30+
name = "probcomp/gensql.query";
31+
tag = systemWithLinux;
32+
fromImage = baseImg;
33+
# architecture
34+
contents = [ ociBin depsCache crossPkgsLinux.clojure sppl python];
35+
config = {
36+
Cmd = [ "${ociBin}/bin/${pname}" ];
37+
Env = [
38+
"CLJ_CONFIG=${depsCache}/.clojure"
39+
"GITLIBS=${depsCache}/.gitlibs"
40+
"JAVA_TOOL_OPTIONS=-Duser.home=${depsCache}"
41+
"JDK_JAVA_OPTIONS=--add-modules jdk.incubator.foreign,jdk.incubator.vector --enable-native-access=ALL-UNNAMED"
42+
"PYTHONPATH=${python.sitePackages}"
43+
];
44+
};
45+
}
46+
47+
48+

0 commit comments

Comments
 (0)