Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Mar 5, 2024
1 parent ee4a884 commit e740150
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 35 deletions.
32 changes: 9 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
filterDnas = filterByHolochainPackageType "dna";
filterHapps = filterByHolochainPackageType "happ";

rustZome = { crateCargoTomlPath, holochain, workspacePath, excludedCrates ? [] }:
rustZome = { crateCargoToml, holochain, workspacePath, excludedCrates ? [] }:
let
system = holochain.devShells.holonix.system;
pkgs = import inputs.nixpkgs {
Expand All @@ -50,9 +50,9 @@

in
pkgs.callPackage ./nix/zome.nix {
inherit craneLib crateCargoTomlPath excludedCrates workspacePath;
};
sweettest = { holochain, dna, workspacePath, crateCargoTomlPath }:
inherit craneLib crateCargoToml excludedCrates workspacePath;
};
sweettest = { holochain, dna, workspacePath, crateCargoToml }:
let
system = holochain.devShells.holonix.system;
pkgs = import inputs.nixpkgs {
Expand All @@ -66,43 +66,29 @@
};
craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain;
in pkgs.callPackage ./nix/sweettest.nix {
inherit holochain dna craneLib workspacePath crateCargoTomlPath;
inherit holochain dna craneLib workspacePath crateCargoToml;
};
dna = { holochain, dnaManifestPath ? null, dnaManifest ? null, zomes }:
dna = { holochain, dnaManifest, zomes }:
let
system = holochain.devShells.holonix.system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
};
finalDnaManifest = if dnaManifestPath == null
then (if dnaManifest == null
then builtins.throw "Either the dnaManifest or the dnaManifestPath need to be set"
else pkgs.writeText "dna.yaml" dnaManifest
)
else dnaManifestPath;
in
pkgs.callPackage ./nix/dna.nix {
inherit zomes holochain;
dnaManifest = finalDnaManifest;
inherit zomes holochain dnaManifest;
};
happ = { holochain, happManifest ? null, happManifestPath ? null, dnas }:
happ = { holochain, happManifest, dnas }:
let
system = holochain.devShells.holonix.system;
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
};
finalHappManifest = if happManifestPath == null
then (if happManifest == null
then builtins.throw "Either the happManifest or the happManifestPath need to be set"
else pkgs.writeText "happ.yaml" happManifest
)
else happManifestPath;
in
pkgs.callPackage ./nix/happ.nix {
inherit dnas holochain;
happManifest = finalHappManifest;
inherit dnas holochain happManifest;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion nix/fixture/dna.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
in
{
my_dna = inputs.hcUtils.outputs.lib.dna {
dnaManifestPath = ./dna.yaml;
dnaManifest = ./dna.yaml;
inherit zomes;
holochain = inputs'.holochain;
};
Expand Down
2 changes: 1 addition & 1 deletion nix/fixture/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/fixture/happ.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
}: {
packages =
let
happManifestPath = ./happ.yaml;
happManifest = ./happ.yaml;
allDnas = inputs.hcUtils.lib.filterDnas self'.packages;
dnas = {
} // allDnas;
in
{
my_happ = inputs.hcUtils.outputs.lib.happ {
holochain = inputs'.holochain;
inherit dnas happManifestPath;
inherit dnas happManifest;
};
};
};
Expand Down
5 changes: 2 additions & 3 deletions nix/fixture/zome/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
packages.my_zome = inputs.hcUtils.outputs.lib.rustZome {
workspacePath = rootPath;
holochain = inputs'.holochain;
crateCargoTomlPath = ./Cargo.toml;
crateCargoToml = ./Cargo.toml;
};
checks.my_zome = inputs.hcUtils.outputs.lib.sweettest {
workspacePath = rootPath;
Expand All @@ -35,9 +35,8 @@
my_zome = self'.packages.my_zome;
};
holochain = inputs'.holochain;

};
crateCargoTomlPath = ./Cargo.toml;
crateCargoToml = ./Cargo.toml;
};
};
}
Expand Down
4 changes: 2 additions & 2 deletions nix/sweettest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
pkgs,
lib,
craneLib,
crateCargoTomlPath,
crateCargoToml,
...
}:
let
cargoToml = builtins.fromTOML (builtins.readFile crateCargoTomlPath);
cargoToml = builtins.fromTOML (builtins.readFile crateCargoToml);
crate = cargoToml.package.name;

buildInputs = (with pkgs; [ openssl holochain.packages.opensslStatic sqlcipher ])
Expand Down
6 changes: 3 additions & 3 deletions nix/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
binaryen,
craneLib,
workspacePath,
crateCargoTomlPath,
crateCargoToml,
excludedCrates
}:

let
cargoExtraArgs = "--workspace ${if excludedCrates != null then builtins.concatStringsSep " " (builtins.map (excludedCrate: ''--exclude ${excludedCrate}'') excludedCrates) else ''''}";

cargoToml = builtins.fromTOML (builtins.readFile crateCargoTomlPath);
cargoToml = builtins.fromTOML (builtins.readFile crateCargoToml);
crate = cargoToml.package.name;

commonArgs = {
Expand All @@ -27,7 +27,7 @@ let
version = "workspace";
});
wasm = craneLib.buildPackage (commonArgs // {
cargoToml = crateCargoTomlPath;
cargoToml = crateCargoToml;
cargoLock = workspacePath + /Cargo.lock;
cargoArtifacts = wasmDeps;
cargoExtraArgs = "-p ${crate} --locked";
Expand Down

0 comments on commit e740150

Please sign in to comment.