From ead5c6ebb685bfa957be5fed77d3596a5a947a35 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Thu, 2 Jan 2025 18:07:38 -0800 Subject: [PATCH] litten: refactor home-manager without flakes, add open-webui --- .gitignore | 3 +- litten.brenise.dev/Makefile | 6 --- litten.brenise.dev/configuration.nix | 20 ++++---- litten.brenise.dev/flake.lock | 48 ------------------- litten.brenise.dev/flake.nix | 26 ---------- litten.brenise.dev/home.nix | 31 ++++++++++-- litten.brenise.dev/opt/open-webui/Makefile | 40 ++++++++++++++++ litten.brenise.dev/opt/open-webui/README.md | 24 ++++++++++ .../opt/open-webui/run-open-webui.sh | 16 ++----- .../overlays/clap/charlatan3.nix | 37 ++++++++++++++ 10 files changed, 148 insertions(+), 103 deletions(-) delete mode 100644 litten.brenise.dev/Makefile delete mode 100644 litten.brenise.dev/flake.lock delete mode 100644 litten.brenise.dev/flake.nix create mode 100644 litten.brenise.dev/opt/open-webui/Makefile create mode 100644 litten.brenise.dev/opt/open-webui/README.md create mode 100644 litten.brenise.dev/overlays/clap/charlatan3.nix diff --git a/.gitignore b/.gitignore index ce0e25f..2834758 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ secrets.nix archive/ glance/config.yaml -litellm.yaml \ No newline at end of file +litellm.yaml +result \ No newline at end of file diff --git a/litten.brenise.dev/Makefile b/litten.brenise.dev/Makefile deleted file mode 100644 index c51a096..0000000 --- a/litten.brenise.dev/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# makefiles require tabs, not spaces -# :set noexpandtab - -.PHONY: update -update: - home-manager switch --flake .#plebconf diff --git a/litten.brenise.dev/configuration.nix b/litten.brenise.dev/configuration.nix index 58917bb..a699f7f 100644 --- a/litten.brenise.dev/configuration.nix +++ b/litten.brenise.dev/configuration.nix @@ -8,12 +8,7 @@ let host_fqdn = "${host_name}.brenise.dev"; in { - imports = [ - ./hardware-configuration.nix - - ]; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; +# nix.settings.experimental-features = [ "nix-command" "flakes" ]; nixpkgs.config = { allowUnfreePredicate = pkg: @@ -33,6 +28,14 @@ in propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ super.python312Packages.jmespath ]; }); # Add jmespath to ansible build inputs }) +# (self: super: { +# charlatan3 = super.callPackage ./overlays/clap/charlatan3.nix { }; +# }) # https://blaukraut.info/ + ]; + + imports = [ + ./hardware-configuration.nix + ]; boot = { @@ -118,6 +121,7 @@ in kdenlive libsForQt5.kcalc # unstable.logseq # warning: https://github.com/logseq/logseq/issues/10851#issuecomment-2402925912 + unstable.ghostty moonlight-qt obs-studio obsidian @@ -142,7 +146,7 @@ in })) awscli2 - aws-sam-cli # broken, fails to init. use pip install aws-sam-cli + aws-sam-cli packer terraform ansible @@ -177,7 +181,7 @@ in }; }; -# home-manager.users.blee = { }; + home-manager.users.blee = { imports = [ ./home.nix ]; }; environment = { systemPackages = with pkgs; [ diff --git a/litten.brenise.dev/flake.lock b/litten.brenise.dev/flake.lock deleted file mode 100644 index 433765d..0000000 --- a/litten.brenise.dev/flake.lock +++ /dev/null @@ -1,48 +0,0 @@ -{ - "nodes": { - "home-manager": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1719827415, - "narHash": "sha256-pvh+1hStXXAZf0sZ1xIJbWGx4u+OGBC1rVx6Wsw0fBw=", - "owner": "nix-community", - "repo": "home-manager", - "rev": "f2e3c19867262dbe84fdfab42467fc8dd83a2005", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "release-23.11", - "repo": "home-manager", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1720535198, - "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "ref": "nixos-23.11", - "type": "indirect" - } - }, - "root": { - "inputs": { - "home-manager": "home-manager", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/litten.brenise.dev/flake.nix b/litten.brenise.dev/flake.nix deleted file mode 100644 index 5f41611..0000000 --- a/litten.brenise.dev/flake.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - description = "Home Manager configuration"; - - inputs = { - nixpkgs.url = "nixpkgs/nixos-23.11"; - - home-manager = { - url = "github:nix-community/home-manager/release-23.11"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { nixpkgs, home-manager, ... }: - let - lib = nixpkgs.lib; - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - in { - homeConfigurations = { - plebconf = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - modules = [ ./home.nix ]; - }; - }; - }; -} \ No newline at end of file diff --git a/litten.brenise.dev/home.nix b/litten.brenise.dev/home.nix index bd53cac..4c043c1 100644 --- a/litten.brenise.dev/home.nix +++ b/litten.brenise.dev/home.nix @@ -1,12 +1,37 @@ { lib, pkgs, ... }: +let + overlays = [ + (self: super: { + charlatan3 = super.callPackage /etc/nixos/overlays/clap/charlatan3.nix { }; + }) + ]; + plebpkgs = import { overlays = overlays; }; +in { + nixpkgs.config = { + allowUnfreePredicate = plebpkgs: + builtins.elem (lib.getName plebpkgs) [ + "charlatan3" + ]; + }; home = { - packages = with pkgs; [ - hello + packages = with plebpkgs; [ + charlatan3 ]; + # Troubleshooting: ldd ~/.clap/Charlatan3.so + # Status: Not working, Reaper doesn't load the plugin. +# file = { +# ".clap/Charlatan3.so" = { +# source = "${plebpkgs.charlatan3}/lib/charlatan3/Charlatan3.so"; +# }; +# ".local/share/charlatan3/presets" = { +# source = "${plebpkgs.charlatan3}/share/charlatan3/presets"; +# }; +# }; + username = "blee"; - homeDirectory = "/home/${username}"; + homeDirectory = "/home/blee"; stateVersion = "23.11"; }; diff --git a/litten.brenise.dev/opt/open-webui/Makefile b/litten.brenise.dev/opt/open-webui/Makefile new file mode 100644 index 0000000..c3cf78d --- /dev/null +++ b/litten.brenise.dev/opt/open-webui/Makefile @@ -0,0 +1,40 @@ +# Makefile for managing virtual environments + +VENV_OPEN_WEBUI=.venv_open_webui +VENV_LITELLM=.venv_litellm +ACTIVATE_OPEN_WEBUI=$(VENV_OPEN_WEBUI)/bin/activate.fish +ACTIVATE_LITELLM=$(VENV_LITELLM)/bin/activate.fish + +.PHONY: install install_open_webui install_litellm update update_open_webui update_litellm + +install_open_webui: + @echo "Creating open-webui environment..." + python -m venv $(VENV_OPEN_WEBUI) + source $(ACTIVATE_OPEN_WEBUI) && \ + pip install -U pip open-webui && \ + deactivate + +install_litellm: + @echo "Creating litellm environment..." + python -m venv $(VENV_LITELLM) + source $(ACTIVATE_LITELLM) && \ + pip install -U pip litellm[proxy] && \ + deactivate + +install: install_open_webui install_litellm + @echo "All environments created and packages installed." + +update_open_webui: + @echo "Updating open-webui environment..." + source $(ACTIVATE_OPEN_WEBUI) && \ + pip install -U open-webui && \ + deactivate + +update_litellm: + @echo "Updating litellm environment..." + source $(ACTIVATE_LITELLM) && \ + pip install -U litellm[proxy] && \ + deactivate + +update: update_open_webui update_litellm + @echo "All environments updated." diff --git a/litten.brenise.dev/opt/open-webui/README.md b/litten.brenise.dev/opt/open-webui/README.md new file mode 100644 index 0000000..2ec4142 --- /dev/null +++ b/litten.brenise.dev/opt/open-webui/README.md @@ -0,0 +1,24 @@ +# open-webui + +Installation: + +```sh +mkdir -p /opt/open-webui +cp -v opt/open-webui/{Makefile,run-open-webui.sh, shell.nix} /opt/open-webui/ +cd /opt/open-webui +make install +``` + +Update: + +```sh +cd /opt/open-webui +make update +``` + +Running: + +```sh +cd /opt/open-webui +nix-shell +``` diff --git a/litten.brenise.dev/opt/open-webui/run-open-webui.sh b/litten.brenise.dev/opt/open-webui/run-open-webui.sh index baf6146..2b42929 100755 --- a/litten.brenise.dev/opt/open-webui/run-open-webui.sh +++ b/litten.brenise.dev/opt/open-webui/run-open-webui.sh @@ -12,25 +12,19 @@ if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then exit 0 fi -# Activate virtual environment -source .venv/bin/activate - -# Source the password forr litellm -source .env - # Check if session already exists if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then # Create new detached session tmux new-session -d -s "$SESSION_NAME" - # Start the open-webui server - tmux send-keys -t "$SESSION_NAME" "open-webui serve" C-m + # Start the open-webui server in its own virtual environment + tmux send-keys -t "$SESSION_NAME" "source .venv_open_webui/bin/activate.fish && open-webui serve" C-m - # Start litellm in a new pane + # Start litellm in a new pane with its own virtual environment tmux split-window -v -t "$SESSION_NAME" - tmux send-keys -t "$SESSION_NAME" "source .env && litellm --telemetry False --config ./litellm.yaml --host 127.0.0.1 --port $LITELLM_PORT" C-m + tmux send-keys -t "$SESSION_NAME" "source .venv_litellm/bin/activate.fish && source .env && litellm --telemetry False --config ./litellm.yaml --host 127.0.0.1 --port $LITELLM_PORT" C-m - echo "Session '$SESSION_NAME' created and configured. To connect, type: tmux att -t $SESSION_NAME" + echo "Session '$SESSION_NAME' created and configured. To connect, type: tmux attach -t $SESSION_NAME" else echo "Session '$SESSION_NAME' already exists. Exiting." exit 1 diff --git a/litten.brenise.dev/overlays/clap/charlatan3.nix b/litten.brenise.dev/overlays/clap/charlatan3.nix new file mode 100644 index 0000000..996f3a7 --- /dev/null +++ b/litten.brenise.dev/overlays/clap/charlatan3.nix @@ -0,0 +1,37 @@ +{ lib, stdenv, fetchurl, unzip, patchelf, dbus, libxcb, xcbutilkeysyms, systemd }: + +stdenv.mkDerivation rec { + pname = "charlatan3"; + version = "3.2.0"; + + src = fetchurl { + url = "https://blaukraut.info/downloads/charlatan3_${version}_linux.zip"; + sha256 = "sha256-DZA23vYh4rQsPVi8Xq9oc/VFa3YIIqsjZsg2rBuDqfc="; + }; + + nativeBuildInputs = [ unzip patchelf ]; + buildInputs = [ dbus libxcb xcbutilkeysyms systemd ]; + + unpackPhase = "unzip $src"; + + installPhase = '' + mkdir -p $out/lib/charlatan3 + cp Charlatan3.so $out/lib/charlatan3/Charlatan3.so + + # Patch the RPATH to include necessary libraries + patchelf --set-rpath "${ + lib.makeLibraryPath buildInputs + }" $out/lib/charlatan3/Charlatan3.so + + # Copy presets + mkdir -p $out/share/charlatan3/presets + cp -r presets $out/share/charlatan3/ + ''; + + meta = with lib; { + description = "Charlatan3 CLAP plugin for Reaper"; + homepage = "https://blaukraut.info/"; + license = licenses.unfreeRedistributable; + maintainers = with maintainers; [ bleetube ]; + }; +} \ No newline at end of file