Skip to content

Commit 5f60a21

Browse files
committed
fix dependencies
1 parent b3ea14f commit 5f60a21

File tree

1 file changed

+131
-60
lines changed

1 file changed

+131
-60
lines changed

flake.nix

+131-60
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
description = "Eliza - AI Agents for Everyone";
2+
description = "Eliza development environment";
33

44
inputs = {
5-
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
77
};
88

@@ -11,66 +11,137 @@
1111
nixpkgs,
1212
flake-utils,
1313
}:
14-
flake-utils.lib.eachDefaultSystem (
15-
system: let
16-
pkgs = nixpkgs.legacyPackages.${system};
17-
18-
commonConfig = {
19-
version = "0.1.5-alpha.5";
20-
src = pkgs.fetchFromGitHub {
21-
owner = "ai16z";
22-
repo = "eliza";
23-
rev = "v0.1.5-alpha.5";
24-
hash = "sha256-DjeDUBuflP2wPrBuy0uzu4Jm3IhwBQrYe2KDLaigElM=";
25-
};
26-
buildInputs = with pkgs; [
27-
nodejs_23
28-
pnpm
29-
];
30-
};
31-
in {
32-
devShell = pkgs.mkShell {
33-
buildInputs = commonConfig.buildInputs;
34-
shellHook = ''
35-
echo "🤖 Welcome to Eliza Development Environment 🚀"
36-
echo ""
37-
echo "Quick Start:"
38-
echo " pnpm i - Install dependencies (run after pulling new changes)"
39-
echo " pnpm build - Build all packages"
40-
echo " pnpm clean - Clean build artifacts (run if you encounter issues)"
41-
echo ""
42-
echo "For more information, visit: https://ai16z.github.io/eliza/"
43-
echo ""
44-
'';
14+
flake-utils.lib.eachDefaultSystem (system: let
15+
pkgs = import nixpkgs {inherit system;};
16+
17+
# Define specific Node.js version
18+
nodejs = pkgs.stdenv.mkDerivation rec {
19+
pname = "nodejs";
20+
version = "23.3.0";
21+
22+
src = pkgs.fetchurl {
23+
url = "https://nodejs.org/dist/v${version}/node-v${version}-${
24+
if pkgs.stdenv.isDarwin
25+
then "darwin"
26+
else "linux"
27+
}-${
28+
if pkgs.stdenv.isx86_64
29+
then "x64"
30+
else "arm64"
31+
}.tar.gz";
32+
hash =
33+
if pkgs.stdenv.isDarwin
34+
then
35+
(
36+
if pkgs.stdenv.isx86_64
37+
then "sha256-0YmPeQEneWi3gGb2tRLLw71/JAaVA3eCb52OAtTiT+Y=" # darwin-x64
38+
else "sha256-RyuRCd2Zh+pJkW8SsB7S8J8cS/S+/PVpXBuf2c/z0Xc=" # darwin-arm64
39+
)
40+
else
41+
(
42+
if pkgs.stdenv.isx86_64
43+
then "sha256-pM6vbkHXYBfuVnBbrcXUks89X+ymB8en065U99sUkTs=" # linux-x64
44+
else "sha256-r0hZFIIjYAfSFmWqK9PRRfSQqpU+hcHKenx78EtxE0E=" # linux-arm64
45+
);
4546
};
4647

47-
packages = {
48-
eliza = pkgs.stdenv.mkDerivation (commonConfig
49-
// {
50-
pname = "eliza";
51-
buildPhase = ''
52-
# Install dependencies and build the project
53-
pnpm i
54-
pnpm build
55-
'';
56-
installPhase = ''
57-
# Copy built files to the output directory
58-
mkdir -p $out/bin
59-
cp -r dist/* $out/bin/
60-
'';
61-
meta = with pkgs.lib; {
62-
description = "Autonomous agents for everyone";
63-
homepage = "https://github.com/ai16z/eliza";
64-
changelog = "https://github.com/ai16z/eliza/blob/v${commonConfig.version}/CHANGELOG.md";
65-
license = licenses.mit;
66-
maintainers = with maintainers; [];
67-
mainProgram = "eliza";
68-
platforms = platforms.all;
69-
};
70-
});
48+
installPhase = ''
49+
mkdir -p $out
50+
cp -r ./* $out/
51+
chmod +x $out/bin/node
52+
chmod +x $out/bin/npm
53+
chmod +x $out/bin/npx
54+
'';
55+
56+
dontStrip = true;
57+
};
58+
59+
# Define specific pnpm version
60+
pnpm = pkgs.stdenv.mkDerivation {
61+
name = "pnpm-9.12.3";
62+
version = "9.12.3";
63+
64+
src = pkgs.fetchurl {
65+
url = "https://registry.npmjs.org/pnpm/-/pnpm-9.12.3.tgz";
66+
hash = "sha256-JCNXcsxKyCpiYnzUf4NMcmZ6LOh3mahG7E6OVV4tS4s=";
7167
};
7268

73-
defaultPackage = self.packages.${system}.eliza;
74-
}
75-
);
69+
buildInputs = [nodejs];
70+
71+
installPhase = ''
72+
# Create directories
73+
mkdir -p $out/{lib,bin}
74+
75+
# Extract tarball
76+
cd $out/lib
77+
tar xzf $src --strip-components=1
78+
79+
# Create the executable
80+
cat > $out/bin/pnpm << EOF
81+
#!${nodejs}/bin/node
82+
require(process.env.PNPM_DIST || require('path').resolve(__dirname, '../lib/dist/pnpm.cjs'))
83+
EOF
84+
85+
chmod +x $out/bin/pnpm
86+
87+
# Export the dist path
88+
mkdir -p $out/nix-support
89+
echo "export PNPM_DIST=\"$out/lib/dist/pnpm.cjs\"" >> $out/nix-support/setup-hook
90+
'';
91+
92+
dontStrip = true;
93+
};
94+
95+
# Define development tools separately
96+
devTools = with pkgs; [
97+
nixpkgs-fmt
98+
remarshal
99+
gcc
100+
gnumake
101+
python3
102+
vips
103+
libopus
104+
rabbitmq-server
105+
pkg-config
106+
pnpm # Our specific pnpm version
107+
];
108+
in {
109+
devShells.default = pkgs.mkShell {
110+
buildInputs = devTools;
111+
112+
shellHook = ''
113+
echo "Welcome to Eliza development environment"
114+
115+
# Ensure project-specific Node.js takes precedence
116+
export PATH="${nodejs}/bin:$PATH"
117+
118+
# Set up pnpm environment
119+
export PNPM_HOME="$HOME/.local/share/pnpm"
120+
export PATH="$PNPM_HOME:$PATH"
121+
122+
# Ensure PNPM_HOME exists
123+
mkdir -p "$PNPM_HOME"
124+
125+
# Set up development environment variables
126+
export NODE_ENV="development"
127+
export VERBOSE="true"
128+
export DEBUG="eliza:*"
129+
130+
# Print available commands
131+
echo "Available commands:"
132+
echo " pnpm i - Install dependencies"
133+
echo " pnpm build - Build the project"
134+
echo " pnpm dev - Start development server"
135+
echo " pnpm test - Run tests"
136+
137+
# Print actual environment versions
138+
node_version=$(${nodejs}/bin/node --version)
139+
pnpm_version=$(pnpm --version)
140+
echo "Node.js version: $node_version"
141+
echo "pnpm version: $pnpm_version"
142+
'';
143+
};
144+
145+
formatter = pkgs.nixpkgs-fmt;
146+
});
76147
}

0 commit comments

Comments
 (0)