diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a84458d --- /dev/null +++ b/flake.lock @@ -0,0 +1,106 @@ +{ + "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716156051, + "narHash": "sha256-TjUX7WWRcrhuUxDHsR8pDR2N7jitqZehgCVSy3kBeS8=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7443df1c478947bf96a2e699209f53b2db26209d", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716137900, + "narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716257780, + "narHash": "sha256-R+NjvJzKEkTVCmdrKRfPE4liX/KMGVqGUwwS5H8ET8A=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "4e5e3d2c5c9b2721bd266f9e43c14e96811b89d2", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9ebbebe --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + description = "A nix development shell and build environment for ibc-types"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + crane = { + url = "github:ipetkov/crane"; + inputs = { nixpkgs.follows = "nixpkgs"; }; + }; + }; + + outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: + flake-utils.lib.eachDefaultSystem + (system: + let + # Set up for Rust builds, use the stable Rust toolchain + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + rustToolchain = pkgs.rust-bin.stable."1.78.0".default; + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + src = craneLib.cleanCargoSource (craneLib.path ./.); + # Important environment variables so that the build can find the necessary libraries + PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig"; + in with pkgs; with pkgs.lib; + let + ibc-types = (craneLib.buildPackage { + pname = "ibc-types"; + version = "0.13.0"; + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ openssl ]; + inherit src system PKG_CONFIG_PATH; + cargoVendorDir = null; + cargoExtraArgs = "-p ibc-types"; + meta = { + description = "Common data structures for Inter-Blockchain Communication (IBC) messages"; + homepage = "https://github.com/penumbra-zone/ibc-types"; + license = [ licenses.mit licenses.asl20 ]; + }; + }).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times + in rec { + packages = { inherit ibc-types; }; + devShells.default = craneLib.devShell { + inputsFrom = [ ibc-types ]; + packages = [ cargo-watch cargo-nextest ]; + shellHook = '' + export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer + ''; + }; + } + ); +}