Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added 71
Empty file.
9 changes: 7 additions & 2 deletions assets.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{ pkgs ? import ./nix {}
, bootstrap-js ? import ./src/bootstrap { inherit pkgs; }
{ system ? builtins.currentSystem
, pkgs ? import ./nix {}
, bootstrap-js ? import ./nix/agent-js/bootstrap-js.nix { inherit system pkgs; }
, agent-js ? import ./nix/agent-js/agent-js.nix { inherit system pkgs; }
, distributed-canisters ? import ./distributed-canisters.nix { inherit pkgs; }
}:
pkgs.runCommandNoCCLocal "assets" {} ''
Expand All @@ -17,5 +19,8 @@ pkgs.runCommandNoCCLocal "assets" {} ''
mkdir $out/bootstrap
cp -R ${bootstrap-js.out}/* $out/bootstrap/

mkdir $out/agent-js
cp -R ${agent-js.out}/* $out/agent-js/

cp -R ${distributed-canisters} $out/canisters
''
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ rec {
node-e2e-tests = import ./e2e/node { inherit pkgs dfx; };

# Agents in varous languages
agent-js = import ./src/agent/javascript { inherit pkgs; };
agent-js = import ./nix/agent-js/agent-js.nix { inherit system pkgs; };

# Bootstrap frontend.
bootstrap-js = import ./src/bootstrap { inherit pkgs agent-js; };
bootstrap-js = import ./nix/agent-js/bootstrap-js.nix { inherit system pkgs; };

cargo-audit = import ./cargo-audit.nix { inherit pkgs RustSec-advisory-db; };

Expand Down
51 changes: 51 additions & 0 deletions nix/agent-js/agent-js-monorepo.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{ pkgs ? import ../. { inherit system; }
, system ? builtins.currentSystem
# This should be via sourcesnix for the git monorepo
, agent-js-monorepo-src
}:
let
src = agent-js-monorepo-src;
agentPackagePath = (src + "/packages/agent");
monorepo = pkgs.napalm.buildPackage src {
name = "agent-js-monorepo";
buildInputs = [
pkgs.python3
];
propagatedNativeBuildInputs = [
# Required by node-gyp
pkgs.python3
];
propagatedBuildInputs = pkgs.lib.optional pkgs.stdenv.isDarwin
# Required by fsevents
pkgs.darwin.apple_sdk.frameworks.CoreServices;
outputs = [
"out"
"agent"
"bootstrap"
"lib"
];
# HUSKY_DEBUG = "1";
# HUSKY_SKIP_INSTALL = "1";
npmCommands = [
"npm install"
];
installPhase = ''
mkdir -p $out

cp -R ./* $out/

# Copy node_modules to be reused elsewhere.
mkdir -p $lib
test -d node_modules && cp -R node_modules $lib || true

mkdir -p $agent
cp -R node_modules $agent/
cp -R ./packages/agent/* $agent/

mkdir -p $bootstrap
cp -R node_modules $bootstrap/
cp -R ./packages/bootstrap/* $bootstrap/
'';
};
in
monorepo
27 changes: 27 additions & 0 deletions nix/agent-js/agent-js.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ pkgs ? import ../. { inherit system; }
, system ? builtins.currentSystem
}:
pkgs.stdenv.mkDerivation {
name = "agent-js";
src = "${pkgs.agent-js-monorepo}/packages/agent/";
buildInputs = [ pkgs.nodejs ];
outputs = [
"out"
"lib"
];
buildPhase = ''
# Don't run `npm run build` here, which will call `tsc -b`.
# `tsc -b` will use typescrpit project references to build things,
# which may try to read from other packages. But nix will error on read from those dirs.
# Let all building happen on the monorepo package.
'';
installPhase = ''
mkdir -p $out

cp -R ./* $out/

# Copy node_modules to be reused elsewhere.
mkdir -p $lib
test -d node_modules && cp -R node_modules $lib || true
'';
}
27 changes: 27 additions & 0 deletions nix/agent-js/bootstrap-js.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ pkgs ? import ../. { inherit system; }
, system ? builtins.currentSystem
}:
pkgs.stdenv.mkDerivation {
name = "bootstrap-js";
src = "${pkgs.agent-js-monorepo}/packages/bootstrap/";
buildInputs = [ pkgs.nodejs ];
outputs = [
"out"
"lib"
];
buildPhase = ''
# Don't run `npm run build` here, which will call `tsc -b`.
# `tsc -b` will use typescrpit project references to build things,
# which may try to read from other packages. But nix will error on read from those dirs.
# Let all building happen on the monorepo package.
'';
installPhase = ''
mkdir -p $out

cp -R ./* $out/

# Copy node_modules to be reused elsewhere.
mkdir -p $lib
test -d node_modules && cp -R node_modules $lib || true
'';
}
4 changes: 4 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ let
napalm = self.callPackage self.sources.napalm {
pkgs = self // { nodejs = self.nodejs-12_x; };
};
agent-js-monorepo = import ./agent-js/agent-js-monorepo.nix {
inherit system pkgs;
agent-js-monorepo-src = self.sources.agent-js-monorepo;
};
ic-ref = (import self.sources.ic-ref { inherit (self) system; }).ic-ref;

nix-fmt = nixFmt.fmt;
Expand Down
6 changes: 6 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"url": "https://github.com/RustSec/advisory-db/archive/47d125073886d0a7891e6a33a2db4e69b2accaf0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"agent-js-monorepo": {
"ref": "master",
"repo": "ssh://git@github.com/dfinity-lab/agent-js",
"rev": "c8a44f04bede186abc7c99e3a892a247dea05690",
"type": "git"
},
"bats-support": {
"branch": "v0.3.0",
"builtin": false,
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.