Skip to content

Commit

Permalink
Add versions and apps
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Jun 4, 2024
1 parent 2409319 commit 21f3142
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: Build nix package
run: nix build -L .#${{ matrix.package }}

- name: Run nix app
run: nix run .#${{ matrix.package }} --version

- run: result/bin/${{ matrix.package }} --version

# - name: Setup tmate session
Expand Down
68 changes: 0 additions & 68 deletions build-and-cache.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions flake.lock

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

42 changes: 30 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@
};

# Holochain sources
holochain-src = {
holochain = {
url = "github:holochain/holochain/main";
flake = false;
};

# Lair keystore sources
lair-keystore-src = {
lair-keystore = {
url = "github:holochain/lair/lair_keystore-v0.4.4";
flake = false;
};

# Holochain Launch CLI
hc-launch-src = {
hc-launch = {
url = "github:holochain/launcher/holochain-weekly";
flake = false;
};
};

# outputs that this flake should produce
outputs = inputs @ { self, nixpkgs, flake-parts, rust-overlay, crane, holochain-src, lair-keystore-src, hc-launch-src, ... }:
outputs = inputs @ { self, nixpkgs, flake-parts, rust-overlay, crane, ... }:
# refer to flake-parts docs https://flake.parts/
flake-parts.lib.mkFlake { inherit inputs; } {
# systems that his flake can be used on
Expand All @@ -56,8 +56,10 @@
inherit system overlays;
};

rustVersion = "1.78.0";

# define Rust toolchain version and targets to be used in this flake
rust = (pkgs.rust-bin.stable."1.78.0".minimal.override
rust = (pkgs.rust-bin.stable.${rustVersion}.minimal.override
{
targets = [ "wasm32-unknown-unknown" ];
});
Expand All @@ -72,14 +74,17 @@
nonCargoBuildFiles = path: _type: builtins.match ".*(json|sql|wasm.gz)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);

# Crane doesn't know which version to select from a workspace, so we tell it where to look
crateInfo = craneLib.crateNameFromCargoToml { cargoToml = inputs.holochain + "/crates/holochain/Cargo.toml"; };
in
craneLib.buildPackage {
pname = "holochain";
version = "workspace";
version = crateInfo.version;
# Use Holochain sources as defined in input dependencies and include only those files defined in the
# filter previously.
src = pkgs.lib.cleanSourceWith {
src = holochain-src;
src = inputs.holochain;
filter = includeFilesFilter;
};
# additional packages needed for build
Expand All @@ -98,16 +103,19 @@
nonCargoBuildFiles = path: _type: builtins.match ".*(sql|md)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);

# Crane doesn't know which version to select from a workspace, so we tell it where to look
crateInfo = craneLib.crateNameFromCargoToml { cargoToml = inputs.lair-keystore + "/crates/lair_keystore/Cargo.toml"; };
in
craneLib.buildPackage {
pname = "lair-keystore";
version = "workspace";
version = crateInfo.version;
# only build lair-keystore binary
cargoExtraArgs = "--bin lair-keystore";
# Use Lair keystore sources as defined in input dependencies and include only those files defined in the
# filter previously.
src = pkgs.lib.cleanSourceWith {
src = lair-keystore-src;
src = inputs.lair-keystore;
filter = includeFilesFilter;
};
# additional packages needed for build
Expand All @@ -131,6 +139,10 @@
nonCargoBuildFiles = path: _type: builtins.match ".*(js|json|png)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);

# Crane doesn't know which version to select from a workspace, so we tell it where to look
crateInfo = craneLib.crateNameFromCargoToml { cargoToml = inputs.hc-launch + "/crates/hc_launch/src-tauri/Cargo.toml"; };

# Use consistent version of Apple SDK throughout. Without this, building on x86_64-darwin fails.
# See below.
apple_sdk =
Expand All @@ -140,11 +152,11 @@

commonArgs = {
pname = "hc-launch";
version = "workspace";
version = crateInfo.version;
# Use hc-launch sources as defined in input dependencies and include only those files defined in the
# filter previously.
src = pkgs.lib.cleanSourceWith {
src = hc-launch-src;
src = inputs.hc-launch;
filter = includeFilesFilter;
};
# Only build hc-launch command
Expand Down Expand Up @@ -194,7 +206,6 @@

# derivation building all dependencies
deps = craneLib.buildDepsOnly commonArgs;

in
# derivation with the main crates
craneLib.buildPackage
Expand All @@ -212,6 +223,7 @@
});
in
{
formatter = pkgs.nixpkgs-fmt;

packages = {
inherit holochain;
Expand All @@ -220,6 +232,12 @@
inherit hc-launch;
};

apps = {
holochain = "${holochain}/bin/holochain";
lair-keystore = "${lair-keystore}/bin/lair-keystore";
hc-launch.program = "${hc-launch}/bin/hc-launch";
};

devShells = {
default = pkgs.mkShell {
packages = [
Expand Down

0 comments on commit 21f3142

Please sign in to comment.