diff --git a/flake.lock b/flake.lock index b0f62a7a..15c474a9 100644 --- a/flake.lock +++ b/flake.lock @@ -136,6 +136,24 @@ "type": "github" } }, + "crane": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1704819371, + "narHash": "sha256-oFUfPWrWGQTZaCM3byxwYwrMLwshDxVGOrMH5cVP/X8=", + "owner": "ipetkov", + "repo": "crane", + "rev": "5c234301a1277e4cc759c23a2a7a00a06ddd7111", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "crescent-src": { "flake": false, "locked": { @@ -479,7 +497,7 @@ "gomod2nix": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1702956934, @@ -835,16 +853,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1702272962, - "narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=", - "owner": "nixos", + "lastModified": 1704008649, + "narHash": "sha256-rGPSWjXTXTurQN9beuHdyJhB8O761w1Zc5BqSSmHvoM=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d", + "rev": "d44d59d2b5bd694cd9d996fd8c51d03e3e9ba7f7", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -868,6 +886,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1702272962, + "narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1704161960, "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", @@ -883,7 +917,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1681358109, "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", @@ -899,7 +933,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1674990008, "narHash": "sha256-4zOyp+hFW2Y7imxIpZqZGT8CEqKmDjwgfD6BzRUE0mQ=", @@ -993,6 +1027,7 @@ "cometbft-src": "cometbft-src", "cosmos-sdk-src": "cosmos-sdk-src", "cosmwasm-src": "cosmwasm-src", + "crane": "crane", "crescent-src": "crescent-src", "cw-plus-src": "cw-plus-src", "evmos-src": "evmos-src", @@ -1031,7 +1066,7 @@ "namada-src": "namada-src", "neutron-src": "neutron-src", "nix-std": "nix-std", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "osmosis-src": "osmosis-src", "provenance-src": "provenance-src", "regen-src": "regen-src", @@ -1061,7 +1096,7 @@ "rust-overlay": { "inputs": { "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1704075545, @@ -1080,7 +1115,7 @@ "sbt-derivation": { "inputs": { "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1698464090, diff --git a/flake.nix b/flake.nix index 4e0001a7..42a6cf17 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,7 @@ # Nix Inputs nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; + crane.url = "github:ipetkov/crane"; sbt-derivation.url = "github:zaninime/sbt-derivation"; nix-std.url = "github:chessai/nix-std"; flake-parts.url = "github:hercules-ci/flake-parts"; diff --git a/modules/packages.nix b/modules/packages.nix index 3b6364b3..4c77154a 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -144,14 +144,6 @@ inherit (self'.packages) libwasmvm_1_2_3; inherit cosmosLib; }; - namada = import ../packages/namada.nix { - inherit pkgs; - inherit (inputs) namada-src; - }; - namada-src = pkgs.symlinkJoin { - name = "namada-src"; - paths = [inputs.namada-src.outPath]; - }; } # This list contains attr sets that are recursively merged into the # base attrset @@ -180,6 +172,12 @@ inherit (inputs) evmos-src; inherit (cosmosLib) mkGenerator; }) + # Namada + (import ../packages/namada { + inherit pkgs; + inherit (inputs) namada-src; + craneLib = inputs.crane.lib.${system}; + }) ]; }; } diff --git a/packages/namada.nix b/packages/namada.nix index 4a118ec3..9e52ef60 100644 --- a/packages/namada.nix +++ b/packages/namada.nix @@ -2,47 +2,98 @@ pkgs, namada-src, }: -pkgs.rustPlatform.buildRustPackage { - pname = "namada"; - version = "v0.28.1"; - src = namada-src; - nativeBuildInputs = with pkgs; - ( - lib.optionals stdenv.isLinux - [pkg-config] - ) - ++ [ - protobuf - rustPlatform.bindgenHook # required for bindgen in custom build script for librocksdb-sys - ]; - buildInputs = with pkgs; - lib.optionals stdenv.isLinux [ - systemd # required for libudev in custom build script for hidapi - ] - ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.Security - hidapi - ] - ++ [ - openssl - openssl.dev - ]; + { + namada = pkgs.rustPlatform.buildRustPackage { + pname = "namada"; + version = "v0.28.1"; + src = namada-src; + nativeBuildInputs = with pkgs; + ( + lib.optionals stdenv.isLinux + [pkg-config] + ) + ++ [ + protobuf + rustPlatform.bindgenHook # required for bindgen in custom build script for librocksdb-sys + ]; + buildInputs = with pkgs; + lib.optionals stdenv.isLinux [ + systemd # required for libudev in custom build script for hidapi + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + hidapi + ] + ++ [ + openssl + openssl.dev + ]; - cargoLock = { - lockFile = "${namada-src}/Cargo.lock"; - outputHashes = { - "borsh-ext-1.2.0" = "sha256-nQadqyeAY0/gEMLBkpqtSm5D7kV+r3LVT/Cg2oTV7Ug="; - "clru-0.5.0" = "sha256-/1NfKqcWGCyF3+f0v2CnuFmNjjKkzfvYcX+GzxLwz7s="; - "ethbridge-bridge-contract-0.24.0" = "sha256-qs81bIWKk4oxh6nFWqAt4eBbPuIWF2a3ytUSjDJZWSU="; - "index-set-0.8.0" = "sha256-oxJfQdKnYiW5VbMPuukVyDY5n8mys31hYNrJF89nXhY="; - "ledger-namada-rs-0.0.1" = "sha256-qFL8LU7i5NAnMUhtrGykVfiYX1NodCNkZG07twyVrac="; - "masp_note_encryption-1.0.0" = "sha256-NwiosHTdzzny+L5VtOBaIa7wia/yRlfiz/8f0pAHUZk="; - "sparse-merkle-tree-0.3.1-pre" = "sha256-B1ZEN4FZjV0x0Cqvx7AZjH9qhDMZYFPVJzg89dqWCv4="; - "tiny-bip39-0.8.2" = "sha256-TU+7Vug3+M6Zxhy6Wln54Pxc9ES4EdFq5TvMOcAG+qA="; - "tower-abci-0.11.1" = "sha256-KisZtsylvUymvV1TpDdGIiE7fSarcuD3I8oZ33BdKTU="; - "wasmer-2.3.0" = "sha256-Fd8ewAwslopjqUVoeHwSR/Zoh4Zm+Sdx8oksXmhLU20="; - "zcash_encoding-0.2.0" = "sha256-keuaoM/t1Q/+8JMemMMUuIo4g5I/EAoONFge+dyWGy0="; - }; + cargoLock = { + lockFile = "${namada-src}/Cargo.lock"; + outputHashes = { + "borsh-ext-1.2.0" = "sha256-nQadqyeAY0/gEMLBkpqtSm5D7kV+r3LVT/Cg2oTV7Ug="; + "clru-0.5.0" = "sha256-/1NfKqcWGCyF3+f0v2CnuFmNjjKkzfvYcX+GzxLwz7s="; + "ethbridge-bridge-contract-0.24.0" = "sha256-qs81bIWKk4oxh6nFWqAt4eBbPuIWF2a3ytUSjDJZWSU="; + "index-set-0.8.0" = "sha256-oxJfQdKnYiW5VbMPuukVyDY5n8mys31hYNrJF89nXhY="; + "ledger-namada-rs-0.0.1" = "sha256-qFL8LU7i5NAnMUhtrGykVfiYX1NodCNkZG07twyVrac="; + "masp_note_encryption-1.0.0" = "sha256-NwiosHTdzzny+L5VtOBaIa7wia/yRlfiz/8f0pAHUZk="; + "sparse-merkle-tree-0.3.1-pre" = "sha256-B1ZEN4FZjV0x0Cqvx7AZjH9qhDMZYFPVJzg89dqWCv4="; + "tiny-bip39-0.8.2" = "sha256-TU+7Vug3+M6Zxhy6Wln54Pxc9ES4EdFq5TvMOcAG+qA="; + "tower-abci-0.11.1" = "sha256-KisZtsylvUymvV1TpDdGIiE7fSarcuD3I8oZ33BdKTU="; + "wasmer-2.3.0" = "sha256-Fd8ewAwslopjqUVoeHwSR/Zoh4Zm+Sdx8oksXmhLU20="; + "zcash_encoding-0.2.0" = "sha256-keuaoM/t1Q/+8JMemMMUuIo4g5I/EAoONFge+dyWGy0="; + }; + }; + doCheck = false; + }; + namada-wasm-scripts = pkgs.rustPlatform.buildRustPackage { + pname = "namada-wasm-scripts"; + version = "v0.28.1"; + src = pkgs.symlinkJoin + { + name = "namada-wasm-scripts-src" ; + paths = [ "${namada-src}/wasm" "${namada-src}/tx_prelude" "${namada-src}/vp_prelude" ]; + patches = []; + }; + nativeBuildInputs = with pkgs; + ( + lib.optionals stdenv.isLinux + [pkg-config] + ) + ++ [ + protobuf + rustPlatform.bindgenHook # required for bindgen in custom build script for librocksdb-sys + ]; + buildInputs = with pkgs; + lib.optionals stdenv.isLinux [ + systemd # required for libudev in custom build script for hidapi + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + hidapi + ] + ++ [ + openssl + openssl.dev + ]; + + preBuild = "${pkgs.tree}/bin/tree ."; + + cargoLock = { + lockFile = "${namada-src}/wasm/Cargo.lock"; + outputHashes = { + "borsh-ext-1.2.0" = "sha256-nQadqyeAY0/gEMLBkpqtSm5D7kV+r3LVT/Cg2oTV7Ug="; + "clru-0.5.0" = "sha256-/1NfKqcWGCyF3+f0v2CnuFmNjjKkzfvYcX+GzxLwz7s="; + "ethbridge-bridge-contract-0.24.0" = "sha256-qs81bIWKk4oxh6nFWqAt4eBbPuIWF2a3ytUSjDJZWSU="; + "index-set-0.8.0" = "sha256-oxJfQdKnYiW5VbMPuukVyDY5n8mys31hYNrJF89nXhY="; + "masp_note_encryption-1.0.0" = "sha256-NwiosHTdzzny+L5VtOBaIa7wia/yRlfiz/8f0pAHUZk="; + "sparse-merkle-tree-0.3.1-pre" = "sha256-B1ZEN4FZjV0x0Cqvx7AZjH9qhDMZYFPVJzg89dqWCv4="; + "tiny-bip39-0.8.2" = "sha256-TU+7Vug3+M6Zxhy6Wln54Pxc9ES4EdFq5TvMOcAG+qA="; + "wasmer-2.3.0" = "sha256-Fd8ewAwslopjqUVoeHwSR/Zoh4Zm+Sdx8oksXmhLU20="; + "zcash_encoding-0.2.0" = "sha256-keuaoM/t1Q/+8JMemMMUuIo4g5I/EAoONFge+dyWGy0="; + }; + }; + doCheck = false; }; - doCheck = false; } diff --git a/packages/namada/default.nix b/packages/namada/default.nix new file mode 100644 index 00000000..25e33808 --- /dev/null +++ b/packages/namada/default.nix @@ -0,0 +1,67 @@ +{ + pkgs, + namada-src, + craneLib, +}: +let version = "v0.28.1"; +in + { + namada = pkgs.rustPlatform.buildRustPackage { + pname = "namada"; + inherit version; + src = namada-src; + nativeBuildInputs = with pkgs; + ( + lib.optionals stdenv.isLinux + [pkg-config] + ) + ++ [ + protobuf + rustPlatform.bindgenHook # required for bindgen in custom build script for librocksdb-sys + ]; + buildInputs = with pkgs; + lib.optionals stdenv.isLinux [ + systemd # required for libudev in custom build script for hidapi + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + hidapi + ] + ++ [ + openssl + openssl.dev + ]; + + cargoLock = { + lockFile = "${namada-src}/Cargo.lock"; + outputHashes = { + "borsh-ext-1.2.0" = "sha256-nQadqyeAY0/gEMLBkpqtSm5D7kV+r3LVT/Cg2oTV7Ug="; + "clru-0.5.0" = "sha256-/1NfKqcWGCyF3+f0v2CnuFmNjjKkzfvYcX+GzxLwz7s="; + "ethbridge-bridge-contract-0.24.0" = "sha256-qs81bIWKk4oxh6nFWqAt4eBbPuIWF2a3ytUSjDJZWSU="; + "index-set-0.8.0" = "sha256-oxJfQdKnYiW5VbMPuukVyDY5n8mys31hYNrJF89nXhY="; + "ledger-namada-rs-0.0.1" = "sha256-qFL8LU7i5NAnMUhtrGykVfiYX1NodCNkZG07twyVrac="; + "masp_note_encryption-1.0.0" = "sha256-NwiosHTdzzny+L5VtOBaIa7wia/yRlfiz/8f0pAHUZk="; + "sparse-merkle-tree-0.3.1-pre" = "sha256-B1ZEN4FZjV0x0Cqvx7AZjH9qhDMZYFPVJzg89dqWCv4="; + "tiny-bip39-0.8.2" = "sha256-TU+7Vug3+M6Zxhy6Wln54Pxc9ES4EdFq5TvMOcAG+qA="; + "tower-abci-0.11.1" = "sha256-KisZtsylvUymvV1TpDdGIiE7fSarcuD3I8oZ33BdKTU="; + "wasmer-2.3.0" = "sha256-Fd8ewAwslopjqUVoeHwSR/Zoh4Zm+Sdx8oksXmhLU20="; + "zcash_encoding-0.2.0" = "sha256-keuaoM/t1Q/+8JMemMMUuIo4g5I/EAoONFge+dyWGy0="; + }; + }; + doCheck = false; + }; + namada-wasm-scripts = let + craneLib' = craneLib.overrideToolchain (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)); + src = namada-src; + cargoExtraArgs = "--manifest-path=./wasm/Cargo.toml --locked"; + name = "namada-wasm-scripts"; + cargoArtifacts = craneLib'.buildDepsOnly { + cargoLock = "${src}/wasm/Cargo.lock"; + pname = "${name}-deps"; + inherit version src cargoExtraArgs; + }; + in craneLib'.buildPackage { + pname = name; + inherit version src cargoExtraArgs cargoArtifacts; + }; +}