-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use direct output because build is super complicated * formatting
- Loading branch information
1 parent
1baa41a
commit b18c7d5
Showing
2 changed files
with
27 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,36 @@ | ||
{ 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; | ||
}; | ||
version = (builtins.fromJSON (builtins.readFile ./javascript/packages/cli/package.json)).version; | ||
name = "zombienet"; | ||
releases = "https://github.com/paritytech/${name}/releases/download"; | ||
src = | ||
if pkgs.stdenv.isDarwin then { | ||
url = "${releases}/v${version}/${name}-macos"; | ||
sha256 = "sha256-piaiv6hFTIZOVZNgo7oooNe+TwRrcNzn4SiT4n1jEBQ="; | ||
} else | ||
if system == "aarch64-linux" then { | ||
url = "${releases}/v${version}/${name}-linux-arm64"; | ||
sha256 = "sha256-tXZt8Q6R8jh/UgdmS2jQf3IWGd4wx3u7tY+etYLIXYg="; | ||
} else { | ||
url = "${releases}/v${version}/${name}-linux-x64"; | ||
sha256 = "sha256-uf4eykvGEvqtCBfX4eCQe4f4SpagV4VBYVA4hgBzg1w="; | ||
}; | ||
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-lA8xOKnzthgscr0pMmQ6KcZjYxNdOK5lfZ301PZ29Xg="; | ||
|
||
pname = "zombienet"; | ||
name = pname; | ||
src = cleaned-javascript-src; | ||
npmBuildScript = "build"; | ||
npmBuildFlag = "--workspaces"; | ||
|
||
# just for safety of mac as it is used here often | ||
nativeBuildInputs = with pkgs; [ | ||
python3 | ||
nodePackages.node-gyp-build | ||
nodePackages.node-gyp | ||
] ++ pkgs.lib.optional pkgs.stdenv.isDarwin (with pkgs; | ||
with darwin.apple_sdk.frameworks; [ | ||
Security | ||
SystemConfiguration | ||
]); | ||
|
||
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 | ||
preBuild = '' | ||
patchShebangs packages | ||
''; | ||
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/ | ||
''; | ||
}; | ||
default = pkgs.stdenv.mkDerivation | ||
{ | ||
runtimeInputs = with pkgs; [ bash coreutils procps findutils podman kubectl ] ++ lib.optional stdenv.isLinux glibc.bin; | ||
inherit name; | ||
src = pkgs.fetchurl src; | ||
phases = [ "installPhase" "patchPhase" ]; | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp $src $out/bin/${name} | ||
chmod +x $out/bin/${name} | ||
''; | ||
}; | ||
}; | ||
}; | ||
} |
Empty file.