Skip to content

Commit 2ab976c

Browse files
rvolosatovsplatten
authored andcommitted
build(nix): build Cryptle
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent aad3b1e commit 2ab976c

File tree

2 files changed

+286
-0
lines changed

2 files changed

+286
-0
lines changed

flake.lock

Lines changed: 210 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: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
description = "Cryptle";
3+
4+
inputs.enarx.url = github:enarx/enarx/v0.6.1;
5+
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
6+
inputs.fenix.url = github:nix-community/fenix;
7+
inputs.flake-utils.url = github:numtide/flake-utils;
8+
inputs.naersk.inputs.nixpkgs.follows = "nixpkgs";
9+
inputs.naersk.url = github:nix-community/naersk;
10+
inputs.nixpkgs.url = github:profianinc/nixpkgs;
11+
12+
outputs = {
13+
self,
14+
enarx,
15+
fenix,
16+
flake-utils,
17+
naersk,
18+
nixpkgs,
19+
}: let
20+
cargo.toml = builtins.fromTOML (builtins.readFile "${self}/Cargo.toml");
21+
22+
overlay = final: prev: let
23+
rust = with fenix.packages.${final.system};
24+
combine [
25+
stable.rustc
26+
stable.cargo
27+
targets.wasm32-wasi.stable.rust-std
28+
];
29+
30+
naersk-lib = naersk.lib.${final.system}.override {
31+
cargo = rust;
32+
rustc = rust;
33+
};
34+
in {
35+
cryptle-wasm = naersk-lib.buildPackage {
36+
src = self;
37+
CARGO_BUILD_TARGET = "wasm32-wasi";
38+
};
39+
40+
cryptle-enarx = final.stdenv.mkDerivation {
41+
inherit (cargo.toml.package) version;
42+
pname = cargo.toml.package.name;
43+
44+
dontUnpack = true;
45+
installPhase = ''
46+
mkdir -p $out
47+
cp ${final.cryptle-wasm}/bin/cryptle.wasm $out/main.wasm
48+
cp ${self}/Enarx.toml $out/Enarx.toml
49+
'';
50+
};
51+
};
52+
in
53+
with flake-utils.lib.system;
54+
flake-utils.lib.eachSystem [
55+
aarch64-darwin
56+
aarch64-linux
57+
x86_64-darwin
58+
x86_64-linux
59+
] (system: let
60+
pkgs = import nixpkgs {
61+
inherit system;
62+
overlays = [overlay];
63+
};
64+
in {
65+
formatter = pkgs.alejandra;
66+
67+
packages.cryptle-wasm = pkgs.cryptle-wasm;
68+
packages.cryptle-enarx = pkgs.cryptle-enarx;
69+
70+
devShells.default = pkgs.mkShell {
71+
buildInputs = [
72+
enarx.packages.${system}.enarx-static
73+
];
74+
};
75+
});
76+
}

0 commit comments

Comments
 (0)