-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* this can implement functions like read-file
- Loading branch information
1 parent
44549bc
commit bc41cb1
Showing
10 changed files
with
226 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
# syntax = docker/dockerfile:1.4 | ||
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder | ||
|
||
WORKDIR /tmp/build | ||
RUN mkdir /tmp/nix-store-closure | ||
|
||
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here | ||
# hadolint ignore=SC2046 | ||
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,target=/tmp/build \ | ||
<<EOF | ||
nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
--extra-trusted-substituters "https://cache.iog.io" \ | ||
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--show-trace \ | ||
--log-format raw \ | ||
build . --out-link /tmp/output/result | ||
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure | ||
EOF | ||
|
||
FROM babashka/babashka:latest@sha256:9e0381fc4c78ee6ff12fd8836352cf343afba289aceb77e36129d92f30a92cc7 | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/output/ /app/ | ||
|
||
ENTRYPOINT ["/app/result/bin/entrypoint"] | ||
CMD ["--help"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
description = "{{tool}}"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, ...}@inputs: | ||
|
||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
|
||
in rec | ||
{ | ||
packages = rec { | ||
|
||
# this derivation just contains the init.clj script | ||
scripts = pkgs.stdenv.mkDerivation { | ||
name = "scripts"; | ||
src = ./.; | ||
installPhase = '' | ||
cp init.clj $out | ||
''; | ||
}; | ||
|
||
run-entrypoint = pkgs.writeShellScriptBin "entrypoint" '' | ||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
/usr/local/bin/bb ${scripts} "$@" | ||
''; | ||
|
||
default = pkgs.buildEnv { | ||
name = "bb"; | ||
paths = [ run-entrypoint ]; | ||
}; | ||
}; | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns init | ||
(:require | ||
[cheshire.core])) | ||
|
||
(def args {}) | ||
|
||
(try | ||
(let [[json-string & extra-args] *command-line-args* | ||
m (cheshire.core/parse-string json-string true) | ||
script (first extra-args)] | ||
(alter-var-root #'args (constantly m)) | ||
(println | ||
(load-string script))) | ||
(catch Throwable t | ||
(binding [*out* *err*] | ||
(println (str "Error: " (.getMessage t))) | ||
(System/exit 1)))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
```sh | ||
docker build -t vonwig/bb:latest . | ||
``` | ||
|
||
```sh | ||
docker run -it --rm -v ~/slimslenderslacks/flask-nix-example:/project \ | ||
--workdir /project vonwig/bb:latest \ | ||
'{"path": "./src/app.py"}' \ | ||
'(slurp (:path args))' | ||
``` | ||
|
||
```sh | ||
docker push vonwig/bb:latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
tools: | ||
- name: pylint | ||
--- | ||
|
||
# prompt user | ||
|
||
Run pylint with options `-f json` on the file `src/app.py` and tell me how many violations are in this file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
tools: | ||
- name: read-file | ||
--- | ||
|
||
# prompt user | ||
|
||
Read the file `src/app.py` and tell me how many functions you see. | ||
|
||
# #prompt user | ||
|
||
Read the file `src/app.py` and tell me how many lines are in the file. | ||
|
||
# #prompt user does not work! | ||
|
||
Read the file `src/app.py` and then output the ranges of lines that each function occupies. | ||
For example, if the function 'foo' is lines 10-2o, then the output should be: | ||
|
||
``` | ||
{ "foo": [10,20] } | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters