Skip to content

Commit 44a4f91

Browse files
Add komet.rust-stellar derivation that provides cargo and stellar in PATH (#84)
* move `komet` and `komet-pyk` outside of overlay * change nix rust target from `wasm32-unknown-unknown` to `wasm32v1-none` * add `komet.rust-soroban` derivation * populate nix binary cache with `komet.rust-soroban` in CI * Set Version: 0.1.69 * change `soroban` to `stellar` --------- Co-authored-by: devops <devops@runtimeverification.com>
1 parent 122f4d3 commit 44a4f91

5 files changed

Lines changed: 136 additions & 125 deletions

File tree

.github/workflows/master.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,6 @@ jobs:
6868
script: |
6969
export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH"
7070
kup publish k-framework-binary .#komet --keep-days 180
71+
kup publish k-framework-binary .#komet.rust-stellar --keep-days 180
7172
7273

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 106 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -8,154 +8,135 @@
88
flake-utils.follows = "k-framework/flake-utils";
99
rv-utils.follows = "k-framework/rv-utils";
1010
poetry2nix.follows = "k-framework/poetry2nix";
11+
1112
rust-overlay.url = "github:oxalica/rust-overlay";
13+
14+
stellar-cli-flake.url = "github:stellar/stellar-cli";
15+
stellar-cli-flake.inputs = {
16+
flake-utils.follows = "flake-utils";
17+
nixpkgs.follows = "nixpkgs";
18+
rust-overlay.follows = "rust-overlay";
19+
};
1220
};
1321

1422
outputs = { self, k-framework, nixpkgs, flake-utils, rv-utils, wasm-semantics
15-
, rust-overlay, ... }@inputs:
16-
let
17-
mkCleanSource = { pkgs, src }: pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [
18-
"/.github"
19-
"flake.nix"
20-
"flake.lock"
21-
./.gitignore
22-
# do not include submodule directories that might be initilized empty or non-existent
23-
"/deps/soroban-examples"
24-
] src
25-
);
26-
overlay = (final: prev:
27-
let
28-
src = mkCleanSource {
29-
src = ./.;
30-
pkgs = final;
31-
};
32-
33-
version = self.rev or "dirty";
34-
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { pkgs = prev; };
35-
in rec {
36-
komet = prev.stdenv.mkDerivation {
37-
pname = "komet";
38-
inherit src version;
39-
40-
buildInputs = with final; [
41-
k-framework.packages.${system}.pyk-python310
42-
k-framework.packages.${system}.k
43-
komet-pyk
44-
];
45-
46-
dontUseCmakeConfigure = true;
47-
48-
nativeBuildInputs = [ prev.makeWrapper ];
49-
50-
enableParallelBuilding = true;
51-
52-
buildPhase = ''
53-
export XDG_CACHE_HOME=$(pwd)
54-
${
55-
prev.lib.optionalString
56-
(prev.stdenv.isAarch64 && prev.stdenv.isDarwin)
57-
"APPLE_SILICON=true"
58-
} K_OPTS="-Xmx8G -Xss512m" kdist -v build soroban-semantics.* -j$NIX_BUILD_CORES
59-
'';
60-
61-
installPhase = ''
62-
mkdir -p $out
63-
cp -r ./kdist-*/* $out/
64-
65-
makeWrapper ${komet-pyk}/bin/komet $out/bin/komet --prefix PATH : ${
66-
prev.lib.makeBinPath [ k-framework.packages.${prev.system}.k ]
67-
} --set KDIST_DIR $out
68-
'';
69-
};
70-
71-
komet-pyk = poetry2nix.mkPoetryApplication {
72-
python = prev.python310;
73-
projectDir = ./.;
74-
src = rv-utils.lib.mkSubdirectoryAppSrc {
75-
pkgs = import nixpkgs { system = prev.system; };
76-
src = ./.;
77-
subdirectories = [ "pykwasm" ];
78-
cleaner = { src }: poetry2nix.cleanPythonSources {
79-
src = (mkCleanSource {
80-
inherit src;
81-
pkgs = final;
82-
});
83-
};
84-
};
85-
overrides = poetry2nix.overrides.withDefaults
86-
(finalPython: prevPython: {
87-
kframework = k-framework.packages.${prev.system}.pyk-python310;
88-
pykwasm = wasm-semantics.packages.${prev.system}.kwasm-pyk;
89-
});
90-
groups = [ ];
91-
checkGroups = [ ];
92-
};
93-
});
94-
in flake-utils.lib.eachSystem [
23+
, rust-overlay, stellar-cli-flake, ... }@inputs: flake-utils.lib.eachSystem [
9524
"x86_64-linux"
9625
"x86_64-darwin"
9726
"aarch64-linux"
9827
"aarch64-darwin"
9928
] (system:
10029
let
30+
# stellar-cli flake does not build on NixOS machines due to openssl issues during `cargo build`
31+
# putting `pkg-config` in `nativeBuildInputs` will run the `pkg-config` setuphook, which will look for derivations in `buildInputs`
32+
# with a `pkgconfig` directory such as the `openssl` derivation
33+
# this will then setup the `PKG_CONFIG_PATH` env variable properly
34+
stellar-cli-overlay = final: prev: {
35+
stellar-cli = stellar-cli-flake.packages.${system}.default.overrideAttrs (finalAttrs: previousAttrs: {
36+
nativeBuildInputs = (previousAttrs.nativeBuildInputs or [ ]) ++ (with final; [
37+
pkg-config
38+
]);
39+
buildInputs = (previousAttrs.buildInputs or [ ]) ++ (with final; [
40+
openssl
41+
]);
42+
});
43+
};
10144
pkgs = import nixpkgs {
10245
inherit system;
103-
overlays = [ overlay (import rust-overlay) ];
46+
overlays = [
47+
stellar-cli-overlay
48+
(import rust-overlay)
49+
];
10450
};
10551

106-
rustWithWasmTarget = pkgs.rust-bin.stable.latest.default.override {
107-
targets = [ "wasm32-unknown-unknown" ];
108-
};
109-
110-
rustPlatformWasm = pkgs.makeRustPlatform {
111-
cargo = rustWithWasmTarget;
112-
rustc = rustWithWasmTarget;
113-
};
52+
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
11453

115-
version = "21.4.0";
116-
stellar-src = pkgs.fetchFromGitHub {
117-
owner = "stellar";
118-
repo = "stellar-cli";
119-
rev = "v${version}";
120-
hash = "sha256-yPg0Tsnb7H7S1MbVvfWrAmTWehWqwJYSqYLqLWVNq0Y=";
54+
komet-pyk = poetry2nix.mkPoetryApplication {
55+
python = pkgs.python310;
56+
projectDir = ./.;
57+
src = rv-utils.lib.mkSubdirectoryAppSrc {
58+
inherit pkgs;
59+
src = ./.;
60+
subdirectories = [ "pykwasm" ];
61+
cleaner = poetry2nix.cleanPythonSources;
62+
};
63+
overrides = poetry2nix.overrides.withDefaults
64+
(finalPython: prevPython: {
65+
kframework = k-framework.packages.${system}.pyk-python310;
66+
pykwasm = wasm-semantics.packages.${system}.kwasm-pyk;
67+
});
68+
groups = [ ];
69+
checkGroups = [ ];
12170
};
12271

123-
stellar-cli = rustPlatformWasm.buildRustPackage rec {
124-
pname = "stellar-cli";
125-
inherit version;
126-
src = stellar-src;
127-
128-
nativeBuildInputs = [ pkgs.pkg-config ]
129-
++ (if pkgs.stdenv.isDarwin then
130-
[ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ]
131-
else
132-
[ ]);
133-
134-
buildInputs = [ pkgs.openssl pkgs.openssl.dev ];
135-
136-
OPENSSL_NO_VENDOR = 1;
137-
GIT_REVISION = "v${version}";
138-
139-
doCheck = false;
72+
mkKomet = {komet-rust ? null, komet-stellar ? null}@args: pkgs.stdenv.mkDerivation {
73+
pname = "komet";
74+
version = self.rev or "dirty";
75+
src = pkgs.lib.cleanSource (pkgs.nix-gitignore.gitignoreSourcePure [
76+
"/.github"
77+
"flake.nix"
78+
"flake.lock"
79+
./.gitignore
80+
] ./.);
81+
82+
buildInputs = with pkgs; [
83+
k-framework.packages.${system}.pyk-python310
84+
k-framework.packages.${system}.k
85+
komet-pyk
86+
];
87+
88+
dontUseCmakeConfigure = true;
89+
90+
nativeBuildInputs = [ pkgs.makeWrapper ];
91+
92+
enableParallelBuilding = true;
93+
94+
buildPhase = ''
95+
export XDG_CACHE_HOME=$(pwd)
96+
${
97+
pkgs.lib.optionalString
98+
(pkgs.stdenv.isAarch64 && pkgs.stdenv.isDarwin)
99+
"APPLE_SILICON=true"
100+
} K_OPTS="-Xmx8G -Xss512m" kdist -v build soroban-semantics.* -j$NIX_BUILD_CORES
101+
'';
140102

141-
cargoLock = {
142-
lockFile = "${stellar-src}/Cargo.lock";
143-
outputHashes = {
144-
"testcontainers-0.15.0" =
145-
"sha256-v9HJ0cgDgTCRwB6lPm425EmVq3L9oNI8NVCzv4T2HOQ=";
146-
};
147-
};
103+
installPhase = ''
104+
mkdir -p $out
105+
cp -r ./kdist-*/* $out/
106+
107+
makeWrapper ${komet-pyk}/bin/komet $out/bin/komet --prefix PATH : ${
108+
pkgs.lib.makeBinPath (
109+
[
110+
k-framework.packages.${system}.k
111+
] ++ pkgs.lib.optionals (komet-rust != null) [
112+
komet-rust
113+
] ++ pkgs.lib.optionals (komet-stellar != null) [
114+
komet-stellar
115+
]
116+
)
117+
} --set KDIST_DIR $out
118+
'';
148119

120+
passthru = if komet-rust == null && komet-stellar == null then {
121+
rust-stellar = pkgs.callPackage mkKomet (args // {
122+
komet-rust = rustWithWasmTarget;
123+
komet-stellar = pkgs.stellar-cli;
124+
});
125+
} else { };
149126
};
127+
komet = pkgs.callPackage mkKomet { };
150128

129+
rustWithWasmTarget = pkgs.rust-bin.stable.latest.default.override {
130+
targets = [ "wasm32v1-none" ];
131+
};
151132
in {
152133
packages = rec {
153-
inherit (pkgs) komet komet-pyk;
154-
default = pkgs.komet;
134+
inherit komet komet-pyk;
135+
default = komet;
155136
};
156137

157138
devShell = pkgs.mkShell {
158-
buildInputs = with pkgs; [ stellar-cli komet rustWithWasmTarget ];
139+
buildInputs = [ pkgs.stellar-cli komet rustWithWasmTarget ];
159140

160141
shellHook = ''
161142
${pkgs.lib.strings.optionalString
@@ -165,6 +146,8 @@
165146
};
166147

167148
}) // {
168-
overlays.default = overlay;
149+
overlays.default = final: prev: {
150+
inherit (self.packages.${final.system}) komet komet-pyk;
151+
};
169152
};
170153
}

package/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.68
1+
0.1.69

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "komet"
7-
version = "0.1.68"
7+
version = "0.1.69"
88
description = "K tooling for the Soroban platform"
99
authors = [
1010
"Runtime Verification, Inc. <contact@runtimeverification.com>",

0 commit comments

Comments
 (0)