-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
138 lines (126 loc) · 5.56 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
description = "Utility for producing Holochain binaries";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
holochain = {
url = "github:holochain/holochain/bump-influxive";
flake = false;
};
lair-keystore = {
url = "github:holochain/lair";
flake = false;
};
holonix = {
url = "github:holochain/holonix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.crane.follows = "crane";
inputs.rust-overlay.follows = "rust-overlay";
inputs.holochain.follows = "holochain";
inputs.lair-keystore.follows = "lair-keystore";
};
};
outputs = inputs @ { nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem
(localSystem: {
packages =
let
pkgs = nixpkgs.legacyPackages.${localSystem};
defineHolochainPackages = { crate, package }: {
"${package}_aarch64-linux" = import ./modules/holochain-cross.nix {
inherit localSystem inputs crate package;
crossSystem = "aarch64-linux";
rustTargetTriple = "aarch64-unknown-linux-gnu";
};
"${package}_x86_64-linux" = import ./modules/holochain-cross.nix {
inherit localSystem inputs crate package;
crossSystem = "x86_64-linux";
rustTargetTriple = "x86_64-unknown-linux-gnu";
};
"${package}_x86_64-windows" = import ./modules/holochain-windows.nix {
inherit localSystem inputs crate package;
};
} // (if localSystem == "aarch64-darwin" then {
# Only define darwin builds if we're on a darwin host because Apple don't like people cross compiling
# from other systems.
"${package}_aarch64-apple" = import ./modules/holochain-cross.nix {
inherit localSystem inputs crate package;
crossSystem = "aarch64-darwin";
rustTargetTriple = "aarch64-apple-darwin";
};
} else if localSystem == "x86_64-darwin" then {
"${package}_x86_64-apple" = import ./modules/holochain-cross.nix {
inherit localSystem inputs crate package;
crossSystem = "x86_64-darwin";
rustTargetTriple = "x86_64-apple-darwin";
};
} else { });
defineLairKeystorePackages = {}: {
lair_keystore_aarch64-linux = import ./modules/lair-keystore-cross.nix {
inherit localSystem inputs;
crossSystem = "aarch64-linux";
rustTargetTriple = "aarch64-unknown-linux-gnu";
};
lair_keystore_x86_64-linux = import ./modules/lair-keystore-cross.nix {
inherit localSystem inputs;
crossSystem = "x86_64-linux";
rustTargetTriple = "x86_64-unknown-linux-gnu";
};
lair_keystore_x86_64-windows = import ./modules/lair-keystore-windows.nix {
inherit localSystem inputs;
};
} // (if localSystem == "aarch64-darwin" then {
# Only define darwin builds if we're on a darwin host because Apple don't like people cross compiling
# from other systems.
lair_keystore_aarch64-apple = import ./modules/lair-keystore-cross.nix {
inherit localSystem inputs;
crossSystem = "aarch64-darwin";
rustTargetTriple = "aarch64-apple-darwin";
};
lair_keystore_x86_64-apple = import ./modules/lair-keystore-cross.nix {
inherit localSystem inputs;
crossSystem = "x86_64-darwin";
rustTargetTriple = "x86_64-apple-darwin";
};
} else { });
extractHolochainBin = bin: pkgs.stdenv.mkDerivation {
name = bin;
unpackPhase = "true";
installPhase = ''
mkdir -p $out/bin
cp ${inputs.holonix.packages.${localSystem}.holochain}/bin/${bin} $out/bin
'';
};
in
(defineHolochainPackages { crate = "holochain"; package = "holochain"; }) //
(defineHolochainPackages { crate = "hc"; package = "holochain_cli"; }) //
(defineHolochainPackages { crate = "hc_run_local_services"; package = "holochain_cli_run_local_services"; }) //
(defineHolochainPackages { crate = "holochain_terminal"; package = "hcterm"; }) //
(defineLairKeystorePackages { }) // (if localSystem == "x86_64-linux" then {
holonix_holochain = extractHolochainBin "holochain";
holonix_hc = extractHolochainBin "hc";
holonix_hc_run_local_services = extractHolochainBin "hc-run-local-services";
holonix_hcterm = extractHolochainBin "hcterm";
holonix_lair_keystore = inputs.holonix.packages.${localSystem}.lair-keystore;
} else { })
;
}) // {
# Add dev helpers that are not required to be platform agnostic
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
};
}