nix: added flake and derivation for the project

Signed-off-by: markoburcul <marko@status.im>
This commit is contained in:
markoburcul 2024-11-19 11:15:35 +01:00
parent ddf956e310
commit f1f7baf3d2
No known key found for this signature in database
GPG Key ID: FC4CD2F9A040D54A
7 changed files with 3326 additions and 2 deletions

6
.gitignore vendored
View File

@ -5,7 +5,11 @@ target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock # Commented since for nix derivation we need the Cargo.lock file.
# Cargo.lock
# If built with Nix, the target with be within result directory.
result
# These are backup files generated by rustfmt # These are backup files generated by rustfmt
**/*.rs.bk **/*.rs.bk

3242
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ crate-type = [
[dependencies] [dependencies]
ark-circom = { git = "https://github.com/codex-storage/circom-compat.git#71f1ceb11aef27256", features = ["circom-2", "ethereum"]} ark-circom = { git = "https://github.com/codex-storage/circom-compat.git", rev = "71f1ceb11aef27256", features = ["circom-2", "ethereum"]}
ark-crypto-primitives = { version = "=0.4.0" } ark-crypto-primitives = { version = "=0.4.0" }
ark-ec = { version = "=0.4.1", default-features = false, features = ["parallel"] } ark-ec = { version = "=0.4.1", default-features = false, features = ["parallel"] }

View File

@ -1,2 +1,8 @@
# circom-compat-ffi # circom-compat-ffi
circom-compat (ark-circom) ffi circom-compat (ark-circom) ffi
# Build with Nix
```nix
nix build
```

21
default.nix Normal file
View File

@ -0,0 +1,21 @@
{ pkgs }:
pkgs.rustPlatform.buildRustPackage {
pname = "circom-compat-ffi";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};
CARGO_HOME = "/tmp";
cargoBuildFlags = ["--release"];
meta = with pkgs.lib; {
description = "circom-compat (ark-circom) ffi";
license = licenses.mit;
};
}

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1731386116,
"narHash": "sha256-lKA770aUmjPHdTaJWnP3yQ9OI1TigenUqVC3wweqZuI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "689fed12a013f56d4c4d3f612489634267d86529",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

24
flake.nix Normal file
View File

@ -0,0 +1,24 @@
{
description = "A flake for building circom-compat (ark-circom) ffi";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
};
outputs = { self, nixpkgs }:
let
stableSystems = [
"x86_64-linux" "aarch64-linux"
"x86_64-darwin" "aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs stableSystems;
pkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
packages = forAllSystems (system: let
pkgs = pkgsFor.${system};
in {
default = pkgs.callPackage ./default.nix {};
});
};
}