From b18c7d534e334ca9ea82cbfac4a47c0177248a31 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Wed, 17 May 2023 11:59:17 +0100 Subject: [PATCH] switch flake to raw release (#1055) * use direct output because build is super complicated * formatting --- flake-module.nix | 82 ++++++++++++++----------------------------- javascript/flake.lock | 0 2 files changed, 27 insertions(+), 55 deletions(-) create mode 100644 javascript/flake.lock diff --git a/flake-module.nix b/flake-module.nix index 214f3292e..493726eed 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -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} + ''; + }; }; }; } diff --git a/javascript/flake.lock b/javascript/flake.lock new file mode 100644 index 000000000..e69de29bb