Skip to content
Draft
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
61 changes: 61 additions & 0 deletions flake.lock

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

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
description = "Nerve — self-hosted AI agent runtime";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Core tools
uv
nodejs_22
git

# Native libs for Python wheel builds (bcrypt, cryptography, aiosqlite, etc.)
openssl
sqlite
libffi
pkg-config
];

env = {
# Let uv manage Python — don't pull it from Nix
UV_PYTHON_PREFERENCE = "only-managed";
};

shellHook = ''
# Help native builds find nix-provided libs
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ pkgs.openssl pkgs.sqlite pkgs.libffi ]}:$LD_LIBRARY_PATH"
'';
};
});
}
24 changes: 24 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ detect_os() {
DISTRO="arch"; PKG_MGR="pacman" ;;
opensuse*)
DISTRO="suse"; PKG_MGR="zypper" ;;
nixos)
DISTRO="nixos"; PKG_MGR="nix" ;;
*)
DISTRO="${ID:-unknown}" ;;
esac
Expand All @@ -115,6 +117,17 @@ detect_os() {
esac
}

# --- NixOS helper ---

nixos_require() {
local tool="$1"
if command_exists "$tool"; then return 0; fi
error "$tool is required but not found."
error "On NixOS, enter the dev shell first: nix develop"
error "Or install $tool in your system/user profile."
exit 1
}

# --- Dependency: git ---

ensure_git() {
Expand All @@ -123,6 +136,8 @@ ensure_git() {
return
fi

if [ "$DISTRO" = "nixos" ]; then nixos_require git; return; fi

info "git is not installed"
if [ "$HAS_SUDO" = "0" ] && [ "$OS" = "linux" ]; then
error "git is required but sudo is not available. Install git manually and re-run."
Expand Down Expand Up @@ -162,6 +177,8 @@ ensure_uv() {
return
fi

if [ "$DISTRO" = "nixos" ]; then nixos_require uv; return; fi

info "Installing uv (Python package manager)..."
curl -LsSf https://astral.sh/uv/install.sh | sh

Expand Down Expand Up @@ -214,6 +231,11 @@ ensure_python() {
# Last resort: system packages
warn "uv python install failed. Trying system packages..."

if [ "$DISTRO" = "nixos" ]; then
error "uv python install failed. On NixOS, ensure you're in the dev shell: nix develop"
exit 1
fi

if [ "$HAS_SUDO" = "0" ] && [ "$OS" = "linux" ]; then
error "Cannot install Python: no sudo and uv python install failed."
error "Install Python 3.12+ manually and re-run."
Expand Down Expand Up @@ -276,6 +298,8 @@ ensure_node() {
warn "Node.js $(node --version) is too old (need v${MIN_NODE_MAJOR}+)"
fi

if [ "$DISTRO" = "nixos" ]; then nixos_require node; return; fi

info "Node.js ${MIN_NODE_MAJOR}+ is not installed"

if [ "$HAS_SUDO" = "0" ] && [ "$OS" = "linux" ]; then
Expand Down