Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

github-actions: add ci.yaml #4

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 71 additions & 59 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,83 @@
inputs.process-compose-flake.flakeModule
];
debug = true;
perSystem = { self', pkgs, config, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
# Required for CUDA
config.allowUnfree = true;
overlays = [
(self: _: with self; {
open-webui-frontend = callPackage (import ./nix/open-webui-frontend.nix { inherit inputs; }) { };
})
];
};
packages.open-webui-backend = inputs.dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
specialArgs = { inherit inputs; };
modules = [
./nix/open-webui-backend
perSystem = { self', pkgs, config, system, ... }:
let
open-webui-backend-module = inputs.dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
specialArgs = { inherit inputs; };
modules = [
./nix/open-webui-backend
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./nix/open-webui-backend;
}
];
};
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
# Required for CUDA
config.allowUnfree = true;
overlays = [
(self: _: with self; {
open-webui-frontend = callPackage (import ./nix/open-webui-frontend.nix { inherit inputs; }) { };
})
];
};

packages = {
# Generate the `pdm.lock` file in `nix/open-webui-backend`
open-webui-backend-lock = open-webui-backend-module.lock;
# Generate the `pyproject.toml` file in `nix/open-webui-backend`
open-webui-backend-req2py = open-webui-backend-module.req2py;
open-webui-backend-pyEnv = open-webui-backend-module.pyEnv;
};

process-compose =
let
common = { ... }: {
imports = [
inputs.services-flake.processComposeModules.default
(import ./nix/ollama.nix { inherit self' inputs; })
];
services.ollama-stack.enable = true;
};
in
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./nix/open-webui-backend;
}
];
};
process-compose =
let
common = { ... }: {
imports = [
inputs.services-flake.processComposeModules.default
(import ./nix/ollama.nix { inherit self' inputs; })
];
services.ollama-stack.enable = true;
};
in
{
default = {
imports = [ common ];
services.ollama-stack.open-webui.enable = true;
};
cuda = {
imports = [ common ];
services.ollama-stack.extraOllamaConfig = {
package = pkgs.ollama.override { acceleration = "cuda"; };
extraEnvs = {
# # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L32-L38
# CUDA_VISIBLE_DEVICES = "0,2";
default = {
imports = [ common ];
services.ollama-stack.open-webui.enable = true;
};
cuda = {
imports = [ common ];
services.ollama-stack.extraOllamaConfig = {
package = pkgs.ollama.override { acceleration = "cuda"; };
extraEnvs = {
# # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L32-L38
# CUDA_VISIBLE_DEVICES = "0,2";
};
};
};
};
rocm = {
imports = [ common ];
services.ollama-stack.extraOllamaConfig = {
package = pkgs.ollama.override { acceleration = "rocm"; };
extraEnvs = {
# # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L55-L86
# HSA_OVERRIDE_GFX_VERSION = “10.3.0”;
# # See docs: https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#rocr-visible-devices
# ROCR_VISIBLE_DEVICES = "0,GPU-DEADBEEFDEADBEEF";
# # See https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#hip-visible-devices
# HIP_VISIBLE_DEVICES = "0,2";
rocm = {
imports = [ common ];
services.ollama-stack.extraOllamaConfig = {
package = pkgs.ollama.override { acceleration = "rocm"; };
extraEnvs = {
# # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L55-L86
# HSA_OVERRIDE_GFX_VERSION = “10.3.0”;
# # See docs: https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#rocr-visible-devices
# ROCR_VISIBLE_DEVICES = "0,GPU-DEADBEEFDEADBEEF";
# # See https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#hip-visible-devices
# HIP_VISIBLE_DEVICES = "0,2";
};
};
};
};
};
};
};
};
}

4 changes: 4 additions & 0 deletions garnix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
builds:
include:
- "*.aarch64-darwin.*"
- "*.x86_64-linux.*"
2 changes: 1 addition & 1 deletion nix/ollama.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{
command = pkgs.writeShellApplication {
name = "open-webui";
runtimeInputs = [ self'.packages.open-webui-backend.pyEnv ];
runtimeInputs = [ self'.packages.open-webui-backend-pyEnv ];
text = ''
set -x
# TODO: make a service and give it a dataDir option
Expand Down
4 changes: 2 additions & 2 deletions nix/open-webui-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ This package depends on `pyproject.toml` and `pdm.lock` file. The `pyproject.tom
To generate the `pyproject.toml` run:

```sh
nix run .#open-webui-backend.req2py
nix run .#open-webui-backend-req2py
```

And to generate the `pdm.lock` file:

```sh
nix run .#open-webui-backend.lock
nix run .#open-webui-backend-lock
```