Skip to content

Commit 706328c

Browse files
authored
Merge branch 'main' into szg251/catalyst-reports
2 parents eebc65c + 063055a commit 706328c

File tree

47 files changed

+4211
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4211
-412
lines changed

docs/typescript-plutus/api/lbf/build.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ _:
22
{
33
perSystem = { config, ... }:
44
let
5-
tsFlake =
5+
lbf-plutus-sample-project-typescript =
66
config.lbf-nix.lbfPlutusTypescript {
77
name = "lbf-plutus-sample-project";
88
src = ./.;
@@ -11,7 +11,7 @@ _:
1111
in
1212
{
1313
packages = {
14-
inherit (tsFlake.packages) lbf-plutus-sample-project-typescript lbf-plutus-sample-project-typescript-tgz;
14+
inherit lbf-plutus-sample-project-typescript;
1515
};
1616
};
1717
}

docs/typescript-plutus/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
src = ./.;
1111

1212
npmExtraDependencies = [
13-
config.packages.lbf-plutus-sample-project-typescript-tgz
13+
config.packages.lbf-plutus-sample-project-typescript
1414
];
1515

1616
devShellTools = config.settings.shell.tools;

docs/typescript-prelude/api/lbf/build.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ _:
22
{
33
perSystem = { config, ... }:
44
let
5-
tsFlake =
5+
lbf-prelude-sample-project-typescript =
66
config.lbf-nix.lbfPreludeTypescript {
77
name = "lbf-prelude-sample-project";
88
src = ./.;
@@ -11,7 +11,7 @@ _:
1111
in
1212
{
1313
packages = {
14-
inherit (tsFlake.packages) lbf-prelude-sample-project-typescript lbf-prelude-sample-project-typescript-tgz;
14+
inherit lbf-prelude-sample-project-typescript;
1515
};
1616
};
1717
}

docs/typescript-prelude/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name = "prelude-sample-project";
1010
src = ./.;
1111
npmExtraDependencies = [
12-
config.packages.lbf-prelude-sample-project-typescript-tgz
12+
config.packages.lbf-prelude-sample-project-typescript
1313
];
1414

1515
devShellTools = config.settings.shell.tools;

extras/build.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# Makes a per system `lbf-nix` option.
2525
perSystem = flake-parts-lib.mkPerSystemOption
26-
({ pkgs, config, pkgsForCtl, pkgsForHaskellNix, pkgsForRust, ... }: {
26+
({ pkgs, config, pkgsForCtl, pkgsForHaskellNix, ... }: {
2727

2828
options.lbf-nix = lib.mkOption {
2929
type = lib.types.anything;
@@ -43,7 +43,6 @@
4343

4444
purescriptFlake = import ./flake-purescript.nix pkgsForCtl;
4545

46-
rustFlake = import ./flake-rust.nix pkgsForRust;
4746
haskellData = import ./haskell-data.nix pkgs;
4847
haskellFlake = import ./flake-haskell.nix pkgsForHaskellNix;
4948
haskellPlutusFlake = import ./flake-haskell-plutus.nix inputs.cardano-haskell-packages pkgsForHaskellNix;

extras/flake-rust.nix

Lines changed: 0 additions & 109 deletions
This file was deleted.

extras/lbf-nix/lbf-rust.nix

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ let
3030
, # Version of the package and also the version of the Cargo crate.
3131
# Examples: version = "0.1.0.0"
3232
version ? "0.1.0"
33-
}: { inherit src imports files classes dependencies configs name version; };
33+
, # Version of dependencies
34+
# A package will only be added to Cargo.toml, if the generated code directly depends on it
35+
# Defaults to version 0.1.0 for all packages
36+
extraVersions ? { }
37+
}: { inherit src imports files classes dependencies configs name version extraVersions; };
3438

3539
lbf-build = import ./lbf-build.nix pkgs lbf;
3640

@@ -66,29 +70,27 @@ let
6670
};
6771

6872
cargoTemplate = opts: with (lbfRustOpts opts);
69-
pkgs.writeTextFile {
70-
name = "lambda-buffers-cargo-template";
71-
text = ''
72-
[package]
73-
name = "${name}"
74-
version = "${version}"
75-
edition = "2021"
76-
77-
[dependencies]
78-
'';
79-
};
73+
pkgs.writers.writeJSON "lambda-buffers-cargo-template"
74+
{
75+
package = {
76+
inherit name version;
77+
edition = "2021";
78+
};
79+
};
8080

8181
# This is a lookup table of default crate versions used by lamba-buffers modules
8282
# Based on the contents of `build.json` a subset of these will be attached to the
8383
# Cargo.toml file
84-
crateVersions = pkgs.writeTextFile {
85-
name = "lambda-buffers-crate-versions";
86-
text = ''
87-
num-bigint = "0.4.4"
88-
serde_json = { version = "1.0.107", features = ["arbitrary_precision"] }
89-
plutus-ledger-api = { git = "https://github.com/mlabs-haskell/plutus-ledger-api-rust", features = [ "lbf", ], rev = "d66d39c949f59e543c91ee36377c93422d8e9d75" }
90-
'';
91-
};
84+
# Note: lbr-prelude and and plutus prelude versions are pinned here, but can be overridden with `extraVersions`
85+
versionTable =
86+
{
87+
num-bigint = "~0.4";
88+
serde_json = { version = "^1.0"; features = [ "arbitrary_precision" ]; };
89+
plutus-ledger-api = { git = "https://github.com/mlabs-haskell/plutus-ledger-api-rust"; features = [ "lbf" ]; rev = "d66d39c949f59e543c91ee36377c93422d8e9d75"; };
90+
};
91+
92+
crateVersions = opts: with (lbfRustOpts opts);
93+
pkgs.writers.writeJSON "lambda-buffers-crate-versions" (versionTable // extraVersions);
9294

9395
build = opts: with (lbfRustOpts opts);
9496
let
@@ -100,6 +102,7 @@ let
100102
outputs = [ "out" "buildjson" ];
101103
buildInputs = [
102104
pkgs.jq
105+
pkgs.yj
103106
];
104107
buildPhase = ''
105108
ln -s ${lbfBuilt} autogen;
@@ -109,22 +112,27 @@ let
109112
# Generating Cargo manifest file
110113
DEPS=$(echo ${builtins.concatStringsSep " " dependencies} $(cat build.json | jq -r ".[]" | sort -u));
111114
echo "Gathered Cargo deps $DEPS";
112-
cat ${cargoTemplate opts} > Cargo.toml;
115+
cat ${cargoTemplate opts} > Cargo.json;
113116
# Using the lookup table `crateVersions`, filling in the library version.
114117
# If no version is found, we default to a local path dependency, pointing to
115118
# a sibling directory (directory in extra-sources or .extras)
116119
# e.g.: for `lbr-prelude` we print `lbr-prelude = { path = "../lbr-prelude" }
117120
for DEP in $DEPS; do
118121
if [ $DEP != "std" ]; then
119-
echo "$(cat ${crateVersions} | grep "$DEP" || echo "$DEP = { path = \"../$DEP\" }")" >> Cargo.toml
122+
VER=$(cat ${crateVersions opts} | jq ".\"$DEP\"" -c);
123+
if [ $VER == "null" ]; then
124+
VER="{\"path\": \"../$DEP-0.1.0\"}"
125+
fi
126+
cat Cargo.json | jq ".dependencies+={\"$DEP\":$VER}" > tmp.json;
127+
mv tmp.json Cargo.json
120128
fi
121129
done
130+
cat Cargo.json | yj -jt > Cargo.toml;
122131
'';
123132

124133
installPhase = ''
125134
cp build.json $buildjson;
126135
echo "Dependencies collected"
127-
cat $buildjson;
128136
129137
mkdir -p $out/src;
130138
cp -r autogen/* $out/src

extras/lbf-nix/lbf-typescript.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ let
276276
});
277277
});
278278
in
279-
lbTypescriptFlake
279+
lbTypescriptFlake.packages."${name}-typescript-tgz"

0 commit comments

Comments
 (0)