Skip to content

Commit

Permalink
other flake copied across
Browse files Browse the repository at this point in the history
  • Loading branch information
jost-s committed May 31, 2024
1 parent b45957f commit 6e08862
Showing 1 changed file with 54 additions and 116 deletions.
170 changes: 54 additions & 116 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,112 +50,40 @@
# for each system...
perSystem = { config, pkgs, system, ... }:
let
# include Rust overlay in nixpkgs
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
rustedNixpkgs = import inputs.nixpkgs {
inherit system;
overlays = [ (import inputs.rust-overlay) ];
};
rustToolchain = rustedNixpkgs.rust-bin.stable."1.78.0".minimal;

# define Rust toolchain version and targets to be used in this flake
rust = (pkgs.rust-bin.stable."1.78.0".minimal.override
{
targets = [ "wasm32-unknown-unknown" ];
});
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;

# instruct crane to use Rust toolchain specified above
craneLib = (crane.mkLib pkgs).overrideToolchain rust;

# define how to build Holochain binaries
holochain =
let
# Crane filters out all non-cargo related files. Define include filter with files needed for build.
nonCargoBuildFiles = path: _type: builtins.match ".*(json|sql|wasm.gz)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);
in
craneLib.buildPackage {
pname = "holochain";
version = "workspace";
# 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;
filter = includeFilesFilter;
};
# additional packages needed for build
buildInputs = [
pkgs.go
pkgs.perl
];
# do not check built package as it either builds successfully or not
doCheck = false;
};
apple_sdk =
if system == "x86_64-darwin"
then pkgs.darwin.apple_sdk_10_12
else pkgs.darwin.apple_sdk_11_0;

# define how to build Lair keystore binary
lair-keystore =
let
# Crane filters out all non-cargo related files. Define include filter with files needed for build.
nonCargoBuildFiles = path: _type: builtins.match ".*(sql|md)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);
in
craneLib.buildPackage {
pname = "lair-keystore";
version = "workspace";
# 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;
filter = includeFilesFilter;
};
# additional packages needed for build
# perl needed for openssl on all platforms
buildInputs = [ pkgs.perl ]
++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
# additional packages needed for darwin platforms
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
# additional packages needed for darwin platforms on x86_64
pkgs.darwin.apple_sdk_11_0.frameworks.CoreFoundation
]);
# do not check built package as it either builds successfully or not
doCheck = false;
};
commonArgs = {

# define how to build Holochain Launcher binary
launcher =
let
# Crane filters out all non-cargo related files. Define include filter with files needed for build.
nonCargoBuildFiles = path: _type: builtins.match ".*(js|json|png)$" path != null;
includeFilesFilter = path: type:
(craneLib.filterCargoSources path type) || (nonCargoBuildFiles path type);
apple_sdk =
if system == "x86_64-darwin"
then pkgs.darwin.apple_sdk_10_12
else pkgs.darwin.apple_sdk_11_0;
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rust;
in
craneLib.buildPackage {
pname = "hc-launch";
version = "workspace";
stdenv =
if pkgs.stdenv.isDarwin then
pkgs.overrideSDK pkgs.stdenv "11.0"
else
pkgs.stdenv;
pname = "hc-launch";
src = inputs.launcher-src;

cargoExtraArgs = "--bin hc-launch";

buildInputs = [
pkgs.perl
]
++ (pkgs.lib.optionals pkgs.stdenv.isLinux
[
pkgs.glib
pkgs.go
pkgs.webkitgtk.dev
])
++ pkgs.lib.optionals pkgs.stdenv.isDarwin
[
apple_sdk.frameworks.AppKit
apple_sdk.frameworks.WebKit

# only build hc-launch binary
cargoExtraArgs = "--bin hc-launch";
# Use Launcher sources as defined in input dependencies and include only those files defined in the
# filter previously.
src = pkgs.lib.cleanSourceWith {
src = launcher-src;
# filter = includeFilesFilter;
};
nativeBuildInputs = [
pkgs.pkg-config
(if pkgs.system == "x86_64-darwin" then
pkgs.darwin.apple_sdk_11_0.stdenv.mkDerivation
{
Expand All @@ -170,25 +98,35 @@
makeWrapper ${pkgs.go}/bin/go $out/bin/go
'';
} else pkgs.go)
];
# additional packages needed for build
# perl needed for openssl on all platforms
buildInputs = [
pkgs.glib
pkgs.perl
]
++ (pkgs.lib.optionals pkgs.stdenv.isLinux [
;

nativeBuildInputs = [ ]
++ (pkgs.lib.optionals pkgs.stdenv.isLinux
[
pkgs.pkg-config
pkgs.webkitgtk.dev
])
++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
# additional packages needed for darwin platforms
apple_sdk.frameworks.AppKit
apple_sdk.frameworks.WebKit
]);
# do not check built package as it either builds successfully or not
doCheck = false;
};
;

doCheck = false;
};

# derivation building all dependencies
deps = craneLib.buildDepsOnly
(commonArgs // { });

# derivation with the main crates
launcher = craneLib.buildPackage
(commonArgs // {
cargoArtifacts = deps;

stdenv =
if pkgs.stdenv.isDarwin then
pkgs.overrideSDK pkgs.stdenv "11.0"
else
pkgs.stdenv;
});

in
{
packages = {
Expand Down

0 comments on commit 6e08862

Please sign in to comment.