From 605cfcbe09552616a383cb49558700979faf87e2 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Thu, 16 May 2024 15:58:04 +0200 Subject: [PATCH] Nix refactor WIP --- crates/scaffold_holochain_runtime/default.nix | 37 +++++++++++ crates/scaffold_tauri_app/default.nix | 57 ++++++++++++++++ flake.nix | 66 +------------------ 3 files changed, 96 insertions(+), 64 deletions(-) create mode 100644 crates/scaffold_holochain_runtime/default.nix create mode 100644 crates/scaffold_tauri_app/default.nix diff --git a/crates/scaffold_holochain_runtime/default.nix b/crates/scaffold_holochain_runtime/default.nix new file mode 100644 index 00000000..7653a1a9 --- /dev/null +++ b/crates/scaffold_holochain_runtime/default.nix @@ -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; + }); + }; +} diff --git a/crates/scaffold_tauri_app/default.nix b/crates/scaffold_tauri_app/default.nix new file mode 100644 index 00000000..5ee38646 --- /dev/null +++ b/crates/scaffold_tauri_app/default.nix @@ -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 + ''; + }; +} diff --git a/flake.nix b/flake.nix index 02ba2bd8..fc0f1438 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { @@ -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; - }); }; }; }