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

WIP: build: initial linux x86_64 support using nix #6

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ probably not ready for you yet.

Requires Clojure, babashka, GraalVM version 22.3.1, and Rust.

### MacOS
If you are using a recent version of MacOS, have all the deps
installed, and are a relatively lucky person, it might be as easy as
doing this from the top-level of this project's directory structure
(making sure that the Java on your path is the GraalVM version
mentioned above):

### Linux x86_64 (using Nix Flakes)
The `flakes.nix` file contains the necessary instructions for a
repeatable build environment on Linux x86_64.
``` shell
$ nix develop
```

### Common
``` shell
$ bb all
```
Expand Down
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:tasks
{:requires ([babashka.fs :as fs])
:init (do
(def libsci (str (first (fs/glob "clj" "LibScimacs.{dylib,dll,solib}"))))
(def libsci (str (first (fs/glob "clj" "LibScimacs.{dylib,dll,so}"))))
(def lib-ext (fs/extension libsci))
(def local-lib (str "scimacs." lib-ext))
(def uberjar "clj/target/uber.jar"))
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let path = "./clj"; // where to find the GraalVM-generated stuff

println!("cargo:rustc-link-search=./clj");
println!("cargo:rustc-link-lib=Scimacs");
println!("cargo:rustc-link-lib=scimacs");

println!("cargo:rustc-link-search={path}", path = path);

Expand Down
77 changes: 77 additions & 0 deletions flake.lock

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

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, nixpkgs, rust-overlay }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [rust-overlay.overlays.default];
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml;
in {
devShells.${system}.default = pkgs.mkShell {
packages = [
toolchain
pkgs.babashka
pkgs.clojure
pkgs.graalvm-ce
pkgs.llvmPackages.libclang
pkgs.rust-analyzer-unwrapped
];
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
};
}
5 changes: 5 additions & 0 deletions toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# toolchain.toml
[toolchain]
channel = "nightly"
components = [ "rustfmt", "rust-src" ]
profile = "minimal"