Skip to content

Commit

Permalink
build: Also provide a docker image with sppl
Browse files Browse the repository at this point in the history
  • Loading branch information
ships committed Mar 30, 2024
1 parent dfe4c68 commit eea2eef
Show file tree
Hide file tree
Showing 10 changed files with 2,361 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:
-L \
-o ./imgTarball \
'.#ociImg'
- run: |
nix build \
-L \
-o ./imgTarball \
'.#ociImgSppl'
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ the nix build universe has knowledge of the hash fingerprints of the new deps ve
It can be done without any setup like so:

```
nix develop --command bash -c "nix run github:jlesquembre/clj-nix#deps-lock" && mv deps-lock.json nix/depsCache
nix develop --command bb deps-lock:all
```

This script can take a minute or two as it needs to build local dependencies of the `clj-nix` library,
though this should only need to happen the first time you run it.
You will see the changes to `deps.edn` reflected in `deps-lock.json`; you should commit these; and the
You will see the changes to `deps.edn` reflected in `nix/depsCache/deps-lock.json`; you should commit these; and the
release build will work again.

Because nix requires these lockfiles to be calculated in advance, we save a separate lockfile for the case of
building an image with SPPL (and therefore `inferenceql.gpm.sppl`) and one without it, to avoid the baggage
of installing python.


#### Building a JAR (portable java application)

```
Expand Down
8 changes: 8 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@
lint {:doc "Run Clojure linters"
:task (shell "clj-kondo --lint src test")}

deps-lock {:doc "Generate deps-lock.json file without sppl"
:task (do (shell "nix run github:jlesquembre/clj-nix#deps-lock -- --alias-exclude :sppl-queries")
(shell "mv deps-lock.json nix/depsCache/deps-lock.json"))}
deps-lock:sppl {:doc "Generate deps-lock.json file with sppl"
:task (do (shell "nix run github:jlesquembre/clj-nix#deps-lock")
(shell "mv deps-lock.json nix/depsCacheWithSppl/deps-lock.json"))}
deps-lock:all {:depends [deps-lock deps-lock:sppl]}

repl {:doc "Launch the InferenceQL REPL"
:task (apply shell "clj -M -m inferenceql.query.main" *command-line-args*)}}}
1 change: 1 addition & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
org.clojure/test.check {:mvn/version "1.1.1"}}}
:build {:deps {io.github.clojure/tools.build {:git/sha "8e78bccc35116f6b6fc0bf0c125dba8b8db8da6b"}}
:ns-default build}
:sppl-queries {:extra-deps {io.github.inferenceql/inferenceql.gpm.sppl {:git/sha "f745dbb0c17c1a9da21488b7bd3098338ab7d7a2"}}}
:clj-test {:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:main-opts ["--main" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}
Expand Down
71 changes: 70 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
systems.url = "github:nix-systems/default";
clj-nix.url = "github:jlesquembre/clj-nix";
inferenceql-gpm-sppl.url = "github:inferenceql/inferenceql.gpm.sppl/ships/add-oci-image-package";
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
Expand All @@ -22,10 +23,14 @@
};

depsCache = pkgsWithCljNixOverlay.callPackage ./nix/depsCache {};
depsCacheWithSppl = pkgsWithCljNixOverlay.callPackage ./nix/depsCacheWithSppl {};

uber = pkgs.callPackage ./nix/uber {inherit depsCache;};
uberSppl = pkgs.callPackage ./nix/uber {depsCache = depsCacheWithSppl;};

pname = "iql";
bin = pkgs.callPackage ./nix/bin { inherit uber pname; };
binSppl = pkgs.callPackage ./nix/bin { inherit pname; uber=uberSppl; };

basicToolsFn = pkgs: with pkgs; [
coreutils
Expand All @@ -51,13 +56,21 @@
nixpkgs = inputs.nixpkgs;
};

ociImgSppl = pkgs.callPackage ./nix/oci/sppl.nix {
inherit pname basicToolsFn;
inferenceql-gpm-sppl = inputs.inferenceql-gpm-sppl;

uber = uberSppl;
nixpkgs = inputs.nixpkgs;
};

in {
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.openjdk21 pkgs.clojure pkgs.babashka ] ++ (basicToolsFn pkgs);
};

packages = {
inherit uber bin ociImg;
inherit uber bin uberSppl binSppl ociImg ociImgSppl;
default = bin;
};
};
Expand Down
7 changes: 7 additions & 0 deletions nix/depsCacheWithSppl/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ mk-deps-cache,
}: mk-deps-cache {
lockfile = builtins.path {
path = ./deps-lock.json;
name = "inferenceql.query.deps-lock.json";
};
}
Loading

0 comments on commit eea2eef

Please sign in to comment.