Skip to content

Commit

Permalink
Refactor happ and dna pack so that it can be unpacked
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Jul 2, 2024
1 parent 4582b56 commit 0448f09
Show file tree
Hide file tree
Showing 12 changed files with 1,473 additions and 971 deletions.
2 changes: 1 addition & 1 deletion crates/nix_scaffolding_utils/fixture/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inputs = {
nixpkgs.follows = "holochain/nixpkgs";

versions.url = "github:holochain/holochain?dir=versions/weekly";
versions.url = "github:holochain/holochain?dir=versions/0_3";

holochain = {
url = "github:holochain/holochain";
Expand Down
2 changes: 1 addition & 1 deletion crates/scaffold_remote_zome/fixture/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inputs = {
nixpkgs.follows = "holochain/nixpkgs";

versions.url = "github:holochain/holochain?dir=versions/weekly";
versions.url = "github:holochain/holochain?dir=versions/0_3";

holochain = {
url = "github:holochain/holochain";
Expand Down
7 changes: 3 additions & 4 deletions crates/sync_npm_git_dependencies_with_nix/fixture/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
inputs = {
nixpkgs.follows = "holochain/nixpkgs";

versions.url = "github:holochain/holochain?dir=versions/weekly";
versions.url = "github:holochain/holochain?dir=versions/0_3";

holochain = {
url = "github:holochain/holochain";
inputs.versions.follows = "versions";
};
hcUtils.url = "path:../../..";
hc-infra.url = "path:../../..";
profiles.url = "github:holochain-open-dev/profiles/nixify";
file-storage.url =
"github:holochain-open-dev/file-storage/for-hdk-0.3.0-beta-dev";
file-storage.url = "github:holochain-open-dev/file-storage/nixify";
};

outputs = inputs@{ ... }:
Expand Down
53 changes: 34 additions & 19 deletions nix/dna.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let

# Recurse over the zomes, and add the correct bundled zome package by name
manifest = (callPackage ./import-yaml.nix { }) dnaManifest;
zomeToBundled = zome: zome // { bundled = zomes.${zome.name}.meta.release; };
zomeToBundled = zome: zome // { bundled = "./${zome.name}.wasm"; };
coordinatorZomes = builtins.map zomeToBundled manifest.coordinator.zomes;
integrityZomes = builtins.map zomeToBundled manifest.integrity.zomes;

Expand All @@ -24,32 +24,47 @@ let
meta = { holochainPackageType = "dna"; };
} ''
mkdir workdir
cp ${dnaManifestYaml} workdir/dna.yaml
cp ${dnaManifestYaml} workdir/dna.yaml
${
builtins.toString (builtins.map (zome: ''
cp ${zomes.${zome.name}.meta.release} ./workdir/${zome.name}.wasm
'') manifest'.integrity.zomes)
}
${
builtins.toString (builtins.map (zome: ''
cp ${zomes.${zome.name}.meta.release} ./workdir/${zome.name}.wasm
'') manifest'.coordinator.zomes)
}
${holochain.packages.holochain}/bin/hc dna pack workdir
mv workdir/${manifest.name}.dna $out
'';

# Debug package
debug = let
manifest = (callPackage ./import-yaml.nix { }) dnaManifest;
zomeToBundled = zome: zome // { bundled = zomes.${zome.name}; };
coordinatorZomes = builtins.map zomeToBundled manifest.coordinator.zomes;
integrityZomes = builtins.map zomeToBundled manifest.integrity.zomes;

manifest' = manifest // {
coordinator.zomes = coordinatorZomes;
integrity = manifest.integrity // { zomes = integrityZomes; };
};

dnaManifestJson = writeText "dna.json" (builtins.toJSON manifest');
dnaManifestYaml = runCommandLocal "json-to-yaml" { }
" ${json2yaml}/bin/json2yaml ${dnaManifestJson} $out\n";
in runCommandLocal manifest.name {
debug = runCommandLocal manifest.name {
srcs = zomeSrcs;
meta = {
inherit release;
holochainPackageType = "dna";
};
}
" mkdir workdir\n cp ${dnaManifestYaml} workdir/dna.yaml\n ${holochain.packages.holochain}/bin/hc dna pack workdir\n mv workdir/${manifest.name}.dna $out\n";
} ''
mkdir workdir
cp ${dnaManifestYaml} workdir/dna.yaml
${
builtins.toString (builtins.map (zome: ''
cp ${zomes.${zome.name}} ./workdir/${zome.name}.wasm
'') manifest'.integrity.zomes)
}
${
builtins.toString (builtins.map (zome: ''
cp ${zomes.${zome.name}} ./workdir/${zome.name}.wasm
'') manifest'.coordinator.zomes)
}
${holochain.packages.holochain}/bin/hc dna pack workdir
mv workdir/${manifest.name}.dna $out
'';
in debug
Loading

0 comments on commit 0448f09

Please sign in to comment.