litten: refactor home-manager without flakes, add open-webui

This commit is contained in:
Brian Lee 2025-01-02 18:07:38 -08:00
parent bc701730d1
commit ead5c6ebb6
10 changed files with 148 additions and 103 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ secrets.nix
archive/ archive/
glance/config.yaml glance/config.yaml
litellm.yaml litellm.yaml
result

View File

@ -1,6 +0,0 @@
# makefiles require tabs, not spaces
# :set noexpandtab
.PHONY: update
update:
home-manager switch --flake .#plebconf

View File

@ -8,12 +8,7 @@ let
host_fqdn = "${host_name}.brenise.dev"; host_fqdn = "${host_name}.brenise.dev";
in in
{ {
imports = [ # nix.settings.experimental-features = [ "nix-command" "flakes" ];
./hardware-configuration.nix
<home-manager/nixos>
];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nixpkgs.config = { nixpkgs.config = {
allowUnfreePredicate = pkg: allowUnfreePredicate = pkg:
@ -33,6 +28,14 @@ in
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ super.python312Packages.jmespath ]; propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ super.python312Packages.jmespath ];
}); # Add jmespath to ansible build inputs }); # Add jmespath to ansible build inputs
}) })
# (self: super: {
# charlatan3 = super.callPackage ./overlays/clap/charlatan3.nix { };
# }) # https://blaukraut.info/
];
imports = [
./hardware-configuration.nix
<home-manager/nixos>
]; ];
boot = { boot = {
@ -118,6 +121,7 @@ in
kdenlive kdenlive
libsForQt5.kcalc libsForQt5.kcalc
# unstable.logseq # warning: https://github.com/logseq/logseq/issues/10851#issuecomment-2402925912 # unstable.logseq # warning: https://github.com/logseq/logseq/issues/10851#issuecomment-2402925912
unstable.ghostty
moonlight-qt moonlight-qt
obs-studio obs-studio
obsidian obsidian
@ -142,7 +146,7 @@ in
})) }))
awscli2 awscli2
aws-sam-cli # broken, fails to init. use pip install aws-sam-cli aws-sam-cli
packer packer
terraform terraform
ansible ansible
@ -177,7 +181,7 @@ in
}; };
}; };
# home-manager.users.blee = { }; home-manager.users.blee = { imports = [ ./home.nix ]; };
environment = { environment = {
systemPackages = with pkgs; [ systemPackages = with pkgs; [

View File

@ -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
}

View File

@ -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 ];
};
};
};
}

View File

@ -1,12 +1,37 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
let
overlays = [
(self: super: {
charlatan3 = super.callPackage /etc/nixos/overlays/clap/charlatan3.nix { };
})
];
plebpkgs = import <nixpkgs> { overlays = overlays; };
in
{ {
nixpkgs.config = {
allowUnfreePredicate = plebpkgs:
builtins.elem (lib.getName plebpkgs) [
"charlatan3"
];
};
home = { home = {
packages = with pkgs; [ packages = with plebpkgs; [
hello 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"; username = "blee";
homeDirectory = "/home/${username}"; homeDirectory = "/home/blee";
stateVersion = "23.11"; stateVersion = "23.11";
}; };

View File

@ -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."

View File

@ -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
```

View File

@ -12,25 +12,19 @@ if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
exit 0 exit 0
fi fi
# Activate virtual environment
source .venv/bin/activate
# Source the password forr litellm
source .env
# Check if session already exists # Check if session already exists
if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
# Create new detached session # Create new detached session
tmux new-session -d -s "$SESSION_NAME" tmux new-session -d -s "$SESSION_NAME"
# Start the open-webui server # Start the open-webui server in its own virtual environment
tmux send-keys -t "$SESSION_NAME" "open-webui serve" C-m 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 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 else
echo "Session '$SESSION_NAME' already exists. Exiting." echo "Session '$SESSION_NAME' already exists. Exiting."
exit 1 exit 1

View File

@ -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 ];
};
}