From f255928714e9342ceb1733d9517537a284003a99 Mon Sep 17 00:00:00 2001 From: Julian Kuners Date: Wed, 28 May 2025 13:27:08 +0200 Subject: [PATCH 1/6] move `komet` and `komet-pyk` outside of overlay --- flake.nix | 154 ++++++++++++++++++++++++------------------------------ 1 file changed, 69 insertions(+), 85 deletions(-) diff --git a/flake.nix b/flake.nix index 64d33ce..2cd1ffe 100644 --- a/flake.nix +++ b/flake.nix @@ -12,86 +12,7 @@ }; outputs = { self, k-framework, nixpkgs, flake-utils, rv-utils, wasm-semantics - , rust-overlay, ... }@inputs: - let - mkCleanSource = { pkgs, src }: pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [ - "/.github" - "flake.nix" - "flake.lock" - ./.gitignore - # do not include submodule directories that might be initilized empty or non-existent - "/deps/soroban-examples" - ] src - ); - overlay = (final: prev: - let - src = mkCleanSource { - src = ./.; - pkgs = final; - }; - - version = self.rev or "dirty"; - poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = prev; }; - in rec { - komet = prev.stdenv.mkDerivation { - pname = "komet"; - inherit src version; - - buildInputs = with final; [ - k-framework.packages.${system}.pyk-python310 - k-framework.packages.${system}.k - komet-pyk - ]; - - dontUseCmakeConfigure = true; - - nativeBuildInputs = [ prev.makeWrapper ]; - - enableParallelBuilding = true; - - buildPhase = '' - export XDG_CACHE_HOME=$(pwd) - ${ - prev.lib.optionalString - (prev.stdenv.isAarch64 && prev.stdenv.isDarwin) - "APPLE_SILICON=true" - } K_OPTS="-Xmx8G -Xss512m" kdist -v build soroban-semantics.* -j$NIX_BUILD_CORES - ''; - - installPhase = '' - mkdir -p $out - cp -r ./kdist-*/* $out/ - - makeWrapper ${komet-pyk}/bin/komet $out/bin/komet --prefix PATH : ${ - prev.lib.makeBinPath [ k-framework.packages.${prev.system}.k ] - } --set KDIST_DIR $out - ''; - }; - - komet-pyk = poetry2nix.mkPoetryApplication { - python = prev.python310; - projectDir = ./.; - src = rv-utils.lib.mkSubdirectoryAppSrc { - pkgs = import nixpkgs { system = prev.system; }; - src = ./.; - subdirectories = [ "pykwasm" ]; - cleaner = { src }: poetry2nix.cleanPythonSources { - src = (mkCleanSource { - inherit src; - pkgs = final; - }); - }; - }; - overrides = poetry2nix.overrides.withDefaults - (finalPython: prevPython: { - kframework = k-framework.packages.${prev.system}.pyk-python310; - pykwasm = wasm-semantics.packages.${prev.system}.kwasm-pyk; - }); - groups = [ ]; - checkGroups = [ ]; - }; - }); - in flake-utils.lib.eachSystem [ + , rust-overlay, ... }@inputs: flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" @@ -100,7 +21,68 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ overlay (import rust-overlay) ]; + overlays = [ (import rust-overlay) ]; + }; + + poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }; + + komet-pyk = poetry2nix.mkPoetryApplication { + python = pkgs.python310; + projectDir = ./.; + src = rv-utils.lib.mkSubdirectoryAppSrc { + inherit pkgs; + src = ./.; + subdirectories = [ "pykwasm" ]; + cleaner = poetry2nix.cleanPythonSources; + }; + overrides = poetry2nix.overrides.withDefaults + (finalPython: prevPython: { + kframework = k-framework.packages.${system}.pyk-python310; + pykwasm = wasm-semantics.packages.${system}.kwasm-pyk; + }); + groups = [ ]; + checkGroups = [ ]; + }; + + komet = pkgs.stdenv.mkDerivation { + pname = "komet"; + version = self.rev or "dirty"; + src = pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [ + "/.github" + "flake.nix" + "flake.lock" + ./.gitignore + ] ./.); + + buildInputs = with pkgs; [ + k-framework.packages.${system}.pyk-python310 + k-framework.packages.${system}.k + komet-pyk + ]; + + dontUseCmakeConfigure = true; + + nativeBuildInputs = [ pkgs.makeWrapper ]; + + enableParallelBuilding = true; + + buildPhase = '' + export XDG_CACHE_HOME=$(pwd) + ${ + pkgs.lib.optionalString + (pkgs.stdenv.isAarch64 && pkgs.stdenv.isDarwin) + "APPLE_SILICON=true" + } K_OPTS="-Xmx8G -Xss512m" kdist -v build soroban-semantics.* -j$NIX_BUILD_CORES + ''; + + installPhase = '' + mkdir -p $out + cp -r ./kdist-*/* $out/ + + makeWrapper ${komet-pyk}/bin/komet $out/bin/komet --prefix PATH : ${ + pkgs.lib.makeBinPath [ k-framework.packages.${system}.k ] + } --set KDIST_DIR $out + ''; }; rustWithWasmTarget = pkgs.rust-bin.stable.latest.default.override { @@ -150,12 +132,12 @@ in { packages = rec { - inherit (pkgs) komet komet-pyk; - default = pkgs.komet; + inherit komet komet-pyk; + default = komet; }; devShell = pkgs.mkShell { - buildInputs = with pkgs; [ stellar-cli komet rustWithWasmTarget ]; + buildInputs = [ stellar-cli komet rustWithWasmTarget ]; shellHook = '' ${pkgs.lib.strings.optionalString @@ -165,6 +147,8 @@ }; }) // { - overlays.default = overlay; + overlays.default = final: prev: { + inherit (self.packages.${final.system}) komet komet-pyk; + }; }; } From 721de2b680734f4852fc942c8f7ea658d075369f Mon Sep 17 00:00:00 2001 From: Julian Kuners Date: Thu, 29 May 2025 00:50:24 +0200 Subject: [PATCH 2/6] change nix rust target from `wasm32-unknown-unknown` to `wasm32v1-none` --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2cd1ffe..7c03f12 100644 --- a/flake.nix +++ b/flake.nix @@ -86,7 +86,7 @@ }; rustWithWasmTarget = pkgs.rust-bin.stable.latest.default.override { - targets = [ "wasm32-unknown-unknown" ]; + targets = [ "wasm32v1-none" ]; }; rustPlatformWasm = pkgs.makeRustPlatform { From c9c5699b3b471316aa61f65207f7118afe9a76fa Mon Sep 17 00:00:00 2001 From: Julian Kuners Date: Fri, 30 May 2025 12:47:36 +0200 Subject: [PATCH 3/6] add `komet.rust-soroban` derivation --- flake.lock | 27 ++++++++++++++++ flake.nix | 93 +++++++++++++++++++++++++++--------------------------- 2 files changed, 73 insertions(+), 47 deletions(-) diff --git a/flake.lock b/flake.lock index 08e2973..9e44552 100644 --- a/flake.lock +++ b/flake.lock @@ -330,6 +330,7 @@ "k-framework", "rv-utils" ], + "stellar-cli-flake": "stellar-cli-flake", "wasm-semantics": "wasm-semantics" } }, @@ -385,6 +386,32 @@ "type": "github" } }, + "stellar-cli-flake": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": [ + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1748046752, + "narHash": "sha256-3Gnc0PMF4Md27D46RGcGazD+KstvCdcvSt2ZcPHq4i4=", + "owner": "stellar", + "repo": "stellar-cli", + "rev": "949f1620c46296c84c2f4de6e5aa70e9dc59590f", + "type": "github" + }, + "original": { + "owner": "stellar", + "repo": "stellar-cli", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 7c03f12..db6e461 100644 --- a/flake.nix +++ b/flake.nix @@ -8,20 +8,45 @@ flake-utils.follows = "k-framework/flake-utils"; rv-utils.follows = "k-framework/rv-utils"; poetry2nix.follows = "k-framework/poetry2nix"; + rust-overlay.url = "github:oxalica/rust-overlay"; + + stellar-cli-flake.url = "github:stellar/stellar-cli"; + stellar-cli-flake.inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + rust-overlay.follows = "rust-overlay"; + }; }; outputs = { self, k-framework, nixpkgs, flake-utils, rv-utils, wasm-semantics - , rust-overlay, ... }@inputs: flake-utils.lib.eachSystem [ + , rust-overlay, stellar-cli-flake, ... }@inputs: flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ] (system: let + # stellar-cli flake does not build on NixOS machines due to openssl issues during `cargo build` + # putting `pkg-config` in `nativeBuildInputs` will run the `pkg-config` setuphook, which will look for derivations in `buildInputs` + # with a `pkgconfig` directory such as the `openssl` derivation + # this will then setup the `PKG_CONFIG_PATH` env variable properly + stellar-cli-overlay = final: prev: { + stellar-cli = stellar-cli-flake.packages.${system}.default.overrideAttrs (finalAttrs: previousAttrs: { + nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ (with final; [ + pkg-config + ]); + buildInputs = (previousAttrs.buildInputs or [ ]) ++ (with final; [ + openssl + ]); + }); + }; pkgs = import nixpkgs { inherit system; - overlays = [ (import rust-overlay) ]; + overlays = [ + stellar-cli-overlay + (import rust-overlay) + ]; }; poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }; @@ -44,7 +69,7 @@ checkGroups = [ ]; }; - komet = pkgs.stdenv.mkDerivation { + mkKomet = {komet-rust ? null, komet-soroban ? null}@args: pkgs.stdenv.mkDerivation { pname = "komet"; version = self.rev or "dirty"; src = pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [ @@ -80,56 +105,30 @@ cp -r ./kdist-*/* $out/ makeWrapper ${komet-pyk}/bin/komet $out/bin/komet --prefix PATH : ${ - pkgs.lib.makeBinPath [ k-framework.packages.${system}.k ] + pkgs.lib.makeBinPath ( + [ + k-framework.packages.${system}.k + ] ++ pkgs.lib.optionals (komet-rust != null) [ + komet-rust + ] ++ pkgs.lib.optionals (komet-soroban != null) [ + komet-soroban + ] + ) } --set KDIST_DIR $out ''; + + passthru = if komet-rust == null && komet-soroban == null then { + rust-soroban = pkgs.callPackage mkKomet (args // { + komet-rust = rustWithWasmTarget; + komet-soroban = pkgs.stellar-cli; + }); + } else { }; }; + komet = pkgs.callPackage mkKomet { }; rustWithWasmTarget = pkgs.rust-bin.stable.latest.default.override { targets = [ "wasm32v1-none" ]; }; - - rustPlatformWasm = pkgs.makeRustPlatform { - cargo = rustWithWasmTarget; - rustc = rustWithWasmTarget; - }; - - version = "21.4.0"; - stellar-src = pkgs.fetchFromGitHub { - owner = "stellar"; - repo = "stellar-cli"; - rev = "v${version}"; - hash = "sha256-yPg0Tsnb7H7S1MbVvfWrAmTWehWqwJYSqYLqLWVNq0Y="; - }; - - stellar-cli = rustPlatformWasm.buildRustPackage rec { - pname = "stellar-cli"; - inherit version; - src = stellar-src; - - nativeBuildInputs = [ pkgs.pkg-config ] - ++ (if pkgs.stdenv.isDarwin then - [ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ] - else - [ ]); - - buildInputs = [ pkgs.openssl pkgs.openssl.dev ]; - - OPENSSL_NO_VENDOR = 1; - GIT_REVISION = "v${version}"; - - doCheck = false; - - cargoLock = { - lockFile = "${stellar-src}/Cargo.lock"; - outputHashes = { - "testcontainers-0.15.0" = - "sha256-v9HJ0cgDgTCRwB6lPm425EmVq3L9oNI8NVCzv4T2HOQ="; - }; - }; - - }; - in { packages = rec { inherit komet komet-pyk; @@ -137,7 +136,7 @@ }; devShell = pkgs.mkShell { - buildInputs = [ stellar-cli komet rustWithWasmTarget ]; + buildInputs = [ pkgs.stellar-cli komet rustWithWasmTarget ]; shellHook = '' ${pkgs.lib.strings.optionalString From ed1e423f64f5556b283f3d7fdee34fe1cce15777 Mon Sep 17 00:00:00 2001 From: Julian Kuners Date: Fri, 30 May 2025 14:03:32 +0200 Subject: [PATCH 4/6] populate nix binary cache with `komet.rust-soroban` in CI --- .github/workflows/master.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e026737..458b33d 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -68,5 +68,6 @@ jobs: script: | export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH" kup publish k-framework-binary .#komet --keep-days 180 + kup publish k-framework-binary .#komet.rust-soroban --keep-days 180 From 3eda5b0976703c1497d099adceb5ce381e39ba11 Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 30 May 2025 14:15:22 +0000 Subject: [PATCH 5/6] Set Version: 0.1.69 --- package/version | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/version b/package/version index 72052e2..9adbab1 100644 --- a/package/version +++ b/package/version @@ -1 +1 @@ -0.1.68 +0.1.69 diff --git a/pyproject.toml b/pyproject.toml index 14465b3..1fcc57b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "komet" -version = "0.1.68" +version = "0.1.69" description = "K tooling for the Soroban platform" authors = [ "Runtime Verification, Inc. ", From f79468b50fc869e60b8ecef0a53ff927e62121e8 Mon Sep 17 00:00:00 2001 From: Julian Kuners Date: Fri, 30 May 2025 16:50:29 +0200 Subject: [PATCH 6/6] change `soroban` to `stellar` --- .github/workflows/master.yml | 2 +- flake.nix | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 458b33d..1e396d5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -68,6 +68,6 @@ jobs: script: | export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH" kup publish k-framework-binary .#komet --keep-days 180 - kup publish k-framework-binary .#komet.rust-soroban --keep-days 180 + kup publish k-framework-binary .#komet.rust-stellar --keep-days 180 diff --git a/flake.nix b/flake.nix index db6e461..e89abf0 100644 --- a/flake.nix +++ b/flake.nix @@ -69,7 +69,7 @@ checkGroups = [ ]; }; - mkKomet = {komet-rust ? null, komet-soroban ? null}@args: pkgs.stdenv.mkDerivation { + mkKomet = {komet-rust ? null, komet-stellar ? null}@args: pkgs.stdenv.mkDerivation { pname = "komet"; version = self.rev or "dirty"; src = pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [ @@ -110,17 +110,17 @@ k-framework.packages.${system}.k ] ++ pkgs.lib.optionals (komet-rust != null) [ komet-rust - ] ++ pkgs.lib.optionals (komet-soroban != null) [ - komet-soroban + ] ++ pkgs.lib.optionals (komet-stellar != null) [ + komet-stellar ] ) } --set KDIST_DIR $out ''; - passthru = if komet-rust == null && komet-soroban == null then { - rust-soroban = pkgs.callPackage mkKomet (args // { + passthru = if komet-rust == null && komet-stellar == null then { + rust-stellar = pkgs.callPackage mkKomet (args // { komet-rust = rustWithWasmTarget; - komet-soroban = pkgs.stellar-cli; + komet-stellar = pkgs.stellar-cli; }); } else { }; };