forked from paritytech/zombienet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake-module.nix
47 lines (45 loc) · 2.13 KB
/
flake-module.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
{ self, ... }: {
perSystem = { config, self', inputs', pkgs, system, ... }:
let
# reuse existing ignores to clone source
cleaned-javascript-src = pkgs.lib.cleanSourceWith {
src = pkgs.lib.cleanSource ./javascript;
filter = pkgs.nix-gitignore.gitignoreFilterPure (name: type:
# nix files are not used as part of build
(type == "regular" && pkgs.lib.strings.hasSuffix ".nix" name)
== false) [ ./.gitignore ] ./javascript;
};
in {
packages = rec {
# output is something like what npm 'pkg` does, but more sandboxed
default = pkgs.buildNpmPackage rec {
# root hash (hash of hashes of each dependnecies)
# this should be updated on each dependency change (use `prefetch-npm-deps` to get new hash)
npmDepsHash = "sha256-kERCSeGAkc0caAahT7fsQzAPL5Bq/rdMgnEhNvCD97I=";
pname = "zombienet";
name = pname;
src = cleaned-javascript-src;
npmBuildScript = "build";
npmBuildFlag = "--workspaces";
runtimeDeps = with pkgs;
# these are used behind the scenes
# can provide nix `devenv` with running podman based kubernetes as process/service
[ bash coreutils procps findutils podman kubectl ]
++ lib.optional stdenv.isLinux glibc.bin;
# uncomment if need to debug build
#npmFlags = "--verbose";
# unfortunately current fetcher(written in rust) has bugs for workspaes, so this is ugly workaround https://github.com/NixOS/nixpkgs/issues/219673
postBuild = ''
echo "Generating `dist` of `workspace`"
npm run build --workspace=packages/utils
npm run build --workspace=packages/orchestrator
'';
postInstall = ''
echo "Copying `dist` of `workspace` to output"
cp --recursive packages/orchestrator/dist/ $out/lib/node_modules/zombienet/node_modules/@zombienet/orchestrator/dist/
cp --recursive packages/utils/dist/ $out/lib/node_modules/zombienet/node_modules/@zombienet/utils/dist/
'';
};
};
};
}