From 2467c0ee97397bae346654734ca4f3893bdc9249 Mon Sep 17 00:00:00 2001 From: Jeff Hykin Date: Thu, 15 Jan 2026 01:22:57 -0800 Subject: [PATCH 1/2] add uv to nix and fix resulting problems --- flake.lock | 46 +++++++++++++++++++++++++------------ flake.nix | 67 +++++++++++++++++++++++++++++++++++------------------- 2 files changed, 75 insertions(+), 38 deletions(-) diff --git a/flake.lock b/flake.lock index 402f251030..94e952d483 100644 --- a/flake.lock +++ b/flake.lock @@ -37,20 +37,20 @@ "home-manager": { "inputs": { "nixpkgs": [ - "xome", "nixpkgs" ] }, "locked": { - "lastModified": 1753983724, - "narHash": "sha256-2vlAOJv4lBrE+P1uOGhZ1symyjXTRdn/mz0tZ6faQcg=", + "lastModified": 1767910483, + "narHash": "sha256-MOU5YdVu4DVwuT5ztXgQpPuRRBjSjUGIdUzOQr9iQOY=", "owner": "nix-community", "repo": "home-manager", - "rev": "7035020a507ed616e2b20c61491ae3eaa8e5462c", + "rev": "82fb7dedaad83e5e279127a38ef410bcfac6d77c", "type": "github" }, "original": { "owner": "nix-community", + "ref": "release-25.11", "repo": "home-manager", "type": "github" } @@ -63,11 +63,11 @@ "libSource": "libSource" }, "locked": { - "lastModified": 1764022662, - "narHash": "sha256-vS3EeyELqCskh88JkUW/ce8A8b3m+iRPLPd4kDRTqPY=", + "lastModified": 1768416447, + "narHash": "sha256-S0n9qoPXg4P1VxOu5ayiuxk7nJk1kk6FlVevU4y9v5o=", "owner": "jeff-hykin", "repo": "quick-nix-toolkits", - "rev": "de1cc174579ecc7b655de5ba9618548d1b72306c", + "rev": "dfad23538da813bc0eb5148644af9227e04191f0", "type": "github" }, "original": { @@ -78,11 +78,11 @@ }, "libSource": { "locked": { - "lastModified": 1766884708, - "narHash": "sha256-x8nyRwtD0HMeYtX60xuIuZJbwwoI7/UKAdCiATnQNz0=", + "lastModified": 1768094297, + "narHash": "sha256-+Mdb/3c09zZPpSfdnO0JdG+a/rgNA4YGuA6n7pvvFBE=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "15177f81ad356040b4460a676838154cbf7f6213", + "rev": "a9f5b3ba6295f67949cec77dd2fb9c3876d0070c", "type": "github" }, "original": { @@ -108,26 +108,40 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748929857, - "narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=", + "lastModified": 1768323494, + "narHash": "sha256-yBXJLE6WCtrGo7LKiB6NOt6nisBEEkguC/lq/rP3zRQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4", + "rev": "2c3e5ec5df46d3aeee2a1da0bfedd74e21f4bf3a", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" } }, + "nixpkgsSourceWithPreCommit": { + "locked": { + "lastModified": 1767151656, + "narHash": "sha256-ujL2AoYBnJBN262HD95yer7QYUmYp5kFZGYbyCCKxq8=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/f665af0cdb70ed27e1bd8f9fdfecaf451260fc55.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/f665af0cdb70ed27e1bd8f9fdfecaf451260fc55.tar.gz" + } + }, "root": { "inputs": { "diagon": "diagon", "flake-utils": "flake-utils", + "home-manager": "home-manager", "lib": "lib", "nixpkgs": "nixpkgs", + "nixpkgsSourceWithPreCommit": "nixpkgsSourceWithPreCommit", "xome": "xome" } }, @@ -151,7 +165,9 @@ "flake-utils": [ "flake-utils" ], - "home-manager": "home-manager", + "home-manager": [ + "home-manager" + ], "libSource": "libSource_2", "nixpkgs": [ "nixpkgs" diff --git a/flake.nix b/flake.nix index 3a70a0bf2f..d1377c92a2 100644 --- a/flake.nix +++ b/flake.nix @@ -2,20 +2,27 @@ description = "Project dev environment as Nix shell + DockerTools layered image"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; flake-utils.url = "github:numtide/flake-utils"; lib.url = "github:jeff-hykin/quick-nix-toolkits"; lib.inputs.flakeUtils.follows = "flake-utils"; + # home-manager.url = "github:nix-community/home-manager"; + home-manager.url = "github:nix-community/home-manager/release-25.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; xome.url = "github:jeff-hykin/xome"; xome.inputs.nixpkgs.follows = "nixpkgs"; xome.inputs.flake-utils.follows = "flake-utils"; + xome.inputs.home-manager.follows = "home-manager"; diagon.url = "github:petertrotman/nixpkgs/Diagon"; + # pre-commit on nixos-25.11 is broken, so we have to use an older version of nixpkgs just for pre-commit + nixpkgsSourceWithPreCommit.url = "https://github.com/NixOS/nixpkgs/archive/f665af0cdb70ed27e1bd8f9fdfecaf451260fc55.tar.gz"; }; - outputs = { self, nixpkgs, flake-utils, lib, xome, diagon, ... }: + outputs = { self, nixpkgs, flake-utils, lib, xome, diagon, nixpkgsSourceWithPreCommit, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; + nixpkgsWithPreCommit = import nixpkgsSourceWithPreCommit { inherit system; }; # ------------------------------------------------------------ # 1. Shared package list (tool-chain + project deps) @@ -76,7 +83,8 @@ { vals.pkg=pkgs.python312Packages.pip; flags={}; } { vals.pkg=pkgs.python312Packages.setuptools; flags={}; } { vals.pkg=pkgs.python312Packages.virtualenv; flags={}; } - { vals.pkg=pkgs.pre-commit; flags={}; } + { vals.pkg=pkgs.uv; flags={}; } + { vals.pkg=nixpkgsWithPreCommit.pre-commit; flags={}; } ### Runtime deps { vals.pkg=pkgs.portaudio; flags={ldLibraryGroup=true; packageConfGroup=true;}; } @@ -170,31 +178,33 @@ # ------------------------------------------------------------ # 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 { + groups = { + 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 { + }); + manualPythonPackages = (aggregation.getAll { hasAllFlags=[ "manualPythonPackages" ]; attrPath=[ "pkg" ]; strAppend="/lib/python3.${aggregation.mergedVals.pythonMinorVersion}/site-packages"; strJoin=":"; - }); + }); + }; # ------------------------------------------------------------ # 3. Host interactive shell → `nix develop` # ------------------------------------------------------------ - shellHook = '' + envVarShellHook = '' 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 @@ -205,15 +215,18 @@ [ -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 LD_LIBRARY_PATH="$NVIDIA_LIBS_DIR:${pkgs.lib.makeLibraryPath groups.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} + export GI_TYPELIB_PATH="${groups.giTypelibPackagesString}:$GI_TYPELIB_PATH" + export PKG_CONFIG_PATH=${lib.escapeShellArg groups.packageConfPackagesString} + export PYTHONPATH="$PYTHONPATH:"${lib.escapeShellArg groups.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" + ''; + shellHook = '' + ${envVarShellHook} # without this alias, the pytest uses the non-venv python and fails alias pytest="python -m pytest" @@ -229,7 +242,7 @@ devShells = { # basic shell (blends with your current environment) default = pkgs.mkShell { - buildInputs = devPackages; + buildInputs = groups.devPackages; shellHook = shellHook; }; # strict shell (creates a fake home, only select exteral commands (e.g. sudo) from your system are available) @@ -246,7 +259,8 @@ # https://nix-community.github.io/home-manager/options.xhtml home.homeDirectory = "/tmp/virtual_homes/dimos"; home.stateVersion = "25.11"; - home.packages = devPackages; + home.packages = groups.devPackages; + targets.darwin = {copyApps.enable = false; linkApps.enable = true;}; # https://github.com/nix-community/home-manager/issues/8336 programs = { home-manager = { @@ -288,11 +302,18 @@ # ------------------------------------------------------------ imageRoot = pkgs.buildEnv { name = "dimos-image-root"; - paths = devPackages; + paths = groups.devPackages; pathsToLink = [ "/bin" ]; }; in { + # so that other people (and us debugging) can import this flake and use parts as needed + vars = { + inherit inputs pkgs groups aggregation devShells imageRoot; + devPackages = groups.devPackages; + shellHook = envVarShellHook; + fullShellHook = shellHook; + }; ## Local dev shell devShells = devShells; From fd6b9c4dbf7f7a0016a8e05d9c5065083d029c97 Mon Sep 17 00:00:00 2001 From: Jeff Hykin Date: Thu, 15 Jan 2026 02:50:42 -0800 Subject: [PATCH 2/2] fix for linux --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d1377c92a2..dd09a5f8cc 100644 --- a/flake.nix +++ b/flake.nix @@ -260,7 +260,8 @@ home.homeDirectory = "/tmp/virtual_homes/dimos"; home.stateVersion = "25.11"; home.packages = groups.devPackages; - targets.darwin = {copyApps.enable = false; linkApps.enable = true;}; # https://github.com/nix-community/home-manager/issues/8336 + # https://github.com/nix-community/home-manager/issues/8336 + targets = if pkgs.stdenv.isLinux then {} else { darwin = {copyApps.enable = false; linkApps.enable = true;}; }; programs = { home-manager = {