Skip to content

Commit

Permalink
Nix refactor WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed May 16, 2024
1 parent 6ba6235 commit 605cfcb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 64 deletions.
37 changes: 37 additions & 0 deletions crates/scaffold_holochain_runtime/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ inputs, self, ... }:

{
perSystem = { inputs', pkgs, system, lib, ... }: rec {

packages.scaffold-holochain-runtime = let
craneLib = inputs.crane.lib.${system};

cratePath = ./.;

cargoToml =
builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml");
crate = cargoToml.package.name;

commonArgs = {
src = craneLib.path ../../.;
doCheck = false;
buildInputs = inputs.hc-infra.outputs.lib.holochainAppDeps.buildInputs {
inherit pkgs lib;
} ++ self.lib.tauriAppDeps.buildInputs { inherit pkgs lib; };
nativeBuildInputs =
(self.lib.tauriAppDeps.nativeBuildInputs { inherit pkgs lib; })
++ (inputs.hc-infra.outputs.lib.holochainAppDeps.nativeBuildInputs {
inherit pkgs lib;
});
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
version = "workspace";
pname = "workspace";
});
in craneLib.buildPackage (commonArgs // {
pname = crate;
version = cargoToml.package.version;
inherit cargoArtifacts;
});
};
}
57 changes: 57 additions & 0 deletions crates/scaffold_tauri_app/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ inputs, self, ... }:

{
perSystem = { inputs', pkgs, system, lib, ... }: rec {
packages.scaffold-tauri-app = let
craneLib = inputs.crane.lib.${system};

cratePath = ./.;

cargoToml =
builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml");
crate = cargoToml.package.name;

commonArgs = {
src = craneLib.path ../../.;
doCheck = false;
buildInputs = inputs.hc-infra.outputs.lib.holochainAppDeps.buildInputs {
inherit pkgs lib;
} ++ self.lib.tauriAppDeps.buildInputs { inherit pkgs lib; };
nativeBuildInputs =
(self.lib.tauriAppDeps.nativeBuildInputs { inherit pkgs lib; })
++ (inputs.hc-infra.outputs.lib.holochainAppDeps.nativeBuildInputs {
inherit pkgs lib;
});
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
version = "workspace";
pname = "workspace";
});
in craneLib.buildPackage (commonArgs // {
pname = crate;
version = cargoToml.package.version;
inherit cargoArtifacts;
});

checks.scaffold-tauri-app = pkgs.runCommandLocal "test-scaffold-tauri-app" {
buildInputs =
[ inputs'.holochain.outputs.hc-scaffold packages.scaffold-tauri-app ];
} ''
hc scaffold --template lit web-app forum
cd forum
nix flake update
nix develop
npm i
scaffold-tauri-app forum
nix flake update
nix develop
npm i
npm run build:happ
npm run tauri build
'';
};
}
66 changes: 2 additions & 64 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
};
};

imports = [ ./crates/scaffold_tauri_app/default.nix ];

systems = builtins.attrNames inputs.holochain.devShells;
perSystem = { inputs', config, pkgs, system, lib, ... }: rec {
devShells.tauriDev = pkgs.mkShell {
Expand Down Expand Up @@ -217,70 +219,6 @@
devShells.holochainTauriAndroidDev
];
};

packages.scaffold-tauri-app = let
craneLib = inputs.crane.lib.${system};

cratePath = ./crates/scaffold_tauri_app;

cargoToml =
builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml");
crate = cargoToml.package.name;

commonArgs = {
src = craneLib.path ./.;
doCheck = false;
buildInputs =
inputs.hc-infra.outputs.lib.holochainAppDeps.buildInputs {
inherit pkgs lib;
} ++ flake.lib.tauriAppDeps.buildInputs { inherit pkgs lib; };
nativeBuildInputs =
(flake.lib.tauriAppDeps.nativeBuildInputs { inherit pkgs lib; })
++ (inputs.hc-infra.outputs.lib.holochainAppDeps.nativeBuildInputs {
inherit pkgs lib;
});
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
version = "workspace";
pname = "workspace";
});
in craneLib.buildPackage (commonArgs // {
pname = crate;
version = cargoToml.package.version;
inherit cargoArtifacts;
});

packages.scaffold-holochain-runtime = let
craneLib = inputs.crane.lib.${system};

cratePath = ./crates/scaffold_holochain_runtime;

cargoToml =
builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml");
crate = cargoToml.package.name;

commonArgs = {
src = craneLib.path ./.;
doCheck = false;
buildInputs =
inputs.hc-infra.outputs.lib.holochainAppDeps.buildInputs {
inherit pkgs lib;
} ++ flake.lib.tauriAppDeps.buildInputs { inherit pkgs lib; };
nativeBuildInputs =
(flake.lib.tauriAppDeps.nativeBuildInputs { inherit pkgs lib; })
++ (inputs.hc-infra.outputs.lib.holochainAppDeps.nativeBuildInputs {
inherit pkgs lib;
});
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
version = "workspace";
pname = "workspace";
});
in craneLib.buildPackage (commonArgs // {
pname = crate;
version = cargoToml.package.version;
inherit cargoArtifacts;
});
};
};
}
Expand Down

0 comments on commit 605cfcb

Please sign in to comment.