diff options
| -rw-r--r-- | flake.lock | 17 | ||||
| -rw-r--r-- | flake.nix | 24 | ||||
| -rw-r--r-- | nix/lib/mkSystem.nix | 9 | ||||
| -rw-r--r-- | nix/lib/overlays.nix | 9 | ||||
| -rw-r--r-- | nix/users/fcuny/darwin.nix | 2 | ||||
| -rw-r--r-- | nix/users/fcuny/dev.nix | 7 | ||||
| -rw-r--r-- | overlays/default.nix | 4 | ||||
| -rw-r--r-- | pkgs/llmPython/default.nix | 85 |
8 files changed, 138 insertions, 19 deletions
@@ -95,6 +95,22 @@ "type": "github" } }, + "nixpkgsUnstable": { + "locked": { + "lastModified": 1745391562, + "narHash": "sha256-sPwcCYuiEopaafePqlG826tBhctuJsLx/mhKKM5Fmjo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "8a2f738d9d1f1d986b5a4cd2fd2061a7127237d7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", @@ -122,6 +138,7 @@ "darwin": "darwin", "home-manager": "home-manager", "nixpkgs": "nixpkgs", + "nixpkgsUnstable": "nixpkgsUnstable", "pre-commit-hooks": "pre-commit-hooks", "treefmt-nix": "treefmt-nix" } @@ -4,6 +4,8 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { url = "github:nix-community/home-manager/release-24.11"; inputs.nixpkgs.follows = "nixpkgs"; @@ -29,6 +31,7 @@ outputs = { nixpkgs, + nixpkgsUnstable, darwin, treefmt-nix, pre-commit-hooks, @@ -37,7 +40,24 @@ let system = "aarch64-darwin"; pkgs = import nixpkgs { inherit system; }; - mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; }; + pkgsUnstable = import nixpkgsUnstable { inherit system; }; + + # Define overlays here + overlays = [ + (final: _prev: { + sapi = final.callPackage ./pkgs/sapi { }; + hashi = final.callPackage ./pkgs/hashi { }; + llmPython = final.callPackage ./pkgs/llmPython { + inherit pkgsUnstable; + }; + }) + ]; + + mkSystem = import ./nix/lib/mkSystem.nix { + inherit nixpkgs nixpkgsUnstable inputs; + inherit overlays; + }; + treefmtEval = treefmt-nix.lib.evalModule pkgs { projectRootFile = "flake.nix"; programs = { @@ -91,7 +111,7 @@ git (writeScriptBin "nbuild" '' set -e - echo "> Running darwin-rebuild switch..." + echo "> Running darwin-rebuild build..." ${inputs.darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild build --flake . echo "> darwin-rebuild build was successful ✅" echo "> macOS config was successfully applied 🚀" diff --git a/nix/lib/mkSystem.nix b/nix/lib/mkSystem.nix index b0f17ee..9cc504b 100644 --- a/nix/lib/mkSystem.nix +++ b/nix/lib/mkSystem.nix @@ -1,6 +1,10 @@ # This function creates a NixOS system based on our VM setup for a # particular architecture. -{ nixpkgs, inputs }: +{ + nixpkgs, + inputs, + overlays, +}: name: { @@ -27,6 +31,9 @@ systemFunc rec { # Allow unfree packages. { nixpkgs.config.allowUnfree = true; } + # Add overlays + { nixpkgs.overlays = overlays; } + machineConfig userOSConfig home-manager.home-manager diff --git a/nix/lib/overlays.nix b/nix/lib/overlays.nix deleted file mode 100644 index 7b338c6..0000000 --- a/nix/lib/overlays.nix +++ /dev/null @@ -1,9 +0,0 @@ -let - path = ../../overlays; -in -with builtins; -map (n: import (path + ("/" + n))) ( - filter (n: match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix"))) ( - attrNames (readDir path) - ) -) diff --git a/nix/users/fcuny/darwin.nix b/nix/users/fcuny/darwin.nix index 1291031..fc412c9 100644 --- a/nix/users/fcuny/darwin.nix +++ b/nix/users/fcuny/darwin.nix @@ -1,7 +1,5 @@ { pkgs, ... }: { - nixpkgs.overlays = import ../../../nix/lib/overlays.nix; - # The user should already exist, but we need to set this up so Nix knows # what our home directory is (https://github.com/LnL7/nix-darwin/issues/423). users.users.fcuny = { diff --git a/nix/users/fcuny/dev.nix b/nix/users/fcuny/dev.nix index d2bb6eb..1f602c4 100644 --- a/nix/users/fcuny/dev.nix +++ b/nix/users/fcuny/dev.nix @@ -1,4 +1,8 @@ -{ config, pkgs, ... }: +{ + config, + pkgs, + ... +}: { home.packages = with pkgs; [ _1password-cli @@ -14,6 +18,7 @@ # python uv python3 + llmPython.llm # nix nil # nix lsp diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index 63b0b5e..0000000 --- a/overlays/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -final: _: { - sapi = final.callPackage ../pkgs/sapi { }; - hashi = final.callPackage ../pkgs/hashi { }; -} diff --git a/pkgs/llmPython/default.nix b/pkgs/llmPython/default.nix new file mode 100644 index 0000000..0f53218 --- /dev/null +++ b/pkgs/llmPython/default.nix @@ -0,0 +1,85 @@ +{ + pkgs, + pkgsUnstable, + lib, + ... +}: +let + # Define all packages in a recursive attribute set + pythonPackages = rec { + llm = pkgsUnstable.python3.pkgs.buildPythonPackage rec { + pname = "llm"; + version = "0.24.2"; + format = "setuptools"; + + src = pkgsUnstable.fetchurl { + url = "https://files.pythonhosted.org/packages/source/l/llm/llm-0.24.2.tar.gz"; + sha256 = "sha256-4U8nIhg4hM4JaSIBtUzdlhlCSS8Nk8p0mmLQKzuL9Do="; + }; + + # Dependencies + propagatedBuildInputs = with pkgsUnstable.python3.pkgs; [ + pyyaml + click + click-default-group + condense-json + openai + pip + pluggy + puremagic + pydantic + python-ulid + setuptools + sqlite-migrate + sqlite-utils + ]; + + # Disable tests - enable if you have specific test dependencies + doCheck = false; + + # Basic import check + pythonImportsCheck = [ "llm" ]; + + meta = with lib; { + description = "CLI utility and Python library for interacting with Large Language Models from organizations like OpenAI, Anthropic and Gemini plus local models installed on your own machine."; + homepage = "https://github.com/simonw/llm"; + license = licenses.asl20; + }; + }; + + # Note, these are available in nixpkgs unstable, but are still behind the latest versions + llm-anthropic = pkgsUnstable.python3.pkgs.buildPythonPackage rec { + pname = "llm-anthropic"; + version = "0.15.1"; + format = "pyproject"; + + src = pkgs.fetchurl { + url = "https://files.pythonhosted.org/packages/source/l/llm_anthropic/llm_anthropic-0.15.1.tar.gz"; + sha256 = "sha256-C8xNs4oS51YxAn1iJkk8j4sJ5dO0pVOwIiP4mv/MnQk="; + }; + + nativeBuildInputs = with pkgsUnstable.python3.pkgs; [ + setuptools + wheel + ]; + # Dependencies + propagatedBuildInputs = with pkgsUnstable.python3.pkgs; [ + anthropic + llm # Use the llm we defined above + ]; + + # Disable tests - enable if you have specific test dependencies + doCheck = false; + + # Basic import check + pythonImportsCheck = [ "llm_anthropic" ]; + + meta = with lib; { + description = "LLM access to models by Anthropic, including the Claude series"; + homepage = "https://github.com/simonw/llm-anthropic"; + license = licenses.asl20; + }; + }; + }; +in +pythonPackages |
