Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a separate deps-lock.json and container derivation that includes SPPL #94

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ pom.xml.asc
package-lock.json
/cljs-test-runner-out/
/.direnv/

# nix
result
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"
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.

18 changes: 16 additions & 2 deletions 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 @@ -21,10 +22,15 @@
];
};

uber = pkgsWithCljNixOverlay.callPackage ./nix/uber {};
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 @@ -50,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/depsCache/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";
};
}
File renamed without changes.
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
Loading