diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..5c04289a --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +watch_file nix + +use flake diff --git a/.gitignore b/.gitignore index 7cb883f2..b52db457 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target - /.env + +/.direnv diff --git a/cli/js/package-lock.json b/cli/js/package-lock.json index db5b6216..f6dd14e9 100644 --- a/cli/js/package-lock.json +++ b/cli/js/package-lock.json @@ -27,10 +27,10 @@ }, "../../node-wasm/js": { "name": "lumina-node", - "version": "0.7.0", + "version": "0.8.0", "license": "Apache-2.0", "dependencies": { - "lumina-node-wasm": "0.7.0" + "lumina-node-wasm": "0.8.0" }, "devDependencies": { "concat-md": "^0.5.1", @@ -41,7 +41,7 @@ }, "../../node-wasm/pkg": { "name": "lumina-node-wasm", - "version": "0.7.0", + "version": "0.8.0", "license": "Apache-2.0" }, "node_modules/@cosmjs/amino": { diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..c265e850 --- /dev/null +++ b/flake.lock @@ -0,0 +1,97 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1739255730, + "narHash": "sha256-RkZx53J5UZu58DclU13tKzwo0oaTIiHgT+ncbaaCnT8=", + "owner": "nix-community", + "repo": "fenix", + "rev": "c023dde9e8b73c78348384661cf3d5e5f209558d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1739138025, + "narHash": "sha256-M4ilIfGxzbBZuURokv24aqJTbdjPA9K+DtKUzrJaES4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b2243f41e860ac85c0b446eadc6930359b294e79", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1738452942, + "narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1739201154, + "narHash": "sha256-jP/Z+X28XQMqR6fWkIokJ45dVBkvsTe4dQOq5s/sA+4=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f5e7172e96ff8a75af99ac570085d22a4afab09b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..7b7d40d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "aarch64-linux" + "aarch64-darwin" + "x86_64-linux" + ]; + perSystem = { + imports = [ + ./nix/devshells.nix + ./nix/packages.nix + ]; + }; + }; +} diff --git a/nix/devshells.nix b/nix/devshells.nix new file mode 100644 index 00000000..903a60e2 --- /dev/null +++ b/nix/devshells.nix @@ -0,0 +1,97 @@ +{ + inputs', + pkgs, + lib, + ... +}: + +let + fenix = inputs'.fenix.packages; + + # creates list of components taken from a toolchain for given channel + rustComponents = + channel: + [ + "rustc" + "cargo" + "clippy" + "rustfmt" + ] + ++ lib.optionals (channel == "stable") [ + "rust-analyzer" + ]; + + # creates list of the extra targets to be installed for given channel + rustExtraTargets = + channel: + [ + "wasm32-unknown-unknown" + ] + ++ lib.optionals (channel == "stable") [ + # android + "aarch64-linux-android" + "armv7-linux-androideabi" + "x86_64-linux-android" + "i686-linux-android" + # ios + "aarch64-apple-ios" + "aarch64-apple-ios-sim" + ]; + + # creates toolchain configuration for given channel + rustToolchain = + channel: + fenix.combine [ + # components + (fenix."${channel}".withComponents (rustComponents channel)) + # extra targets + (lib.lists.map (target: fenix.targets."${target}"."${channel}".rust-std) (rustExtraTargets channel)) + ]; + + # wrapper for cargo to allow `+channel` syntax + cargoWrapper = pkgs.writeShellScriptBin "cargo" '' + case "$1" in + "+stable") + shift + exec env PATH="${rustToolchain "stable"}/bin:$PATH" cargo "$@" + ;; + "+nightly") + shift + exec env PATH="${rustToolchain "latest"}/bin:$PATH" cargo "$@" + ;; + "+"*) + echo "Channel $1 not installed. You may need to add it to the devShell" >&2 + exit 1 + ;; + *) + exec env PATH="${rustToolchain "stable"}/bin:$PATH" cargo "$@" + ;; + esac + ''; +in +{ + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + # c/gnu base + gnumake + pkg-config + stdenv + + # rust - toolchain + cargoWrapper # first in PATH, to be invoked instead one from toolchain + (rustToolchain "stable") + # rust - wasm + binaryen # wasm-opt + wasm-bindgen-cli_0_2_100 + wasm-pack + # rust - other + cargo-edit + cargo-ndk + cargo-udeps + + # javascript + nodejs + nodePackages.typescript-language-server + ]; + }; +} diff --git a/nix/packages.nix b/nix/packages.nix new file mode 100644 index 00000000..f398b4f3 --- /dev/null +++ b/nix/packages.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + packages.default = { }; +}