diff --git a/README.md b/README.md index 14cb075abf..9a74d63aa7 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,6 @@ We are shipping a first look at the DIMOS x Unitree Go2 integration, allowing fo # Install Nix curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install -# make sure flakes are enabled -mkdir -p "$HOME/.config/nix"; echo "experimental-features = nix-command flakes" >> "$HOME/.config/nix/nix.conf" - # clone the repository git clone --branch dev --single-branch https://github.com/dimensionalOS/dimos.git @@ -73,8 +70,6 @@ nix develop # You should be able to follow the instructions below as well for a more manual installation ``` - - --- ## Python Installation Tested on Ubuntu 22.04/24.04 diff --git a/bin/_dev_init b/bin/_dev_init deleted file mode 100755 index 27683a4b5f..0000000000 --- a/bin/_dev_init +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env bash - -# TODO: combine this script into bin/dev, let bin/dev handle choosing between docker/nix/manual setup - -# summary: -# This script should be run after: -# 1. all system dependencies are installed (e.g. after `nix develop` or manual installation) -# 2. the project is cloned -# This script is designed to be user-interactive -# It handles setting up a python virtual environment, git lfs installing python dependencies, and running tests - -PROJECT_ROOT=$(git rev-parse --show-toplevel) -cd "$PROJECT_ROOT" - -cyan="$(printf '%b' "\e[0;36m")" -light_green="$(printf '%b' "\e[0;1;32m")" -color_reset="$(printf '%b' "\e[0m")" -red="$(printf '%b' "\e[0;31m")" -newline="$(printf "\n")" - -# helper -confirm_ask() { - echo - echo - question="$1";answer="" - while true; do - echo $light_green"$question"$color_reset; read response - if [ -z "$response" ]; then - echo - return 0 # success - break - fi - case "$response" in - [Yy]* ) answer='yes'; break;; - [Nn]* ) answer='no'; break;; - * ) echo "Please answer yes or no.";; - esac - done - if [ "$answer" = "yes" ]; then - echo - return 0 # success - fi - echo - return 1 # failure -} - -macos_version="$(sw_vers -productVersion 2>/dev/null || echo "0.0")" -macos_major_version="''${macos_version%%.*}" -echo $light_green"Making sure git lfs is installed..."$color_reset -git lfs install --skip-smudge - -if confirm_ask "Should I donwload the models and data? (around 17Gb) this will be needed to run the simulation [y/n]"; then - echo "Downloading the models and data..." - git lfs fetch --all - git lfs pull - echo "Done!" -fi - -# check if no .env -if ! [ -f ".env" ] -then - echo "Setting up .env file..." - cp default.env .env - echo - echo "note: you might want to edit the .env file with your own settings" - echo -fi - -echo $light_green"Setting up virtualenv..."$color_reset -python3 -m venv venv -echo "Activating virtualenv..." -. venv/bin/activate -echo "Installing python dependencies..." -pip install -e . - -# if really old MacOS then ignore the lcm dependency (it'll be supplied by nix) -if [ "$(uname)" = "Darwin" ] && [ "$macos_major_version" -le 13 ]; then - echo "You're on a really old MacOS version. Ignore the errors above (and probably later below) about LCM" - echo "Got it? (press enter)";read _ - rm -f pyproject.original.toml - cp pyproject.toml pyproject.original.toml - # install dimos-lcm without installing lcm - pip install --no-deps 'git+https://github.com/dimensionalOS/dimos-lcm.git' - # manually install dependencies of dimos-lcm - pip install foxglove-websocket numpy - # remove dimos-lcm from pyproject.toml for a moment - grep -v '^\s*#' pyproject.original.toml | grep -v "dimos-lcm @ .*" | grep -v "opencv-python" > pyproject.toml - pip install -e '.[cpu,dev,sim]' 2>&1 | grep -v -E "Could not find a version that satisfies the requirement lcm |ERROR: No matching distribution found for lcm" - # restore pyproject.toml - rm -f pyproject.toml - mv pyproject.original.toml pyproject.toml -fi - -# CUDA/CPU dependencies -if ! [ "$(uname)" = "Darwin" ] && confirm_ask "Want me to install the cuda dependencies? [y/n]"; then - # get around weird "pytorch not found" error that seems to be a detection2 issue (how did that install ever work?) - pip install 'detectron2 @ git+https://github.com/facebookresearch/detectron2.git@v0.6' --no-build-isolation - - rm -f pyproject.original.toml - cp pyproject.toml pyproject.original.toml - # for just a moment, remove facebookresearch/detectron2 from pyproject.toml - grep -v '^\s*#' pyproject.original.toml | grep -v "facebookresearch/detectron2" > pyproject.toml - pip install -e '.[cuda,dev]' - # restore pyproject.toml - rm -f pyproject.toml - mv pyproject.original.toml pyproject.toml -else - echo "installing CPU dependencies" - pip install -e '.[cpu,dev]' -fi - -# Mujoco/Simulation dependencies -if confirm_ask "Want me to install the optional simulation (mujoco) dependencies? [y/n]"; then - pip install -e '.[sim]' -fi - -if confirm_ask "Would you like me to run the tests to make sure everything is working? [y/n]"; then - echo "Running tests..." - echo "$cyan "'python -m pytest -s "./dimos/"'$color_reset - python -m pytest -s "$PROJECT_ROOT/dimos/" && echo "${light_green}${newline}tests finished${color_reset}" -fi - -echo -echo -echo $light_green"here's the main example command to run:"$color_reset -echo "$cyan dimos --replay run unitree-go2 $color_reset" -echo diff --git a/flake.lock b/flake.lock index 1934527896..e6d920a293 100644 --- a/flake.lock +++ b/flake.lock @@ -18,78 +18,6 @@ "type": "github" } }, - "home-manager": { - "inputs": { - "nixpkgs": [ - "xome", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1753983724, - "narHash": "sha256-2vlAOJv4lBrE+P1uOGhZ1symyjXTRdn/mz0tZ6faQcg=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "7035020a507ed616e2b20c61491ae3eaa8e5462c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "home-manager", - "type": "github" - } - }, - "lib": { - "inputs": { - "flakeUtils": [ - "flake-utils" - ], - "libSource": "libSource" - }, - "locked": { - "lastModified": 1763164848, - "narHash": "sha256-OlnnK3Iepi4As1onBrNfIiiQ0xIGzEWsJ16/TrLFcpY=", - "owner": "jeff-hykin", - "repo": "quick-nix-toolkits", - "rev": "3c820d33a0c4c8480a771484f99490243b3c6b5f", - "type": "github" - }, - "original": { - "owner": "jeff-hykin", - "repo": "quick-nix-toolkits", - "type": "github" - } - }, - "libSource": { - "locked": { - "lastModified": 1763255503, - "narHash": "sha256-7AL5rgcGVjhYgZFbZQt1IndGcY27h5B5xi9OWtLlm6c=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "56f74a2d6cd236c0ea3097b3df2e053fbb374b26", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "libSource_2": { - "locked": { - "lastModified": 1753579242, - "narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=", - "owner": "divnix", - "repo": "nixpkgs.lib", - "rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1748929857, @@ -109,9 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "lib": "lib", - "nixpkgs": "nixpkgs", - "xome": "xome" + "nixpkgs": "nixpkgs" } }, "systems": { @@ -128,31 +54,6 @@ "repo": "default", "type": "github" } - }, - "xome": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "home-manager": "home-manager", - "libSource": "libSource_2", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1765320026, - "narHash": "sha256-yPvFElT1PG4ENioIn+ctf682E8y6jPodeosM8One680=", - "owner": "jeff-hykin", - "repo": "xome", - "rev": "bae4f441d3e1ebe3b2da51a3ecdbdccddda67444", - "type": "github" - }, - "original": { - "owner": "jeff-hykin", - "repo": "xome", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0d05f42876..6491c5d88a 100644 --- a/flake.nix +++ b/flake.nix @@ -4,14 +4,9 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; - lib.url = "github:jeff-hykin/quick-nix-toolkits"; - lib.inputs.flakeUtils.follows = "flake-utils"; - xome.url = "github:jeff-hykin/xome"; - xome.inputs.nixpkgs.follows = "nixpkgs"; - xome.inputs.flake-utils.follows = "flake-utils"; }; - outputs = { self, nixpkgs, flake-utils, lib, xome, ... }: + outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; @@ -19,300 +14,80 @@ # ------------------------------------------------------------ # 1. Shared package list (tool-chain + project deps) # ------------------------------------------------------------ - # we "flag" each package with what we need it for (e.g. LD_LIBRARY_PATH, nativeBuildInputs vs buildInputs, etc) - aggregation = lib.aggregator [ + devPackages = with pkgs; [ ### Core shell & utils - { vals.pkg=pkgs.bashInteractive; flags={}; } - { vals.pkg=pkgs.coreutils; flags={}; } - { vals.pkg=pkgs.gh; flags={}; } - { vals.pkg=pkgs.stdenv.cc.cc.lib; flags.ldLibraryGroup=true; } - { vals.pkg=pkgs.stdenv.cc; flags.ldLibraryGroup=true; } - { vals.pkg=pkgs.cctools; flags={}; onlyIf=pkgs.stdenv.isDarwin; } # for pip install opencv-python - { vals.pkg=pkgs.pcre2; flags={ ldLibraryGroup=true; packageConfGroup=pkgs.stdenv.isDarwin; }; } - { vals.pkg=pkgs.libsysprof-capture; flags.packageConfGroup=true; onlyIf=pkgs.stdenv.isDarwin; } - { vals.pkg=pkgs.xcbuild; flags={}; } - { vals.pkg=pkgs.git-lfs; flags={}; } - { vals.pkg=pkgs.gnugrep; flags={}; } - { vals.pkg=pkgs.gnused; flags={}; } - { vals.pkg=pkgs.iproute2; flags={}; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.pkg-config; flags={}; } - { vals.pkg=pkgs.git; flags={}; } - { vals.pkg=pkgs.opensshWithKerberos;flags={}; } - { vals.pkg=pkgs.unixtools.ifconfig; flags={}; } - { vals.pkg=pkgs.unixtools.netstat; flags={}; } - - # when pip packages call cc with -I/usr/include, that causes problems on some machines, this swaps that out for the nix cc headers - # this is only necessary for pip packages from venv, pip packages from nixpkgs.python312Packages.* already have "-I/usr/include" patched with the nix equivalent - { - vals.pkg=(pkgs.writeShellScriptBin - "cc-no-usr-include" - '' - #!${pkgs.bash}/bin/bash - set -euo pipefail - - real_cc="${pkgs.stdenv.cc}/bin/gcc" - - args=() - for a in "$@"; do - case "$a" in - -I/usr/include|-I/usr/local/include) - # drop these - ;; - *) - args+=("$a") - ;; - esac - done - - exec "$real_cc" "''${args[@]}" - '' - ); - flags={}; - } + bashInteractive coreutils gh + stdenv.cc.cc.lib pcre2 ### Python + static analysis - { vals.pkg=pkgs.python312; flags={}; vals.pythonMinorVersion="12";} - { vals.pkg=pkgs.python312Packages.pip; flags={}; } - { vals.pkg=pkgs.python312Packages.setuptools; flags={}; } - { vals.pkg=pkgs.python312Packages.virtualenv; flags={}; } - { vals.pkg=pkgs.pre-commit; flags={}; } + python312 python312Packages.pip python312Packages.setuptools + python312Packages.virtualenv pre-commit ### Runtime deps - { vals.pkg=pkgs.portaudio; flags={ldLibraryGroup=true; packageConfGroup=true;}; } - { vals.pkg=pkgs.ffmpeg_6; flags={}; } - { vals.pkg=pkgs.ffmpeg_6.dev; flags={}; } + python312Packages.pyaudio portaudio ffmpeg_6 ffmpeg_6.dev ### Graphics / X11 stack - { vals.pkg=pkgs.libGL; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.libGLU; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.mesa; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.glfw; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libX11; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXi; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXext; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXrandr; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXinerama; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXcursor; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXfixes; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXrender; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXdamage; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXcomposite; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libxcb; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXScrnSaver; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.xorg.libXxf86vm; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.udev; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.SDL2; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.SDL2.dev; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.zlib; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } + libGL libGLU mesa glfw + xorg.libX11 xorg.libXi xorg.libXext xorg.libXrandr xorg.libXinerama + xorg.libXcursor xorg.libXfixes xorg.libXrender xorg.libXdamage + xorg.libXcomposite xorg.libxcb xorg.libXScrnSaver xorg.libXxf86vm + + udev SDL2 SDL2.dev zlib ### GTK / OpenCV helpers - { vals.pkg=pkgs.glib; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.gtk3; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.gdk-pixbuf; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.gobject-introspection; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } + glib gtk3 gdk-pixbuf gobject-introspection ### GStreamer - { vals.pkg=pkgs.gst_all_1.gstreamer; flags.ldLibraryGroup=true; flags.giTypelibGroup=true; } - { vals.pkg=pkgs.gst_all_1.gst-plugins-base; flags.ldLibraryGroup=true; flags.giTypelibGroup=true; } - { vals.pkg=pkgs.gst_all_1.gst-plugins-good; flags={}; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.gst_all_1.gst-plugins-bad; flags={}; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.gst_all_1.gst-plugins-ugly; flags={}; onlyIf=pkgs.stdenv.isLinux; } - { vals.pkg=pkgs.python312Packages.gst-python; flags={}; onlyIf=pkgs.stdenv.isLinux; } + gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good + gst_all_1.gst-plugins-bad gst_all_1.gst-plugins-ugly + python312Packages.gst-python ### Open3D & build-time - { vals.pkg=pkgs.eigen; flags={}; } - { vals.pkg=pkgs.cmake; flags={}; } - { vals.pkg=pkgs.ninja; flags={}; } - { vals.pkg=pkgs.jsoncpp; flags={}; } - { vals.pkg=pkgs.libjpeg; flags.ldLibraryGroup=true; } - { vals.pkg=pkgs.libjpeg_turbo; flags.ldLibraryGroup=true; } - { vals.pkg=pkgs.libpng; flags={}; } + eigen cmake ninja jsoncpp libjpeg libjpeg_turbo libpng ### LCM (Lightweight Communications and Marshalling) - { vals.pkg=pkgs.lcm; flags.ldLibraryGroup=true; onlyIf=pkgs.stdenv.isLinux; } - # lcm works on darwin, but only after two fixes (1. pkg-config, 2. fsync) - { - onlyIf=pkgs.stdenv.isDarwin; - flags.ldLibraryGroup=true; - flags.manualPythonPackages=true; - vals.pkg=pkgs.lcm.overrideAttrs (old: - let - # 1. fix pkg-config on darwin - pkgConfPackages = aggregation.getAll { hasAllFlags=[ "packageConfGroup" ]; attrPath=[ "pkg" ]; }; - packageConfPackagesString = (aggregation.getAll { - hasAllFlags=[ "packageConfGroup" ]; - attrPath=[ "pkg" ]; - strAppend="/lib/pkgconfig"; - strJoin=":"; - }); - in - { - buildInputs = (old.buildInputs or []) ++ pkgConfPackages; - nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ pkgs.pkg-config pkgs.python312 ]; - # 1. fix pkg-config on darwin - env.PKG_CONFIG_PATH = packageConfPackagesString; - # 2. Fix fsync on darwin - patches = [ - (pkgs.writeText "lcm-darwin-fsync.patch" "--- ./lcm-logger/lcm_logger.c 2025-11-14 09:46:01.000000000 -0600\n+++ ./lcm-logger/lcm_logger.c 2025-11-14 09:47:05.000000000 -0600\n@@ -428,9 +428,13 @@\n if (needs_flushed) {\n fflush(logger->log->f);\n #ifndef WIN32\n+#ifdef __APPLE__\n+ fsync(fileno(logger->log->f));\n+#else\n // Perform a full fsync operation after flush\n fdatasync(fileno(logger->log->f));\n #endif\n+#endif\n logger->last_fflush_time = log_event->timestamp;\n }\n") - ]; - } - ); - } + lcm ]; # ------------------------------------------------------------ - # 2. group / aggregate our packages - # ------------------------------------------------------------ - devPackages = aggregation.getAll { attrPath=[ "pkg" ]; }; - ldLibraryPackages = aggregation.getAll { hasAllFlags=[ "ldLibraryGroup" ]; attrPath=[ "pkg" ]; }; - giTypelibPackagesString = aggregation.getAll { - hasAllFlags=[ "giTypelibGroup" ]; - attrPath=[ "pkg" ]; - strAppend="/lib/girepository-1.0"; - strJoin=":"; - }; - packageConfPackagesString = (aggregation.getAll { - hasAllFlags=[ "packageConfGroup" ]; - attrPath=[ "pkg" ]; - strAppend="/lib/pkgconfig"; - strJoin=":"; - }); - manualPythonPackages = (aggregation.getAll { - hasAllFlags=[ "manualPythonPackages" ]; - attrPath=[ "pkg" ]; - strAppend="/lib/python3.${aggregation.mergedVals.pythonMinorVersion}/site-packages"; - strJoin=":"; - }); - - # ------------------------------------------------------------ - # 3. Host interactive shell → `nix develop` + # 2. Host interactive shell → `nix develop` # ------------------------------------------------------------ - shellHook = '' - shopt -s nullglob 2>/dev/null || setopt +o nomatch 2>/dev/null || true # allow globs to be empty without throwing an error - if [ "$OSTYPE" = "linux-gnu" ]; then - export CC="cc-no-usr-include" # basically patching for nix + devShell = pkgs.mkShell { + packages = devPackages; + shellHook = '' # Create nvidia-only lib symlinks to avoid glibc conflicts NVIDIA_LIBS_DIR="/tmp/nix-nvidia-libs-$$" mkdir -p "$NVIDIA_LIBS_DIR" - for lib in /usr/lib/libcuda.so* /usr/lib/libnvidia*.so* /usr/lib/x86_64-linux-gnu/libnvidia*.so*; do + for lib in /usr/lib/libcuda.so* /usr/lib/libnvidia*.so*; do [ -e "$lib" ] && ln -sf "$lib" "$NVIDIA_LIBS_DIR/" 2>/dev/null done - fi - export LD_LIBRARY_PATH="$NVIDIA_LIBS_DIR:${pkgs.lib.makeLibraryPath ldLibraryPackages}:$LD_LIBRARY_PATH" - export LIBRARY_PATH="$LD_LIBRARY_PATH" # fixes python find_library for pyaudio - export DISPLAY=:0 - export GI_TYPELIB_PATH="${giTypelibPackagesString}:$GI_TYPELIB_PATH" - export PKG_CONFIG_PATH=${lib.escapeShellArg packageConfPackagesString} - export PYTHONPATH="$PYTHONPATH:"${lib.escapeShellArg manualPythonPackages} - # CC, CFLAGS, and LDFLAGS are bascially all for `pip install pyaudio` - export CFLAGS="$(pkg-config --cflags portaudio-2.0) $CFLAGS" - export LDFLAGS="-L$(pkg-config --variable=libdir portaudio-2.0) $LDFLAGS" - # without this alias, the pytest uses the non-venv python and fails - alias pytest="python -m pytest" - - PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD") - [ -f "$PROJECT_ROOT/motd" ] && cat "$PROJECT_ROOT/motd" - [ -f "$PROJECT_ROOT/.pre-commit-config.yaml" ] && pre-commit install --install-hooks - if [ -f "$PROJECT_ROOT/env/bin/activate" ]; then - . "$PROJECT_ROOT/env/bin/activate" - fi - cd "$PROJECT_ROOT" - - # - # python & setup - # - if [ -f "$PROJECT_ROOT/venv/bin/activate" ]; then - # if there is a venv, load it - _nix_python_path="$(realpath "$(which python)")" - . "$PROJECT_ROOT/venv/bin/activate" - # check the venv to make sure it wasn't created with a different (non nix) python - if [ "$_nix_python_path" != "$(realpath "$(which python)")" ] - then - echo - echo - echo "WARNING:" - echo " Your venv was created with something other than the current nix python" - echo " This could happen if you made the venv before doing `nix develop`" - echo " It could also happen if the nix-python was updated but the venv wasn't" - echo " WHAT YOU NEED TO DO:" - echo " - If you're about to make/test a PR, delete/rename your venv and run `nix develop` again" - echo " - If you're just trying to get the code working, you can continue but you might get bugs FYI" - echo - echo - echo "Got it? (press enter)"; read _ - echo + export LD_LIBRARY_PATH="$NVIDIA_LIBS_DIR:${pkgs.lib.makeLibraryPath [ + pkgs.stdenv.cc.cc.lib pkgs.libGL pkgs.libGLU pkgs.mesa pkgs.glfw + pkgs.xorg.libX11 pkgs.xorg.libXi pkgs.xorg.libXext pkgs.xorg.libXrandr + pkgs.xorg.libXinerama pkgs.xorg.libXcursor pkgs.xorg.libXfixes + pkgs.xorg.libXrender pkgs.xorg.libXdamage pkgs.xorg.libXcomposite + pkgs.xorg.libxcb pkgs.xorg.libXScrnSaver pkgs.xorg.libXxf86vm + pkgs.udev pkgs.portaudio pkgs.SDL2.dev pkgs.zlib pkgs.glib pkgs.gtk3 + pkgs.gdk-pixbuf pkgs.gobject-introspection pkgs.lcm + pkgs.gst_all_1.gstreamer pkgs.gst_all_1.gst-plugins-base + pkgs.libjpeg_turbo]}:$LD_LIBRARY_PATH" + + export DISPLAY=:0 + export GI_TYPELIB_PATH="${pkgs.gst_all_1.gstreamer}/lib/girepository-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/girepository-1.0:$GI_TYPELIB_PATH" + + PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD") + if [ -f "$PROJECT_ROOT/env/bin/activate" ]; then + . "$PROJECT_ROOT/env/bin/activate" fi - else - # - # automate the readme - # - cyan="$(printf '%b' "\e[0;36m")" - color_reset="$(printf '%b' "\e[0m")" - echo - echo "I don't see a venv directory" - echo "If you'd like me to setup the project for you, run: $cyan bin/_dev_init $color_reset" - fi - ''; - devShells = { - # basic shell (blends with your current environment) - default = pkgs.mkShell { - buildInputs = devPackages; - shellHook = shellHook; - }; - # strict shell (creates a fake home, only select exteral commands (e.g. sudo) from your system are available) - isolated = (xome.simpleMakeHomeFor { - inherit pkgs; - pure = true; - commandPassthrough = [ "sudo" "nvim" "code" "sysctl" "sw_vers" "git" "vim" "emacs" "openssl" "ssh" "osascript" "otool" "hidutil" "logger" "codesign" ]; # e.g. use external nvim instead of nix's - # commonly needed for MacOS: [ "osascript" "otool" "hidutil" "logger" "codesign" ] - homeSubpathPassthrough = [ "cache/nix/" ]; # share nix cache between projects - homeModule = { - # for home-manager examples, see: - # https://deepwiki.com/nix-community/home-manager/5-configuration-examples - # all home-manager options: - # https://nix-community.github.io/home-manager/options.xhtml - home.homeDirectory = "/tmp/virtual_homes/dimos"; - home.stateVersion = "25.11"; - home.packages = devPackages; - programs = { - home-manager = { - enable = true; - }; - zsh = { - enable = true; - enableCompletion = true; - autosuggestion.enable = true; - syntaxHighlighting.enable = true; - shellAliases.ll = "ls -la"; - history.size = 100000; - # this is kinda like .zshrc - initContent = '' - # most people expect comments in their shell to to work - setopt interactivecomments - # fix emoji prompt offset issues (this shouldn't lock people into English b/c LANG can be non-english) - export LC_CTYPE=en_US.UTF-8 - ${shellHook} - ''; - }; - starship = { - enable = true; - enableZshIntegration = true; - settings = { - character = { - success_symbol = "[▣](bold green)"; - error_symbol = "[▣](bold red)"; - }; - }; - }; - }; - }; - }).default; + [ -f "$PROJECT_ROOT/motd" ] && cat "$PROJECT_ROOT/motd" + [ -f "$PROJECT_ROOT/.pre-commit-config.yaml" ] && pre-commit install --install-hooks + ''; }; # ------------------------------------------------------------ - # 4. Closure copied into the OCI image rootfs + # 3. Closure copied into the OCI image rootfs # ------------------------------------------------------------ imageRoot = pkgs.buildEnv { name = "dimos-image-root"; @@ -322,7 +97,7 @@ in { ## Local dev shell - devShells = devShells; + devShells.default = devShell; ## Layered docker image with DockerTools packages.devcontainer = pkgs.dockerTools.buildLayeredImage {