-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
205 lines (181 loc) · 7.89 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{
inputs = {
nixpkgs.follows = "holonix/nixpkgs";
pnpmnixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
holonix.url = "github:holochain/holonix/main-0.3";
rust-overlay.follows = "holonix/rust-overlay";
crane.follows = "holonix/crane";
};
nixConfig = {
extra-substituters = [ "https://holochain-open-dev.cachix.org" ];
extra-trusted-public-keys = [
"holochain-open-dev.cachix.org-1:3Tr+9in6uo44Ga7qiuRIfOTFXog+2+YbyhwI/Z6Cp4U="
];
};
outputs = inputs@{ ... }:
inputs.holonix.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
flake = {
flakeModules.builders = ./nix/builders-option.nix;
flakeModules.dependencies = ./nix/dependencies-option.nix;
};
imports = [
./crates/scaffold_remote_zome/default.nix
./crates/compare_dnas_integrity/default.nix
./crates/zome_wasm_hash/default.nix
./crates/sync_npm_git_dependencies_with_nix/default.nix
./nix/builders-option.nix
./nix/dependencies-option.nix
# inputs.holonix.inputs.flake-parts.flakeModules.flakeModules
];
systems = builtins.attrNames inputs.holonix.devShells;
perSystem = { inputs', self', config, pkgs, system, lib, ... }: rec {
dependencies.holochain.buildInputs = (with pkgs; [ perl openssl ])
++ (lib.optionals pkgs.stdenv.isLinux [ pkgs.pkg-config pkgs.go ])
++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.AppKit
pkgs.darwin.apple_sdk.frameworks.WebKit
(if pkgs.system == "x86_64-darwin" then
(pkgs.stdenv.mkDerivation {
name = "go";
nativeBuildInputs = with pkgs; [ makeBinaryWrapper go ];
dontBuild = true;
dontUnpack = true;
installPhase = ''
makeWrapper ${pkgs.go}/bin/go $out/bin/go
'';
})
else
pkgs.go)
]);
builders = {
rustZome = { crateCargoToml, workspacePath, cargoArtifacts ? null
, matchingZomeHash ? null, meta ? { }, zomeEnvironmentVars ? { } }:
let
deterministicCraneLib = let
rustToolchain =
inputs.holonix.outputs.packages."x86_64-linux".rust;
in (inputs.crane.mkLib inputs.nixpkgs.outputs.legacyPackages.${
"x86_64-linux"
}).overrideToolchain rustToolchain;
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain
inputs'.holonix.packages.rust;
zome-wasm-hash = self'.packages.zome-wasm-hash;
in pkgs.callPackage ./nix/zome.nix {
inherit deterministicCraneLib craneLib crateCargoToml
cargoArtifacts workspacePath matchingZomeHash zome-wasm-hash
meta zomeEnvironmentVars;
};
sweettest = { dna, workspacePath, crateCargoToml, buildInputs ? [ ]
, nativeBuildInputs ? [ ], cargoArtifacts ? null }:
let
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain
inputs'.holonix.packages.rust;
in pkgs.callPackage ./nix/sweettest.nix {
inherit dna craneLib crateCargoToml cargoArtifacts workspacePath;
buildInputs = buildInputs
++ self'.dependencies.holochain.buildInputs;
};
dna = { dnaManifest, zomes, matchingIntegrityDna ? null, meta ? { } }:
let
compare-dnas-integrity = self'.packages.compare-dnas-integrity;
holochain = inputs'.holonix.packages.holochain;
in pkgs.callPackage ./nix/dna.nix {
inherit zomes holochain dnaManifest compare-dnas-integrity
matchingIntegrityDna meta;
};
happ = { happManifest, dnas, meta ? { } }:
pkgs.callPackage ./nix/happ.nix {
inherit dnas happManifest meta;
holochain = inputs'.holonix.packages.holochain;
};
};
devShells.default = pkgs.mkShell {
inputsFrom = [ inputs'.holonix.devShells.default ];
packages = with pkgs;
[
nodejs_20
# more packages go here
] ++ self'.dependencies.holochain.buildInputs;
};
devShells.holochainDev = pkgs.mkShell {
buildInputs = self'.dependencies.holochain.buildInputs;
};
packages = {
zomeCargoArtifacts = let
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain
inputs'.holonix.packages.rust;
src =
craneLib.cleanCargoSource (craneLib.path ./nix/reference-happ);
commonArgs = {
inherit src;
doCheck = false;
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
pname = "zome";
version = "for-holochain-0.3.2";
});
in cargoArtifacts;
holochainCargoArtifacts = let
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain
inputs'.holonix.packages.rust;
cargoArtifacts = craneLib.buildDepsOnly {
buildInputs = self'.dependencies.holochain.buildInputs;
src =
craneLib.cleanCargoSource (craneLib.path ./nix/reference-happ);
doCheck = false;
# RUSTFLAGS =
# "--remap-path-prefix ${cargoVendorDir}=/build/source/";
# CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS =
# " -Clink-arg=-fuse-ld=mold";
# CARGO_PROFILE = "release";
CARGO_PROFILE = "release";
pname = "sweettest";
version = "for-holochain-0.3.2";
};
in cargoArtifacts;
};
packages.synchronized-pnpm = pkgs.symlinkJoin {
name = "synchronized-pnpm";
paths = [ inputs'.pnpmnixpkgs.legacyPackages.pnpm ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/pnpm --run ${self'.packages.sync-npm-git-dependencies-with-nix}/bin/sync-npm-git-dependencies-with-nix
'';
};
devShells.synchronized-pnpm = pkgs.mkShell {
packages = let
npm-warning = pkgs.writeShellScriptBin "echo-npm-warning" ''
echo "
-----------------
WARNING: this repository is not managed with npm, but pnpm.
Don't worry! They are really similar to each other. Here are some helpful reminders:
If you are trying to run \`npm install\`, you can run \`pnpm install\`
If you are trying to run \`npm install some_dependency\`, you can run \`pnpm add some_dependency\`
If you are trying to run a script like \`npm run build\`, you can run \`pnpm build\`
If you are trying to run a script for a certain workspace like \`npm run build -w ui\`, you can run \`pnpm -F ui build\`
The npm command that you just ran will continue now, but it is recommended that you do all commands in this repository with pnpm.
-----------------
"
'';
npm-with-warning = pkgs.symlinkJoin {
name = "npm";
paths = [ pkgs.nodejs_20 ];
buildInputs = [ pkgs.makeWrapper ];
postBuild =
" wrapProgram $out/bin/npm \\\n --run ${npm-warning}/bin/echo-npm-warning\n ";
};
in [
npm-with-warning
pkgs.nodejs_20
packages.synchronized-pnpm
self'.packages.sync-npm-git-dependencies-with-nix
];
shellHook = ''
sync-npm-git-dependencies-with-nix
'';
};
};
};
}